Code Monkey home page Code Monkey logo

gogradle's Introduction

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.

gogradle's People

Contributors

0xflotus avatar blindpirate avatar bmuschko avatar ddska avatar fkorotkov avatar jonpspri avatar joshpetit avatar keykey7 avatar khamutov avatar maguro avatar markslater avatar mkobit avatar rgoomar avatar testpersonal avatar tonyabbott avatar zhaoying818 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gogradle's Issues

Extracting package path from string dependency notation is not accurate

Current implementation of extracting package path from string dependency notation is:

    private String extractPackagePath(String notation) {
        for (int i = 0; i < notation.length(); ++i) {
            char c = notation.charAt(i);
            // TODO not accurate
            if (c == '#' || c == '@') {
                return notation.substring(0, i);
            }
        }
        return notation;
    }

It is not accurate.

Build fails right away with no Go source files in the project directory

The following project builds fine in native Go but fails right away when building with Gradle.

To reproduce ...

$ mkdir -p $GOPATH/src/github.com/tendermint
$ git clone https://github.com/tendermint/tendermint $GOPATH/src/github.com/tendermint/tendermint
$ cd $GOPATH/src/github.com/tendermint/tendermint
$ git checkout develop
$ git pull
$ glide install
$ go install ./cmd/tendermint
$ gradle --no-daemon build
:prepare
Found go 1.8 in C:\opt\go\bin\go.exe, use it.
:resolveBuildDependencies
:installBuildDependencies
:build
can't load package: package .: no buildable Go source files in C:\home\projects\go\src\github.com\tendermint\tendermint
:build FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':build'.
> Build failed due to non-zero return code of go process: 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Following my simple Gradle build file ...

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

golang {
    packagePath = 'github.com/tendermint/tendermint' // path of project to be built 
}

Now, it is true that there are no Go sources directly under directory $GOPATH/src/github.com/tendermint/tendermint, but should this fail the build?

Please advise. Thanks.

chat

task cell_package(type: Zip) {
outputs.upToDateWhen { false }
baseName = "cell_package"

from (ReleaseDir)
}

我能使用这种方式吗?

build failed while fetching metadata on private bitbucket repo

Hi,

I tried to build a go project with private bitbucket repos as dependencies. This can't be done, because gogradle tries to fetch metadata from a private bitbucket repo and receives a 403 error.

12:11:00.241 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@4a08c8885 pairs: {GET /2.0/repositories/xxx/xxx HTTP/1.1: null}{User-Agent: Go-http-client/1.1 Java/1.8.0_121}{Host: api.bitbucket.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}

(I removed the repo and replaced it with xxx)

Based on this https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html a basic auth user and password should be provided

Single test and multiple test should be supported

We should support specifying test cases in command line param as native gradle do.

See here

gradle test --tests org.gradle.SomeTest.someSpecificFeature
gradle test --tests *SomeTest.someSpecificFeature
gradle test --tests *SomeSpecificTest
gradle test --tests all.in.specific.package*
gradle test --tests *IntegTest
gradle test --tests *IntegTest*ui*
gradle someTestTask --tests *UiTest someOtherTestTask --tests *WebTest*ui

packagePath 应该怎么配置?

你好:
我在使用 gogradle时碰到一点问题:

我有代码路径如下:
c:\Users\someone\workspace\goinaction\src\github.com\someone\cpt4\cpt4.go
然后在 build.gradle 中配置 packagePath 如下:

...
golang {
  packagePath = 'c:/Users/someone/workspace/goinaction'
}

build 的时候提示 cant't load package: package .: no buildable Go source files in C:\Users\someone\workspace\goinaction\

修改build的配置, 配置 packagePath 指向 go 文件存在的位置

golang {
  packagePath = 'c:/Users/someone/workspace/goinaction/src/github.com/someone/cpt4/cpt.go'
}

也提示找不到可以build的源文件...

Gopmfile should be parsed more accurately

.gopmfile is actually a git config file, but it contains non-standard key name such as github.com/x/y which cannot be accepted by standard git config parser. Current implementation is simple and not fully fault-tolerant. The parser implementation should be more accurate, e.g., ANTLR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.