A Gradle Plugin Providing Full Support for Go

Gogradle - a Full-featured Build Tool for Golang

中文文档

gogradle Coverage Status Java 8+ Apache License 2

Gogradle is a gradle plugin which provides support for building golang.

2017-06-23 Gogradle is awarded Gradle Plugin of the Year 2017. See the talk on Gradle Summit 2017.

2017-12-17 Now Gogradle can build 817 of Github's top 1000 Go repositories WITHOUT any extra configuration!

2017-03-20 Now Gogradle can generate HTML reports for test and coverage!

What is Gogradle?

Gogradle is a Gradle plugin which provide modern build support for Golang. Gogradle is deeply inspired by glide(I need to pay respect for it). You can simply think Gogradle as glide+make.

Why Gogradle?

  • make has a very steep learning curve, thus many people (like me) aren't good at it; Gradle use a DSL with similar syntax to Java to describe a build, which is easier for me.
  • Makefile and Shell have cross-platform issues, especially on Windows. Thanks to Gradle and JVM, Gogradle provide an excellent cross-platform support and can leverage the whole Java ecosystem
  • There're many mature plugins in Gradle ecosystem, and it's easy for yourself to implement a plugin to reuse your build code
  • Gogradle supports project-scoped GOPATH, if you prefer
  • Gogradle supports existence and switch of multi-version of Go
  • There's plenty of package management tools in Go community which are not compatible with each other.
    • Gogradle provides a migration command which enables you to migrate from other tools.
    • Gogradle is compatible with glide/glock/godep/gom/gopm/govendor/gvt/gbvendor/trash/gpm. When retrieving a dependency package's transitive dependencies, it can recognized lock files of these tools.
  • Gogradle has a long-term and active development support

Gogradle implements most features of glide and adds some extra features:

  • Test and coverage reports generation
  • Multi-version management of Go
  • IDE support
  • Declaration and substitution of repositories, which can be used as mirror repositories

If you puzzled over these issues, or you were a Java developer and familiar with Gradle, Gogradle is your choice!

Gogradle's objective is not replacing other tools, it only provides an option for developers.

Gogradle is NOT a toy. 52% of its code are tests to assure its quality. We also tested Github's top 1000 Go repositories as real world scenarios.

Feature

  • No need to preinstall anything but JDK 8+ (including golang itself)
    • If you're using JetBrains IDE, then JDK is not required
  • Supports Go 1.5+ and allow their existence at the same time
  • Perfect cross-platform support (as long as Java can be run, all tests have passed on OS X 10.11/Ubuntu 12.04/Windows 7)
  • Project-scope build, needless to set GOPATH
  • Full-featured package management
    • Needless to install dependency packages manually, all you need to do is specifying the version
    • VCS supported: Git/Mercurial
    • Transitive dependency management
    • Resolves package conflict automatically
    • Supports dependency lock
    • Supports importing dependencies managed by various external tools such as glide/glock/godep/gom/gopm/govendor/gvt/gbvendor/trash/gpm (Based on this report)
    • Supports submodule
    • Supports SemVersion
    • Supports vendor
    • Supports flattening dependencies (Inspired by glide)
    • Supports renaming local packages
    • Supports private repository
    • Support automatic repository url substitution
    • build/test dependencies are managed separately
    • Supports dependency tree visualization
    • Supports sub packages
  • Supports build/test/single-test/wildcard-test/cross-compile
  • Modern production-grade support for automatic build, simple to define customized tasks
  • Native syntax of gradle
  • Additional features for users in mainland China who are behind the GFW
  • Supports shadowsocks proxy
  • IDE support
  • Test and coverage report generation
  • Incremental build

How Gogradle works

Gogradle's work is based on vendor mechanism. You declare your build dependencies and build logic with Gradle DSL in build.gradle, and Gogradle will resolve all dependencies and potential package conflict, then install them into vendor directory and execute a build. In this course, dependency packages will be flattened to avoid issues. Later, you can lock your resolved dependencies to ensure a reproducible build. It's up to you whether to check in vendor directory or not.

See here for examples.

Table of Content

Snapshot

Test report

1 1 1 1

Coverage report

1 1

Contributing

If you like Gogradle, star it please.

Please feel free to submit an issue.

Fork and PR are always welcomed.

Contributor Guide

Gogradle is developed in IntelliJ IDEA. You can run ./gradlew idea and open the generated .ipr files in IDEA.

Please make sure all checks passed via ./gradlew check.

Comments
  • Gogradle plugin apply issue

    Gogradle plugin apply issue

    Hello,

    I am newbie to gogradle. When I am using the plugin in my build.gradle file, I am getting below error

    An exception occurred applying plugin request [id: 'com.github.blindpirate.gogradle', version: '0.11.4']

    Failed to apply plugin [id 'com.github.blindpirate.gogradle'] Could not create task ':services:rsamicroservice:goBuild'. > Could not create task of type 'GoBuild'. > Could not initialize class com.github.blindpirate.gogradle.crossplatform.Os

    Here is my build.gradle file

    plugins { id 'com.github.blindpirate.gogradle' version '0.11.4' }

    golang { packagePath = 'github.com/rsamicroservice/rsaserver' }

    dependencies { golang { build 'github.com/jinzhu/gorm' build 'github.com/jinzhu/gorm/dialects/postgres' build 'github.com/joho/godotenv' build '"google.golang.org/grpc' build 'google.golang.org/grpc/codes' build 'google.golang.org/grpc/reflection' build 'google.golang.org/grpc/status' build 'google.golang.org/protobuf/encoding/protojson'

    }
    

    }

    goBuild.dependsOn goCheck

    goBuild { outputLocation = './rsaserver${GOEXE}' }

  • gogradle doesn't work with beta builds of go

    gogradle doesn't work with beta builds of go

    The regex used to check if a version of go is valid doesn't work for beta builds.
    The current go beta build is 1.18beta1 which doesn't match GO_VERSION_REGEX or GO_VERSION_OUTPUT_REGEX. As a result, this build can't be used with gogradle at all.

  • Is Gogradle still maintained?

    Is Gogradle still maintained?

    I'm about to start a Go project and, as I'm a big Gradle fan, was wondering if Gogradle could help me with that. Looking at the recent contributions to this project I see that there's not much happening here recently. So my question is: is Gogradle still maintained? Should I use it in my new projects?

  • Failed to apply plugin  - Gradle 7.2

    Failed to apply plugin - Gradle 7.2

    Hi,

    gradle goInit resulted in Failed to apply plugin 'com.github.blindpirate.gogradle'.

    Details:

    * What went wrong:
    An exception occurred applying plugin request [id: 'com.github.blindpirate.gogradle', version: '0.11.4']
    > Failed to apply plugin 'com.github.blindpirate.gogradle'.
       > Unable to create injector, see the following errors:
    
         1) Injected method org.gradle.api.internal.project.DefaultProject.getProviders() cannot be abstract.
    
         2) Injected method org.gradle.api.internal.project.DefaultProject.getDependencyMetaDataProvider() cannot be abstract.
    
         3) Injected method org.gradle.api.internal.project.DefaultProject.getPluginManager() cannot be abstract.
    
         4) Injected method org.gradle.api.internal.project.DefaultProject.getConfigurationActions() cannot be abstract.
    
         5) Injected method org.gradle.api.internal.project.DefaultProject.getModelRegistry() cannot be abstract.
    
         6) Injected method org.gradle.api.internal.project.DefaultProject.getBuildscript() cannot be abstract.
    
         7) Injected method org.gradle.api.internal.project.DefaultProject.getObjects() cannot be abstract.
    
         8) Injected method org.gradle.api.internal.project.DefaultProject.getLayout() cannot be abstract.
    
         9) Injected method org.gradle.api.internal.project.DefaultProject.getLogging() cannot be abstract.
    
         10) Injected method org.gradle.api.internal.project.DefaultProject.getRepositories() cannot be abstract.
    
         11) Injected method org.gradle.api.internal.project.DefaultProject.getComponents() cannot be abstract.
    
         12) Injected method org.gradle.api.internal.project.DefaultProject.getNormalization() cannot be abstract.
    
         13) Injected method org.gradle.api.internal.project.DefaultProject.getDependencyLocking() cannot be abstract.
    
         14) Injected method org.gradle.api.internal.project.DefaultProject.getFileOperations() cannot be abstract.
    
         15) Injected method org.gradle.api.internal.project.DefaultProject.getProcessOperations() cannot be abstract.
    
         16) Injected method org.gradle.api.internal.project.DefaultProject.getScriptHandlerFactory() cannot be abstract.
    
         17) Injected method org.gradle.api.internal.project.DefaultProject.getScriptPluginFactory() cannot be abstract.
    
         18) Injected method org.gradle.api.internal.project.DefaultProject.getListenerBuildOperationDecorator() cannot be abstract.
    
         19) Injected method org.gradle.api.internal.project.DefaultProject.getProjectEvaluator() cannot be abstract.
    
         20) Injected method org.gradle.api.internal.project.DefaultProject.getCrossProjectModelAccess() cannot be abstract.
    
         21) Injected method org.gradle.api.internal.project.DefaultProject.getDeferredProjectConfiguration() cannot be abstract.
    
         22) Injected method org.gradle.api.internal.project.DefaultProject.getProjectConfigurator() cannot be abstract.
    
         22 errors
    

    build.gradle

    plugins {
        id 'com.github.blindpirate.gogradle' version '0.11.4'
        id 'application'
    }
    
    repositories {
        // Use Maven Central for resolving dependencies.
        mavenCentral()
    }
    
    golang {
        packagePath = 'github.com/jfrog/artifactory-secrets-plugin'
    }
    
    ❯ gradle --version
    
    ------------------------------------------------------------
    Gradle 7.2
    ------------------------------------------------------------
    
    Build time:   2021-08-17 09:59:03 UTC
    Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad
    
    Kotlin:       1.5.21
    Groovy:       3.0.8
    Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
    JVM:          15.0.2 (AdoptOpenJDK 15.0.2+7)
    OS:           Mac OS X 10.16 x86_64
    
  • Windows Development Requires

    Windows Development Requires "Developer Mode" be Enabled

    When running commands like

    .\gradlew.bat goInit
    

    The Windows Setting "For developers" -> "Developer Mode" must be enabled. In particular the ability to construct symbolic links is disabled for regular users.

The plugin serves as a starting point for writing a Mattermost plugin

Plugin Starter Template This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.

Dec 10, 2021
Feb 10, 2022
Cf-cli-find-app-plugin - CF CLI plugin to find applications containing a search string

Overview This cf cli plugin allows users to search for application names that co

Jan 3, 2022
Twitter-plugin - Falco Plugin for Twitter Stream

Twitter Plugin This repository contains the twittter plugin for Falco, which fol

Mar 17, 2022
Node for providing data into Orakuru network

Orakuru's crystal-ball Node for providing data into Orakuru network. Configuration Crystal-ball uses environment variables and configuration files for

Jan 20, 2022
Go library providing an abstraction to Ethereum execution nodes

go-execution-client Go library providing an abstraction to Ethereum execution nodes. Its external API follows the official Ethereum consensus APIs spe

Aug 12, 2022
Chacha20 with blake2s providing authentication

chacha20blake2s A small construction of chacha20 with blake2s as the HMAC. This

Jan 3, 2022
A C/S Tool to Download Torrent Remotely and Retrieve Files Back Over HTTP at Full Speed without ISP Torrent Limitation.

remote-torrent Download Torrent Remotely and Retrieve Files Over HTTP at Full Speed without ISP Torrent Limitation. This repository is an extension to

Sep 30, 2022
[deprecated] A full-featured SPDY library for the Go language.

Deprecated With the release of Go1.6 and the addition of http2 to the standard library, this package is no longer under active development. It is high

Oct 1, 2022
Inspired by go-socks5,This package provides full functionality of socks5 protocol.
Inspired by go-socks5,This package provides full functionality of socks5 protocol.

The protocol described here is designed to provide a framework for client-server applications in both the TCP and UDP domains to conveniently and securely use the services of a network firewall.

Dec 16, 2022
Full-featured BitTorrent client package and utilities

torrent This repository implements BitTorrent-related packages and command-line utilities in Go. The emphasis is on use as a library from other projec

Jan 2, 2023
Baseledger core consensus for running validator, full and seed nodes

baseledger-core Baseledger core consensus client for running a validator, full or seed node. ⚠️ WARNING: this code has not been audited and is not rea

Jan 13, 2022
Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021
proxylogon, proxyshell, proxyoracle full chain exploit tool
proxylogon, proxyshell, proxyoracle full chain exploit tool

Proxy-Attackchain proxylogon, proxyshell, proxyoracle full chain exploit tool ProxyLogon: The most well-known and impactful Exchange exploit chain Pro

Dec 16, 2022
Imersão Full Cycle 5
Imersão Full Cycle 5

Imersão Full Cycle 5 Dinâmica do sistema Tecnologias Frontend Painel: Next.js Backend Painel: Nest.js Microsserviço processamento: Golang Sistema de m

Jan 10, 2022
A Go package for creating contributor list by release, Help full for those organization that use one repository for platform release

This is a Go package which create contributors list by release by scanning across all repository that exist in organisation, Only helpful for those or

Dec 26, 2021
Wrapper around bufcli to make it do cross-repo compiles for private repos and use full paths.
Wrapper around bufcli to make it do cross-repo compiles for private repos and use full paths.

Bufme A tool for compiling protos with full directory paths and cross repo compiles. Introduction Protocol buffers rock, but protoc should die in a fi

Feb 5, 2022
A Go library for connecting to HandlerSocket (github.com/ahiguti/HandlerSocket-Plugin-for-MySQL)

handlersocket-go Go library for connecting to HandlerSocket Mysql plugin. See github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/ Installation $ go get

Jan 19, 2021
Yet another SIP003 plugin for shadowsocks, based on Xray-core

Yet another SIP003 plugin for shadowsocks, based on Xray-core Build go build Usage See command line args for advanced usages.

Jan 8, 2023