You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/05/15 10:31:59 UTC

[plc4x] branch develop updated: - Moved the groovy code for generating the artificial version properties into a groovy-file - Added code to generate a pom.adoc file containinng all of maven's properties in an adoc format - Removed now obsolete pom stuff that was already commented out

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 34e1177  - Moved the groovy code for generating the artificial version properties into a groovy-file - Added code to generate a pom.adoc file containinng all of maven's properties in an adoc format - Removed now obsolete pom stuff that was already commented out
34e1177 is described below

commit 34e1177c5d674b3f9301922f6dd30c6bd9ddbce3
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri May 15 12:31:39 2020 +0200

    - Moved the groovy code for generating the artificial version properties into a groovy-file
    - Added code to generate a pom.adoc file containinng all of maven's properties in an adoc format
    - Removed now obsolete pom stuff that was already commented out
---
 pom.xml                                           | 100 ++--------------------
 src/main/script/preSiteGeneration.groovy          |  71 +++++++++++++++
 src/site/asciidoc/developers/release/release.adoc |   2 -
 3 files changed, 77 insertions(+), 96 deletions(-)

diff --git a/pom.xml b/pom.xml
index e2b8ee5..3bd1595 100644
--- a/pom.xml
+++ b/pom.xml
@@ -806,7 +806,10 @@
               <source>${project.basedir}/src/main/script/prerequisiteCheck.groovy</source>
             </configuration>
           </execution>
-          <!-- Set some dynamic variables which are useful for the site generation -->
+          <!--
+            Set some dynamic variables which are useful for the site generation and
+            generate an 'pom.adoc' file containing them in a format asciidoc can use.
+          -->
           <execution>
             <id>provide-custom-properties</id>
             <phase>pre-site</phase>
@@ -814,49 +817,7 @@
               <goal>execute</goal>
             </goals>
             <configuration>
-              <source>import org.apache.maven.repository.internal.MavenRepositorySystemUtils
-
-              print "\nCalculating some additional properties:"
-              // Get the current year
-              def currentYear = Calendar.getInstance().get(Calendar.YEAR) as String
-              print "\nCurrent year:                     " + currentYear
-              project.properties['current-year'] = currentYear
-
-              // Calculate some version related stuff
-              def currentVersion = project.version as String
-              def match = (currentVersion =~ /(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)
-              print "\nCurrent version:                  " + currentVersion
-              if (match.count &gt;= 1) {
-                def majorVersion = match[0][1] as Integer
-                def minorVersion = match[0][2] as Integer
-                def bugfixVersion = match[0][3] as Integer
-
-                def currentFullVersion = majorVersion + "." + minorVersion + "." + bugfixVersion
-                def currentShortVersion = majorVersion + "." + minorVersion
-                def currentNextIncrementalVersion = majorVersion + "." + minorVersion + "." + (bugfixVersion + 1)
-                def currentNextMinorVersion = majorVersion + "." + (minorVersion + 1) + ".0"
-
-                print "\nCurrent full version:             " + currentFullVersion + " (current-full-version)"
-                project.properties['current-full-version'] = currentFullVersion
-                print "\nCurrent short version:            " + currentShortVersion + "   (current-short-version)"
-                project.properties['current-short-version'] = currentShortVersion
-                print "\nCurrent next incremental version: " + currentNextIncrementalVersion + " (current-next-incremental-version)"
-                project.properties['current-next-incremental-version'] = currentNextIncrementalVersion
-                print "\nCurrent next minor version:       " + currentNextMinorVersion + " (current-next-minor-version)"
-                project.properties['current-next-minor-version'] = currentNextMinorVersion
-              }
-
-              // Get the latest released version from our doap file.
-              def plc4xDoapFile = new File(project.getBasedir(), "src/site/resources-filtered/plc4x-doap.rdf")
-              if (plc4xDoapFile.exists()) {
-                def doapDocument = new XmlSlurper().parse(plc4xDoapFile)
-                def lastReleasedVersion = doapDocument.Project.release[0].Version.revision
-                print "\nCurrent last released version:    " + lastReleasedVersion + " (current-last-released-version)"
-                project.properties['current-last-released-version'] = lastReleasedVersion
-              }
-
-              print "\n"
-              </source>
+              <source>${project.basedir}/src/main/script/preSiteGeneration.groovy</source>
             </configuration>
           </execution>
         </executions>
@@ -869,23 +830,6 @@
         </dependencies>
       </plugin>
 
-      <!-- Write all the properties into a file so we can access them from asciidoctor -->
-      <!--plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>properties-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <phase>pre-site</phase>
-            <goals>
-              <goal>write-project-properties</goal>
-            </goals>
-            <configuration>
-              <outputFile>${project.build.directory}/pom.adoc</outputFile>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin-->
-
       <!-- Check if all source files have the required apache license headers -->
       <plugin>
         <groupId>org.apache.rat</groupId>
@@ -1041,38 +985,6 @@
       </plugin>
 
       <!--
-        Convert the pom.adoc file from a java property file into an asciidoctor property file.
-      -->
-      <!--plugin>
-        <groupId>com.google.code.maven-replacer-plugin</groupId>
-        <artifactId>replacer</artifactId>
-        <executions>
-          <execution>
-            <id>convert-property-to-adoc</id>
-            <!- Only execute this for the parent module ->
-            <inherited>false</inherited>
-            <phase>pre-site</phase>
-            <goals>
-              <goal>replace</goal>
-            </goals>
-            <configuration>
-              <file>${project.build.directory}/pom.adoc</file>
-              <replacements>
-                <replacement>
-                  <token>(.*)=(.*)</token>
-                  <value>\:$1\: $2</value>
-                </replacement>
-                <replacement>
-                  <token>#(.*)</token>
-                  <value>// $1</value>
-                </replacement>
-              </replacements>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin-->
-
-      <!--
         Make the maven-site-plugin stage the output in the "asf-site" branch
       -->
       <plugin>
@@ -1281,7 +1193,7 @@
               <attributes>
                 <source-highlighter>prettify</source-highlighter>
                 <imagesoutdir>${project.build.directory}/site/images</imagesoutdir>
-                <!--pom-adoc>${project.build.directory}/pom.adoc</pom-adoc-->
+                <pom-adoc>${project.build.directory}/pom.adoc</pom-adoc>
               </attributes>
               <requires>
                 <require>asciidoctor-diagram</require>
diff --git a/src/main/script/preSiteGeneration.groovy b/src/main/script/preSiteGeneration.groovy
new file mode 100644
index 0000000..d40da48
--- /dev/null
+++ b/src/main/script/preSiteGeneration.groovy
@@ -0,0 +1,71 @@
+/*
+ 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 org.apache.maven.repository.internal.MavenRepositorySystemUtils
+
+print "\nCalculating some additional properties:"
+// Get the current year
+def currentYear = Calendar.getInstance().get(Calendar.YEAR) as String
+print "\nCurrent year:                     " + currentYear
+project.properties['current-year'] = currentYear
+
+// Calculate some version related stuff
+def currentVersion = project.version as String
+def match = (currentVersion =~ /(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)
+print "\nCurrent version:                  " + currentVersion
+if (match.count >= 1) {
+    def majorVersion = match[0][1] as Integer
+    def minorVersion = match[0][2] as Integer
+    def bugfixVersion = match[0][3] as Integer
+
+    def currentFullVersion = majorVersion + "." + minorVersion + "." + bugfixVersion
+    def currentShortVersion = majorVersion + "." + minorVersion
+    def currentNextIncrementalVersion = majorVersion + "." + minorVersion + "." + (bugfixVersion + 1)
+    def currentNextMinorVersion = majorVersion + "." + (minorVersion + 1) + ".0"
+
+    print "\nCurrent full version:             " + currentFullVersion + " (current-full-version)"
+    project.properties['current-full-version'] = currentFullVersion
+    print "\nCurrent short version:            " + currentShortVersion + "   (current-short-version)"
+    project.properties['current-short-version'] = currentShortVersion
+    print "\nCurrent next incremental version: " + currentNextIncrementalVersion + " (current-next-incremental-version)"
+    project.properties['current-next-incremental-version'] = currentNextIncrementalVersion
+    print "\nCurrent next minor version:       " + currentNextMinorVersion + " (current-next-minor-version)"
+    project.properties['current-next-minor-version'] = currentNextMinorVersion
+}
+
+// Get the latest released version from our doap file.
+def plc4xDoapFile = new File(project.getBasedir(), "src/site/resources-filtered/plc4x-doap.rdf")
+if (plc4xDoapFile.exists()) {
+    def doapDocument = new XmlSlurper().parse(plc4xDoapFile)
+    def lastReleasedVersion = doapDocument.Project.release[0].Version.revision
+    print "\nCurrent last released version:    " + lastReleasedVersion + " (current-last-released-version)"
+    project.properties['current-last-released-version'] = lastReleasedVersion
+}
+print "\n"
+
+// Dump all maven properties into a file readable by asciidoc.
+print "\nGenerating 'pom.adoc' file in target directory (Use in adoc by including 'include::{pom-adoc} ... however this should not be required)'\n\n"
+def propertyFile = new File(project.getBasedir(), "target/pom.adoc")
+// Ensure the parent directory is created
+propertyFile.getParentFile().mkdirs()
+// Make sure the file is deleted so we don't append to an existing file
+propertyFile.delete()
+// Iterate over all properties and dump them to the file
+project.properties.each { entry -> propertyFile << ":$entry.key: $entry.value\n" }
+
diff --git a/src/site/asciidoc/developers/release/release.adoc b/src/site/asciidoc/developers/release/release.adoc
index f08b54a..0b0990c 100644
--- a/src/site/asciidoc/developers/release/release.adoc
+++ b/src/site/asciidoc/developers/release/release.adoc
@@ -66,8 +66,6 @@ This helps reviewers to see what's in the convenience maven package and to relea
 
 But in order to be allowed to upload artifacts, your account has to be enabled for this and you have to tell Maven about your credentials.
 
-:current-full-version:
-
 In order to do this, you should provide these credentials via `.m2/settings.xml`.
 
 So if you don't already have one, you should create a `.m2` directory in your user home and inside that create a `settings.xml` file with at least this content: