tidy up some gradle things
add gradle version check
remove old wrapper task
rename 'downloadWrapper' (misnomer) to classic 'wrapper' task name
move some buildscripts to new gradle folder
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 263a91e..00be84b 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -80,7 +80,7 @@
The top-level Gradle file is `edgent/build.gradle` and it contains several
unique tasks:
-* `downloadWrapper` (default) : one-time bootstrap processing for use when building from a source release bundle
+* `wrapper` (default) : one-time bootstrap processing for use when building from a source release bundle
* `assemble` : Build all code and Javadoc into `build\distributions`. The build will fail on any code error or Javadoc warning or error.
* `all` : Synonym for `assemble`
* `build` : Essentially like "assemble test reports"
diff --git a/build.gradle b/build.gradle
index 4090017..dfa253b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,13 +17,8 @@
under the License.
*/
-ext {
- gradleVersion = "3.1"
- gradleDistributionSha256Sum = "c7de3442432253525902f7e8d7eac8b5fd6ce1623f96d76916af6d0e383010fc"
-}
-apply from: 'wrapper.gradle'
-
-apply from: 'other.gradle'
+apply from: 'gradle/wrapper.gradle'
+apply from: 'gradle/other.gradle'
import org.gradle.plugins.signing.Sign
import java.io.Console
@@ -686,8 +681,8 @@
ant.move(file: "TESTS-TestSuites.xml", tofile: "${target_report_dir}/TESTS-TestSuites.xml")
}
-apply from: 'jacoco.gradle'
-apply from: 'javadoc.gradle'
+apply from: 'gradle/jacoco.gradle'
+apply from: 'gradle/javadoc.gradle'
task addVersionDotTxt {
description = 'Add version.txt in target_dir'
@@ -873,7 +868,3 @@
description = 'Add all of the dependant external jars to the target-dir (make available to Eclipse, etc)'
dependsOn setupCommonExtJars, filteredSubprojects.setupProjectExtJars
}
-
-task wrapper(type: Wrapper) {
- jarFile = rootProject.file('.gradle-wrapper/gradle-wrapper.jar')
-}
diff --git a/gradle.properties b/gradle.properties
index 004d9d8..291599b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -14,7 +14,14 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
build_group: org.apache.edgent
build_name: edgent
build_version: 1.0.0
build_vendor: Apache Software Foundation
+
+# Minimum required gradle version and version for the wrapper to use.
+# Comment out gradleDistributionSha256Sum to disable validation of
+# a wrapper downloaded gradle distribution.
+gradleVersion = 3.1
+gradleDistributionSha256Sum = c7de3442432253525902f7e8d7eac8b5fd6ce1623f96d76916af6d0e383010fc
diff --git a/jacoco.gradle b/gradle/jacoco.gradle
similarity index 100%
rename from jacoco.gradle
rename to gradle/jacoco.gradle
diff --git a/javadoc.gradle b/gradle/javadoc.gradle
similarity index 100%
rename from javadoc.gradle
rename to gradle/javadoc.gradle
diff --git a/other.gradle b/gradle/other.gradle
similarity index 100%
rename from other.gradle
rename to gradle/other.gradle
diff --git a/wrapper.gradle b/gradle/wrapper.gradle
similarity index 60%
rename from wrapper.gradle
rename to gradle/wrapper.gradle
index 32fba02..557a8f8 100644
--- a/wrapper.gradle
+++ b/gradle/wrapper.gradle
@@ -17,10 +17,10 @@
* under the License.
*/
-defaultTasks 'downloadWrapper'
+defaultTasks 'wrapper'
-task downloadWrapper(type: Wrapper) {
- description = "Download the gradle wrapper and requisite files. Overwrites existing wrapper files."
+task wrapper(type: Wrapper) {
+ description = "Initialize the gradle wrapper. Overwrites existing wrapper files."
jarFile = "${project.projectDir}/.gradle-wrapper/gradle-wrapper.jar"
gradleVersion = project.gradleVersion
@@ -28,11 +28,24 @@
// distributionSha256Sum = project.gradleDistributionSha256Sum
doLast {
- File wrapperProps = file(propertiesFile)
- wrapperProps.append("distributionSha256Sum=${project.gradleDistributionSha256Sum}\n");
+ if (project.hasProperty("gradleDistributionSha256Sum")) {
+ File wrapperProps = file(propertiesFile)
+ wrapperProps.append("distributionSha256Sum=${project.gradleDistributionSha256Sum}\n");
+ }
}
doLast {
println "The gradle wrapper is now initialized." +
"\nUse ./gradlew for subsequent build operations."
}
}
+
+gradle.taskGraph.whenReady {taskGraph ->
+ if (!taskGraph.hasTask(wrapper)) {
+ if (GradleVersion.current() < GradleVersion.version(gradleVersion)) {
+ throw new GradleException('Running with unsupported Gradle Version (' + GradleVersion.current() + ').' +
+ '\nUse Gradle Wrapper or with Gradle version >= ' + gradleVersion +
+ '\nRun \'gradle\' (default task) to initialize the wrapper.')
+ }
+ }
+}
+