Skip to content

Gradle ParserPowerful Gradle Build File Parser

Parse, analyze, and edit Gradle build files with ease in Go

Gradle Parser

Quick Example

go
package main

import (
    "fmt"
    "github.com/scagogogo/gradle-parser/pkg/api"
)

func main() {
    // Parse a Gradle file
    result, err := api.ParseFile("build.gradle")
    if err != nil {
        panic(err)
    }

    // Access project information
    fmt.Printf("Project: %s\n", result.Project.Name)
    fmt.Printf("Version: %s\n", result.Project.Version)
    
    // List dependencies
    for _, dep := range result.Project.Dependencies {
        fmt.Printf("Dependency: %s:%s:%s (%s)\n", 
            dep.Group, dep.Name, dep.Version, dep.Scope)
    }
}

Installation

bash
go get github.com/scagogogo/gradle-parser/pkg/api

Key Features

🔍 Comprehensive Parsing

  • Extract project metadata (group, name, version, description)
  • Parse dependencies with scope classification
  • Analyze plugin configurations and detect project types
  • Process repository configurations including custom repositories

✏️ Structured Editing

  • Update dependency versions programmatically
  • Modify plugin versions and configurations
  • Edit project properties while preserving formatting
  • Add new dependencies with proper placement

📍 Source Location Tracking

  • Precise line and column information for every element
  • Enable accurate modifications with minimal diff
  • Support for complex editing scenarios

🌐 Multi-Language Support

  • Full support for Groovy DSL syntax
  • Kotlin DSL compatibility
  • Handle both single and multi-module projects

Use Cases

  • Build Tool Integration: Integrate Gradle parsing into your build tools and IDEs
  • Dependency Management: Analyze and update project dependencies programmatically
  • Project Analysis: Extract insights from Gradle projects for reporting and analytics
  • Automated Maintenance: Bulk update dependencies and configurations across projects
  • Migration Tools: Build tools to migrate between Gradle versions or configurations

Community

License

Gradle Parser is released under the MIT License.

Released under the MIT License.