Skip to content

Commit

Permalink
Defer more configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Feb 23, 2023
1 parent 3075ea6 commit ea7d3ed
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,31 @@ idea {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

task downloadDependencies(type: Exec) {
tasks.register("downloadDependencies", Exec) {
dependsOn configurations.testRuntimeClasspath
commandLine 'echo', 'Downloaded all dependencies'
}

tasks.build.dependsOn tasks.shadowJar
tasks.named("build") { dependsOn tasks.shadowJar }

project.tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}

project.tasks.withType(GroovyCompile) {
tasks.withType(GroovyCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}

task relocateShadowJar(type: ConfigureShadowRelocation) {
def relocateShadowJar = tasks.register("relocateShadowJar", ConfigureShadowRelocation) {
target = tasks.shadowJar
}

tasks.shadowJar.dependsOn tasks.relocateShadowJar
tasks.named("shadowJar") {
dependsOn relocateShadowJar
}
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ sourceSets {
}
}

project.tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}

project.tasks.withType(GroovyCompile) {
tasks.withType(GroovyCompile).configureEach {
// This will be the default in Gradle 5.0
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
Expand Down
13 changes: 8 additions & 5 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
def javaApiUrl = 'http://docs.oracle.com/javase/1.7.0/docs/api'
def groovyApiUrl = "http://docs.groovy-lang.org/2.4.7/html/gapi/"

tasks.withType(Javadoc) {
tasks.withType(Javadoc).configureEach {
classpath += project.configurations.shadow
options.links(javaApiUrl, groovyApiUrl)
if (JavaVersion.current().java8Compatible) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register("javadocJar", Jar) {
dependsOn javadoc
archiveClassifier.set('javadoc')
from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
tasks.register("sourcesJar", Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

project.tasks.groovydoc {
tasks.named("groovydoc") {
classpath += project.configurations.shadow
}

build.dependsOn javadocJar, sourcesJar
tasks.named("build") {
dependsOn javadocJar, sourcesJar
}
2 changes: 1 addition & 1 deletion gradle/ghPages.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gitPublish {
from '.circleci'
}
into('api') {
from project.tasks.groovydoc
from tasks.groovydoc
}
filter(ReplaceTokens, tokens: [version: project.version])
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ signing {
sign publishing.publications.plugin
}

task release() {
tasks.register("release") {
dependsOn 'assemble', 'publishPlugins', 'gitPublishPush'
}
2 changes: 1 addition & 1 deletion src/docs/configuration/reproducible-builds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
By default, JAR files generated by Gradle (with or without Shadow) for a single project with the same source code may not be identical to each other. Sometimes it's desireable to configure a project to consistently output a byte-for-byte identical JAR on every build. Gradle supports this with the following configuration, and Shadow will correctly respect these settings too:

```groovy
tasks.withType(AbstractArchiveTask) {
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
Expand Down

0 comments on commit ea7d3ed

Please sign in to comment.