You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by cc...@apache.org on 2017/12/17 14:02:05 UTC

[54/62] [abbrv] groovy git commit: Avoid copying unprocessed release-info file into jar (then overwriting)

Avoid copying unprocessed release-info file into jar (then overwriting)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5abfec71
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5abfec71
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5abfec71

Branch: refs/heads/GROOVY_2_6_X
Commit: 5abfec710bda06f43876a7ad1ba52e4ce3743dda
Parents: 9edb31f
Author: Cedric Champeau <cc...@apache.org>
Authored: Thu Dec 14 12:41:00 2017 +0100
Committer: Cedric Champeau <cc...@apache.org>
Committed: Sun Dec 17 14:51:50 2017 +0100

----------------------------------------------------------------------
 build.gradle                                    | 12 ++-
 .../groovy/gradle/ReleaseInfoGenerator.groovy   | 78 ++++++++++++++++++++
 gradle/assemble.gradle                          |  7 +-
 gradle/docs.gradle                              |  4 +-
 gradle/filter.gradle                            | 33 ---------
 .../META-INF/groovy-release-info.properties     | 23 ------
 6 files changed, 91 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 4b96673..c24073e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+import org.codehaus.groovy.gradle.ReleaseInfoGenerator
 
 buildscript {
     repositories {
@@ -69,6 +70,7 @@ buildScanRecipes {
 ext.modules = {
     subprojects.findAll{ !['performance', 'tests-vm8'].contains(it.name) }
 }
+ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
 
 apply from: 'gradle/filter.gradle'
 apply from: 'gradle/indy.gradle'
@@ -97,6 +99,15 @@ allprojects {
         maven { url 'http://dl.bintray.com/melix/thirdparty-apache' } // openbeans
     }
 
+    ext.buildDate = isReleaseVersion?new Date():new Date(0)
+
+    task generateReleaseInfo(type: ReleaseInfoGenerator) {
+        version = rootProject.groovyVersion
+        bundleVersion = rootProject.groovyBundleVersion
+        buildDate = rootProject.buildDate
+        outputFile = file("$buildDir/release-info/groovy-release-info.properties")
+    }
+
     apply plugin: 'groovy'
     apply from: "${rootProject.projectDir}/gradle/indy.gradle"
     if (JavaVersion.current().java7Compatible) {
@@ -169,7 +180,6 @@ ext {
     spockVersion = '1.2-groovy-2.4-SNAPSHOT'
     antlr4Version = '4.7'
     jsr305Version = '3.0.2'
-    isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
 }
 
 dependencies {

http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
new file mode 100644
index 0000000..b29193c
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
@@ -0,0 +1,78 @@
+/*
+ *  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.
+ */
+package org.codehaus.groovy.gradle
+
+import groovy.transform.CompileStatic
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputFile
+
+import java.text.SimpleDateFormat
+
+@CompileStatic
+class ReleaseInfoGenerator extends DefaultTask {
+    String description = "Generates the release info properties file"
+
+    @Input
+    String version
+
+    @Input
+    String bundleVersion
+
+    @Input
+    Date buildDate
+
+    @OutputFile
+    File outputFile
+
+    @TaskAction
+    void generateDescriptor() {
+        String date = new SimpleDateFormat('dd-MMM-yyyy').format(buildDate)
+        String time = new SimpleDateFormat('hh:mm aa').format(buildDate)
+
+        outputFile.withWriter('utf-8') {
+            it.write("""#
+#  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.
+#
+
+ImplementationVersion=$version
+BundleVersion=$bundleVersion
+BuildDate=$date
+BuildTime=$time
+""")
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/gradle/assemble.gradle
----------------------------------------------------------------------
diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle
index d60fab4..706953f 100644
--- a/gradle/assemble.gradle
+++ b/gradle/assemble.gradle
@@ -166,9 +166,7 @@ allprojects {
                 include('antlr4-license.txt')
             }
             from("$projectDir/notices/NOTICE-JARJAR")
-            from('src/resources/META-INF/groovy-release-info.properties') {
-                filter(rootProject.propertiesFilter, org.apache.tools.ant.filters.ReplaceTokens)
-            }
+            from(generateReleaseInfo)
             rename { String filename -> filename == 'LICENSE-JARJAR' ? 'LICENSE' : filename == 'NOTICE-JARJAR' ? 'NOTICE' : filename }
         }
         arch.exclude '**/package-info.class'
@@ -317,9 +315,6 @@ subprojects { sp ->
             } else {
                 from "${rootProject.projectDir}/notices/NOTICE-BASE"
             }
-            from("${rootProject.projectDir}/src/resources/META-INF/groovy-release-info.properties") {
-                filter(rootProject.propertiesFilter, org.apache.tools.ant.filters.ReplaceTokens)
-            }
             rename { String filename -> filename == 'LICENSE-BASE' ? 'LICENSE' : filename == 'NOTICE-BASE' ? 'NOTICE' : filename }
         }
         exclude '**/package-info.class'

http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/gradle/docs.gradle
----------------------------------------------------------------------
diff --git a/gradle/docs.gradle b/gradle/docs.gradle
index d10b9d5..483bb23 100644
--- a/gradle/docs.gradle
+++ b/gradle/docs.gradle
@@ -113,9 +113,7 @@ groovydocAll groovydocSpec
 task docProjectVersionInfo(type: Copy) {
     destinationDir = file("${project(':groovy-docgenerator').sourceSets.main.java.outputDir}")
     into('META-INF') {
-        from('src/resources/META-INF/groovy-release-info.properties') {
-            filter(rootProject.propertiesFilter, org.apache.tools.ant.filters.ReplaceTokens)
-        }
+        from(generateReleaseInfo)
     }
     from('subprojects/groovy-docgenerator/src/main/resources')
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/gradle/filter.gradle
----------------------------------------------------------------------
diff --git a/gradle/filter.gradle b/gradle/filter.gradle
deleted file mode 100644
index 4a5575b..0000000
--- a/gradle/filter.gradle
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *  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.
- */
-import java.text.SimpleDateFormat
-
-// do not use a timestamp during development, to avoid unnecessary rebuilds and cache misses
-ext.buildTime = rootProject.groovyVersion.endsWith('SNAPSHOT')?new Date(0):new Date()
-
-ext.propertiesFilter = [
-        beginToken: '#',
-        endToken: '#',
-        tokens: [
-                ImplementationVersion: rootProject.groovyVersion,
-                BundleVersion: rootProject.groovyBundleVersion,
-                BuildDate: new SimpleDateFormat('dd-MMM-yyyy').format(rootProject.buildTime),
-                BuildTime: new SimpleDateFormat('hh:mm aa').format(rootProject.buildTime)
-        ]
-]

http://git-wip-us.apache.org/repos/asf/groovy/blob/5abfec71/src/resources/META-INF/groovy-release-info.properties
----------------------------------------------------------------------
diff --git a/src/resources/META-INF/groovy-release-info.properties b/src/resources/META-INF/groovy-release-info.properties
deleted file mode 100644
index d33358c..0000000
--- a/src/resources/META-INF/groovy-release-info.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-#  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.
-#
-
-ImplementationVersion=#ImplementationVersion#
-BundleVersion=#BundleVersion#
-BuildDate=#BuildDate#
-BuildTime=#BuildTime#
\ No newline at end of file