Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #73 from blindpirate/nameconflict
Browse files Browse the repository at this point in the history
Rename tasks to avoid name conflict
  • Loading branch information
blindpirate committed Apr 8, 2017
2 parents 9ecd77a + 603477c commit 9a44eb1
Show file tree
Hide file tree
Showing 35 changed files with 259 additions and 875 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ golang {
}
dependencies {
build name:'github.com/my/project',url:'${repoUrl}'
golang {
build name:'github.com/my/project',url:'${repoUrl}'
}
}
golang {
goExecutable = '${StringUtils.toUnixString(goBinPath)}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ repositories {
void 'dependencies should be resolved correctly'() {
try {
newBuild {
it.forTasks('dependencies')
it.forTasks('goDependencies')
}

String actualOutput = stdout.toString().replaceAll('\\r', '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,26 @@ repositories {
dependencies {
build 'github.com/firstlevel/a'
build(
golang{
build 'github.com/firstlevel/a'
build(
[name: 'github.com/firstlevel/b', version: '67b0cfae52118d8044c03c1564fd2845ba1b81e1'], // commit3
'github.com/firstlevel/c@1.0.0'
)
)
build('github.com/firstlevel/d') {
transitive = false
}
build('github.com/firstlevel/d') {
transitive = false
}
build(name: 'github.com/firstlevel/e', commit: '95907c7d') { // commit5
transitive = true
exclude name: 'github.com/external/e'
}
build(name: 'github.com/firstlevel/e', commit: '95907c7d') { // commit5
transitive = true
exclude name: 'github.com/external/e'
}
build name: 'github.com/firstlevel/f', dir: "${StringUtils.toUnixString(localDependencyRoot)}"
build name: 'github.com/firstlevel/f', dir: "${StringUtils.toUnixString(localDependencyRoot)}"
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ golang {
packagePath='my/project'
}
dependencies {
build (name:'a', dir: '${StringUtils.toUnixString(new File(resource, "a"))}'){
exclude name:'e'
golang {
build (name:'a', dir: '${StringUtils.toUnixString(new File(resource, "a"))}'){
exclude name:'e'
}
}
}
""")
Expand All @@ -51,7 +53,7 @@ dependencies {
void 'exclusion in ancestor should succeed'() {
try {
newBuild {
it.forTasks('dependencies', 'resolveBuildDependencies')
it.forTasks('goDependencies', 'resolveBuildDependencies')
}
} finally {
println(stderr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ golang {
packagePath='github.com/my/package'
goVersion='1.8'
}
build {
goBuild {
targetPlatform = 'darwin-amd64, windows-amd64, linux-386, ${Os.getHostOs()}-${Arch.getHostArch()}'
}
"""
Expand Down Expand Up @@ -79,7 +79,7 @@ func main(){
@Test
void 'build should succeed'() {
newBuild {
it.forTasks('build')
it.forTasks('goBuild')
}

["darwin_amd64_myPackage", 'windows_amd64_myPackage', 'linux_386_myPackage'].each {
Expand All @@ -103,15 +103,15 @@ func main(){
@Test
void 'customized build should succeed'() {
writeBuildAndSettingsDotGradle(buildDotGradle + '''
build {
goBuild {
doLast {
go 'build -o ${GOOS}_${GOARCH}_output github.com/my/package/sub'
}
}
''')
try {
newBuild {
it.forTasks('build')
it.forTasks('goBuild')
}
} catch (Exception e) {
println(stderr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ golang {
void 'test and coverage report should be generated successfully'() {
try {
newBuild {
it.forTasks('check')
it.forTasks('goCheck')
}
} finally {
println(stderr)
Expand Down Expand Up @@ -61,7 +61,7 @@ golang {

try {
newBuild {
it.forTasks('check')
it.forTasks('goCheck')
}
} catch (BuildException e) {
println(stderr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ golang {
writeBuildAndSettingsDotGradle(buildDotGradle)
try {
newBuild {
it.forTasks('vet')
it.forTasks('goVet')
}
} catch (BuildException e) {
assert stderr.toString().contains('first argument to Println is os.Stderr')
assert stderr.toString().contains('exit status 1')
assert stdout.toString().contains('vet FAILED')
assert stdout.toString().contains('goVet FAILED')
}
}

@Test
void 'exception should be suppressed if continueWhenFail=true'() {
writeBuildAndSettingsDotGradle(buildDotGradle + '''
vet {
goVet {
continueWhenFail = true
}
''')
newBuild {
it.forTasks('vet')
it.forTasks('goVet')
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ golang {
void 'gofmt should succeed'() {
try {
newBuild {
it.forTasks('fmt')
it.forTasks('gofmt')
}
} finally {
println(stderr)
Expand Down Expand Up @@ -86,14 +86,14 @@ func sub() {
@Test
void 'customized gofmt should not affect other files'() {
writeBuildAndSettingsDotGradle(buildDotGradle + '''
fmt {
gofmt {
doLast {
gofmt '-w main.go'
}
}
''')
newBuild {
it.forTasks('fmt')
it.forTasks('gofmt')
}

assert new File(resource, 'sub/sub.go').getText() == subDotGo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ golang {
goVersion='1.8'
}
vet {
goVet {
continueWhenFail = true
}
Expand All @@ -46,7 +46,7 @@ vet {

// I don't know why it will fail on Windows
if (Os.getHostOs() == Os.WINDOWS) {
writeBuildAndSettingsDotGradle(buildDotGradle + 'test.enabled = false')
writeBuildAndSettingsDotGradle(buildDotGradle + 'goTest.enabled = false')
} else {
writeBuildAndSettingsDotGradle(buildDotGradle)
}
Expand All @@ -70,7 +70,7 @@ vet {
void firstBuild() {
try {
newBuild {
it.forTasks('build', 'check', 'lock', 'dependencies')
it.forTasks('goBuild', 'goCheck', 'goLock', 'goDependencies')
}
} catch (Exception e) {
throw e
Expand All @@ -83,7 +83,7 @@ vet {
void secondBuild() {
try {
newBuild {
it.forTasks('build', 'check', 'dependencies')
it.forTasks('goBuild', 'goCheck', 'goDependencies')
}
} catch (Exception e) {
throw e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,20 @@ golang{
IOUtils.mkdir(resource, '.tmp')
IOUtils.write(resource, 'build.gradle', buildDotGradle + """
dependencies {
build name:'tmp', dir: '${StringUtils.toUnixString(new File(resource, '.tmp'))}'
golang {
build name:'tmp', dir: '${StringUtils.toUnixString(new File(resource, '.tmp'))}'
}
}
""")
build()
assertNotUpToDate()

IOUtils.write(resource, 'build.gradle', buildDotGradle + """
dependencies {
build(name:'tmp', dir: '${StringUtils.toUnixString(new File(resource, '.tmp'))}'){
exclude name:'xxx'
golang {
build(name:'tmp', dir: '${StringUtils.toUnixString(new File(resource, '.tmp'))}'){
exclude name:'xxx'
}
}
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ golang {
packagePath='sample'
}
dependencies {
build 'github.com/golang/example'
golang {
build 'github.com/golang/example'
}
}
"""
IOUtils.write(resource, 'hello.go', helloDotGo)
Expand All @@ -34,7 +36,7 @@ dependencies {
@AccessWeb
void 'build string reverse example should succeed'() {
newBuild { build ->
build.forTasks('dependencies', 'build')
build.forTasks('goDependencies', 'goBuild')
}

assertDependencyOutput()
Expand All @@ -48,7 +50,7 @@ dependencies {
initStdoutStderr()

newBuild { build ->
build.forTasks('dependencies')
build.forTasks('goDependencies')
}

assertDependencyOutput()
Expand All @@ -62,7 +64,7 @@ dependencies {
IOUtils.write(resource, 'hello.go', helloDotGo + " ")

newBuild { build ->
build.forTasks('dependencies')
build.forTasks('goDependencies')
}

assertDependencyOutput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ golang {
goExecutable='${StringUtils.toUnixString(goBinPath)}'
}
dependencies {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}'){
exclude name:'unrecognized2'
golang {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}'){
exclude name:'unrecognized2'
}
}
}
""")
Expand Down Expand Up @@ -93,9 +95,9 @@ repositories {
}
dependencies {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}')
// build (name:'unrecognized2', url: 'http://localhost:8080/helloworld')
golang {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}')
}
}
""")
Expand Down Expand Up @@ -128,8 +130,10 @@ repositories {
}
dependencies {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}'){
exclude name:'unrecognized3'
golang {
build (name:'unrecognized1', dir: '${getResourceDir("unrecognized1")}'){
exclude name:'unrecognized3'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ repositories {
}
dependencies {
build 'my/awesome/project'
golang {
build 'my/awesome/project'
}
}
"""
writeBuildAndSettingsDotGradle(buildDotGradle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS
import static org.mockito.Mockito.mock

abstract class GogradleModuleSupport {
@Mock
Instantiator instantiator

ProjectInternal project = mock(DefaultProject, RETURNS_DEEP_STUBS)

Injector injector

@Before
void initInjector() {
injector = Guice.createInjector(new GogradleModule(project, instantiator))
injector = Guice.createInjector(new GogradleModule(project))
GogradleGlobal.INSTANCE.setInjector(injector)
injector.injectMembers(this)
}
Expand Down
Loading

0 comments on commit 9a44eb1

Please sign in to comment.