polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [08/33] polygene-java git commit: Fix Gradle wrapper installation from source distribution
Date Tue, 23 May 2017 02:13:51 GMT
Fix Gradle wrapper installation from source distribution

A separate mini-build that should be compatible with ancient versions of
Gradle allows to install the Gradle Wrapper pointing to the Gradle
version required by the Polygene build.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/d5d753ff
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/d5d753ff
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/d5d753ff

Branch: refs/heads/yeoman-work
Commit: d5d753ffd1784eed411c314e6519ac01c37c725a
Parents: cf4876b
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Wed May 17 12:41:24 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Wed May 17 13:00:34 2017 +0200

----------------------------------------------------------------------
 .../distributions/DistributionsPlugin.groovy    | 19 +++++++++++----
 distributions/src/src-dist/README.txt           | 16 +++++++------
 .../gradle/wrapper-install/build.gradle         | 25 ++++++++++++++++++++
 .../gradle/wrapper-install/settings.gradle      | 19 +++++++++++++++
 4 files changed, 68 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d5d753ff/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
index 46233ce..3425d70 100644
--- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
@@ -52,6 +52,7 @@ import org.gradle.plugins.ide.internal.IdeDependenciesExtractor
 import org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency
 import org.gradle.plugins.signing.Sign
 import org.gradle.plugins.signing.SigningExtension
+import org.gradle.process.ExecSpec
 
 import java.nio.file.Files
 import java.nio.file.Path
@@ -118,6 +119,7 @@ class DistributionsPlugin implements Plugin<Project>
   private static void applySourceDistribution( Project project )
   {
     def releaseSpec = project.extensions.getByType( ReleaseSpecExtension )
+    def dependenciesDeclaration = project.rootProject.extensions.getByType( DependenciesDeclarationExtension
)
     def srcDistFilesCopySpec = project.copySpec { CopySpec spec ->
       spec.from project.rootProject.projectDir
       spec.include '*.txt'
@@ -147,7 +149,7 @@ class DistributionsPlugin implements Plugin<Project>
       spec.exclude '**/.git*'                // Git files
       spec.exclude '**/build/**'             // Build output
       spec.exclude 'gradlew*'                // Gradle wrapper scripts
-      spec.exclude 'gradle/wrapper/*.jar'    // Gradle wrapper JAR
+      spec.exclude 'gradle/wrapper/**'       // Gradle wrapper
       spec.exclude '**/.gradle/**'           // Gradle caches
       spec.exclude '**/.gradletasknamecache' // Gradle shell completion cache
       spec.exclude '**/node_modules/**'      // Node's node_module dir
@@ -168,6 +170,7 @@ class DistributionsPlugin implements Plugin<Project>
     def srcDistSupplementaryFilesCopySpec = project.copySpec { CopySpec spec ->
       spec.from project.file( 'src/src-dist' )
       spec.into '.'
+      spec.filter { String line -> line.replaceAll( '%REQUIRED_GRADLE_VERSION%', dependenciesDeclaration.gradleVersion
) }
     }
     def srcDistFilteredFilesTask = project.tasks.create 'srcDistFilteredFiles'
     srcDistFilteredFilesTask.description = 'Apply release specification to source distribution
build scripts'
@@ -307,21 +310,29 @@ class DistributionsPlugin implements Plugin<Project>
     }
     project.tasks.create( TaskNames.BUILD_SOURCE_DIST, ExecLogged, { ExecLogged task ->
       task.group = TaskGroups.DISTRIBUTION_VERIFICATION
-      task.description = 'Checks the source distribution by running `gradle build` inside.'
+      task.description = 'Checks the source distribution by running `gradle check assemble`
inside.'
       task.dependsOn TaskNames.STAGE_SOURCE_DIST
       task.mustRunAfter TaskNames.RAT_SOURCE_DIST
       task.mustRunAfter TaskNames.INSPECT_SOURCE_DIST
       def workDir = project.file( "$project.buildDir/tmp/${ TaskNames.BUILD_SOURCE_DIST }"
)
       task.inputs.dir unpackedSrcDistDir
       task.workingDir = workDir
-      def gradlew = new File( project.rootDir, 'gradlew' ).absolutePath
+      def gradlew = new File( workDir, 'gradlew' ).absolutePath
       def settings = new File( workDir, 'settings.gradle' ).absolutePath
-      task.commandLine = [ gradlew, '-c', settings, 'build', '-u', '-s', /* '-g', workDir
*/ ]
+      task.commandLine = [ gradlew, '-c', settings, 'check', 'assemble', '-u', '-s', /* '-g',
workDir */ ]
       task.doFirst {
         project.copy { CopySpec spec ->
           spec.from unpackedSrcDistDir
           spec.into workDir
         }
+        def logName = "${ TaskNames.BUILD_SOURCE_DIST }_installWrapper"
+        def stdout = project.file( "${ project.buildDir }/log/$logName/$logName-stdout.log"
)
+        def stderr = project.file( "${ project.buildDir }/log/$logName/$logName-stderr.log"
)
+        def rootGradlew = new File( project.rootDir, 'gradlew' ).absolutePath
+        ExecLogged.execLogged( project, stdout, stderr, { ExecSpec spec ->
+          spec.workingDir = workDir
+          spec.commandLine = [ rootGradlew, '-i', '-s', '-b', 'gradle/wrapper-install/build.gradle',
'install' ]
+        } as Action )
       }
       task.doLast {
         if( workDir.exists() )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d5d753ff/distributions/src/src-dist/README.txt
----------------------------------------------------------------------
diff --git a/distributions/src/src-dist/README.txt b/distributions/src/src-dist/README.txt
index de6c218..2aa83ed 100644
--- a/distributions/src/src-dist/README.txt
+++ b/distributions/src/src-dist/README.txt
@@ -7,9 +7,9 @@ This Apache Polygene™ Source Distribution contains everything you need to
 create Polygene™ applications.
 
 
-Polygene™ started in 2007, and is still in heavy development under the umbrella of
-the Apache Polygene™ project at the Apache Software Foundation. We would like
-developers around the world to participate in the advancement of this
+Polygene™ started in 2007, and is still in heavy development under the umbrella
+of the Apache Polygene™ project at the Apache Software Foundation. We would
+like developers around the world to participate in the advancement of this
 cool, new and challenging technology. We are especially interested in
 people willing to help improve the SDK, samples, tutorials, documentation
 and other supporting material.
@@ -46,13 +46,12 @@ To build Polygene™ from sources you only need to have a valid Java JDK
>= 8
 installation and any version of Gradle.
 
 This distribution embeds the exact version of Gradle needed to build Polygene™.
-It is in the gradle/wrapper/gradle-wrapper.properties file.
 Here is how to bootstrap that version:
 
-    gradle wrapper
+    gradle -b gradle/wrapper-install/build.gradle install
 
-This will download the required Gradle distribution and create gradlew and
-gradlew.bat script files that you should use from now on.
+This will deploy the Gradle Wrapper and create gradlew and gradlew.bat script
+files that you should use from now on.
 
 Once you have the wrapper installed you can invoke the build system.
 
@@ -60,6 +59,9 @@ Here is how to run a full build with checks:
 
     ./gradlew check assemble
 
+Running gradlew for the first time will download the required Gradle
+distribution. You can run ./gradlew tasks to list available tasks.
+
 Read the Polygene™ Build System tutorial for more details:
 https://polygene.apache.org/java/latest/build-system.html
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d5d753ff/distributions/src/src-dist/gradle/wrapper-install/build.gradle
----------------------------------------------------------------------
diff --git a/distributions/src/src-dist/gradle/wrapper-install/build.gradle b/distributions/src/src-dist/gradle/wrapper-install/build.gradle
new file mode 100644
index 0000000..232ab00
--- /dev/null
+++ b/distributions/src/src-dist/gradle/wrapper-install/build.gradle
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+task install( type: Wrapper ) {
+  description = 'Installs the Gradle Wrapper in Apache Polygene™ source distribution.'
+  gradleVersion = '%REQUIRED_GRADLE_VERSION%'
+  def targetRoot = project.rootDir.parentFile.parentFile
+  jarFile = new File(targetRoot, 'gradle/wrapper/gradle-wrapper.jar')
+  scriptFile = new File(targetRoot, 'gradlew')
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d5d753ff/distributions/src/src-dist/gradle/wrapper-install/settings.gradle
----------------------------------------------------------------------
diff --git a/distributions/src/src-dist/gradle/wrapper-install/settings.gradle b/distributions/src/src-dist/gradle/wrapper-install/settings.gradle
new file mode 100644
index 0000000..a183ce3
--- /dev/null
+++ b/distributions/src/src-dist/gradle/wrapper-install/settings.gradle
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+// Gradle build root directory marker


Mime
View raw message