groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cchamp...@apache.org
Subject [54/62] [abbrv] groovy git commit: Avoid copying unprocessed release-info file into jar (then overwriting)
Date Sun, 17 Dec 2017 15:05:16 GMT
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/52942545
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/52942545
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/52942545

Branch: refs/heads/GROOVY_2_5_X
Commit: 52942545918cd61738b2a3b1ce0262e7f65b2ff6
Parents: 401c749
Author: Cedric Champeau <cchampeau@apache.org>
Authored: Thu Dec 14 12:41:00 2017 +0100
Committer: Cedric Champeau <cchampeau@apache.org>
Committed: Sun Dec 17 15:36:27 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/52942545/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 12c3dba..4fda6b5 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 {
@@ -66,6 +67,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'
@@ -94,6 +96,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) {
@@ -166,7 +177,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/52942545/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/52942545/gradle/assemble.gradle
----------------------------------------------------------------------
diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle
index 24171e4..7005b71 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/52942545/gradle/docs.gradle
----------------------------------------------------------------------
diff --git a/gradle/docs.gradle b/gradle/docs.gradle
index 03dfe64..2d7e698 100644
--- a/gradle/docs.gradle
+++ b/gradle/docs.gradle
@@ -112,9 +112,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/52942545/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/52942545/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 7eae8ae..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


Mime
View raw message