This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added it to the new :buildSrc project, along with a preliminary test. * Updated .gitignore so that source code in the "edu.ucar.build" package isn't ignored
- Loading branch information
cwardgar
committed
Jan 18, 2016
1 parent
c9d514b
commit d7e01cc
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apply plugin: 'groovy' | ||
|
||
apply from: "../gradle/dependencies.gradle" | ||
|
||
dependencies { | ||
compile gradleApi() // We're developing a custom task, so we need the Gradle API. | ||
|
||
testCompile (libraries["spock-core"]) { | ||
// The Gradle API drags in the bundled version of Groovy that Gradle ships with (localGroovy()) – | ||
// see https://discuss.gradle.org/t/unable-to-force-gradle-to-use-groovy-2-0-0-for-the-project/7021. | ||
// Spock drags in another Groovy as a transitive dependency. | ||
// | ||
// So, there are multiple candidate versions of the Groovy dependency. Ordinarily, this is no problem for | ||
// Gradle; it bas version-conflict-resolution machinery to deal with it. However, localGroovy() is a special | ||
// kind of dependency that doesn't participate in that resolution (again, see above URL). | ||
// | ||
// Once added to a configuration, localGroovy() will remain part of it no matter what. Furthermore, since | ||
// localGroovy() is "special", Gradle will not consider a second, "normal" Groovy dependency to be in conflict | ||
// with it. This can result in two different versions of Groovy in the same configuration, and ultimately | ||
// errors like: "groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded | ||
// in version 2.4.4 and you are trying to load version 2.4.1". | ||
// | ||
// Our solution is to explicitly exclude any other Groovy dependencies whenever localGroovy() is already part | ||
// of the configuration. | ||
exclude group: 'org.codehaus.groovy', module: 'groovy-all' | ||
} | ||
} | ||
|
||
task foo << { | ||
println rootProject?.name | ||
println project?.name | ||
println project?.parent?.name | ||
println "$rootDir" | ||
} |
18 changes: 18 additions & 0 deletions
18
buildSrc/src/main/groovy/edu/ucar/build/GenerateMavenBom.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package edu.ucar.build | ||
|
||
import org.gradle.api.publish.maven.tasks.GenerateMavenPom | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* | ||
* | ||
* @author cwardgar | ||
* @since 2016-01-16 | ||
*/ | ||
class GenerateMavenBom extends GenerateMavenPom { | ||
@TaskAction | ||
def generateBom() { | ||
println "YAY!" | ||
println "Project: $project" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
buildSrc/src/test/groovy/edu/ucar/build/GenerateMavenBomTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package edu.ucar.build | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
|
||
/** | ||
* | ||
* | ||
* @author cwardgar | ||
* @since 2016-01-16 | ||
*/ | ||
class GenerateMavenBomTest extends Specification { | ||
def "DoIt"() { | ||
setup: | ||
ProjectBuilder builder = ProjectBuilder.builder().withName("GenerateMavenBomTest") | ||
Project project = builder.build() | ||
|
||
Task task = project.tasks.create(name: 'generateBom', type: GenerateMavenBom) { | ||
} | ||
|
||
when: | ||
task.generateBom() | ||
|
||
then: | ||
true | ||
} | ||
} |