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 2019/05/23 11:19:23 UTC

[plc4x] 01/05: PLC4X-126 - Make the asciidoctor generated site reference the dynamic properties

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

commit 434c590d9a4f33eab8b172c39023023e71b375ce
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu May 23 13:17:19 2019 +0200

    PLC4X-126 - Make the asciidoctor generated site reference the dynamic properties
    
    - Found a way to make all properties (including dynamic ones) available in Asciidoctor
    - Updated the pom to generate a set of version properties
    - Updated the release documentation to use the new properties
    - Updated the website documentation on how to use the properties
---
 pom.xml                                   |  63 ++++++++++++----
 src/site/asciidoc/developers/release.adoc | 120 +++++++++++++++++-------------
 src/site/asciidoc/developers/website.adoc |  21 ++++++
 3 files changed, 140 insertions(+), 64 deletions(-)

diff --git a/pom.xml b/pom.xml
index de575c8..399350c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,6 +153,9 @@
     <thrift.version>0.12.0</thrift.version>
 
     <!-- Site properties -->
+    <asciidoctor.maven.plugin.version>2.0.0-RC.1</asciidoctor.maven.plugin.version>
+    <asciidoctorj.version>2.0.0</asciidoctorj.version>
+    <asciidoctorj.diagram.version>1.5.16</asciidoctorj.diagram.version>
     <reflow.skin.version>1.5.0</reflow.skin.version>
     <bootstrap.version>3.3.7</bootstrap.version>
     <jquery.version>3.3.1</jquery.version>
@@ -709,6 +712,24 @@
         </executions>
       </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>
+        <version>1.0.0</version>
+        <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>
@@ -941,6 +962,28 @@
               </replacements>
             </configuration>
           </execution>
+          <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>
 
@@ -1053,12 +1096,7 @@
               <attributes>
                 <source-highlighter>prettify</source-highlighter>
                 <imagesoutdir>${project.build.directory}/site/images</imagesoutdir>
-                <project-version>${project.version}</project-version>
-                <current-year>@{current-year}</current-year>
-                <current-full-version>@{current-full-version}</current-full-version>
-                <current-short-version>@{current-short-version}</current-short-version>
-                <current-next-incremental-version>@{current-next-incremental-version}</current-next-incremental-version>
-                <current-next-minor-version>@{current-next-minor-version}</current-next-minor-version>
+                <pom-adoc>${project.build.directory}/pom.adoc</pom-adoc>
               </attributes>
               <requires>
                 <require>asciidoctor-diagram</require>
@@ -1072,6 +1110,7 @@
               <artifactId>reflow-velocity-tools</artifactId>
               <version>${reflow.skin.version}</version>
             </dependency>
+
             <!-- add support for scm/git site deployment -->
             <dependency>
               <groupId>org.apache.maven.wagon</groupId>
@@ -1093,26 +1132,22 @@
               <artifactId>maven-scm-provider-gitexe</artifactId>
               <version>1.9.5</version>
             </dependency>
+
             <!-- Add support for asciidoctor -->
             <dependency>
               <groupId>org.asciidoctor</groupId>
               <artifactId>asciidoctor-maven-plugin</artifactId>
-              <version>1.5.7.1</version>
-            </dependency>
-            <dependency>
-              <groupId>org.jruby</groupId>
-              <artifactId>jruby-complete</artifactId>
-              <version>9.1.13.0</version>
+              <version>${asciidoctor.maven.plugin.version}</version>
             </dependency>
             <dependency>
               <groupId>org.asciidoctor</groupId>
               <artifactId>asciidoctorj</artifactId>
-              <version>1.5.6</version>
+              <version>${asciidoctorj.version}</version>
             </dependency>
             <dependency>
               <groupId>org.asciidoctor</groupId>
               <artifactId>asciidoctorj-diagram</artifactId>
-              <version>1.5.4.1</version>
+              <version>${asciidoctorj.diagram.version}</version>
             </dependency>
           </dependencies>
         </plugin>
diff --git a/src/site/asciidoc/developers/release.adoc b/src/site/asciidoc/developers/release.adoc
index 778eab0..a3cd167 100644
--- a/src/site/asciidoc/developers/release.adoc
+++ b/src/site/asciidoc/developers/release.adoc
@@ -14,6 +14,7 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
+include::{pom-adoc}[]
 :imagesdir: ../images/
 :icons: font
 
@@ -28,6 +29,8 @@ 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:
@@ -90,7 +93,7 @@ According to SemVer, we have: Major, Minor and Bugfix releases.
 
 For each new Major and Minor release we create a new branch at the beginning of a code-freeze phase.
 
-So if currently the project version in develop is `0.5.0-SNAPSHOT`, we create a branch `rel/0.5`.
+So if currently the project version in develop is `{current-full-version}-SNAPSHOT`, we create a branch `rel/{current-short-version}`.
 
 When creating the branch is exactly the moment in which the version in `develop` is incremented to the next minor version.
 
@@ -107,17 +110,23 @@ Otherwise we would have to define the working copy version for each module.
 Per default the plugin suggests the next bugfix version as working version, however we want it to use the next minor version.
 So in case of preparing the release branch for `0.5.0-SNAPSHOT` the command would be the following:
 
-   mvn release:branch -P with-cpp,with-dotnet,with-java,with-proxies,with-python,with-sandbox -DbranchName=rel/0.5 -DautoVersionSubmodules=true
+[subs="verbatim,attributes"]
+----
+   mvn release:branch -P with-cpp,with-dotnet,with-java,with-proxies,with-python,with-sandbox -DbranchName=rel/{current-short-version} -DautoVersionSubmodules=true
+----
 
 The plugin will then aks for the version:
 
-   What is the new working copy version for "PLC4X"? (org.apache.plc4x:plc4x-parent) 0.5.1-SNAPSHOT: : 0.6.0-SNAPSHOT
+[subs="verbatim,attributes"]
+----
+   What is the new working copy version for "PLC4X"? (org.apache.plc4x:plc4x-parent) {current-next-incremental-version}-SNAPSHOT: : {current-next-minor-version}-SNAPSHOT
+----
 
 Where the suggested default is manually overridden.
 
 This step now should perform quite quickly as no build and no tests are involved.
 
-However in the end the versions of the `develop` branch are updated and a new `rel/0.4` branch is created.
+However in the end the versions of the `develop` branch are updated and a new `rel/{current-short-version}` branch is created.
 
 === Preparing `develop` for the next iteration
 
@@ -125,9 +134,10 @@ Now is a good time to add a new section to the `RELEASE_NOTES` document for the
 
 Here comes a template:
 
-```
+[subs="verbatim,attributes"]
+----
 ==============================================================
-(Unreleased) Apache PLC4X 0.X.0-SNAPSHOT
+(Unreleased) Apache PLC4X {current-next-minor-version}-SNAPSHOT
 ==============================================================
 
 New Features
@@ -141,7 +151,7 @@ Bug Fixes
 
 // Rest of the file
 
-```
+----
 
 Also be sure to do a quick full-text-search to check if the version was updated correctly everywhere.
 
@@ -169,8 +179,8 @@ After that, the following command will to all preparation steps for the release:
 In general the plugin will now ask you 3 questions:
 
 1. The version we want to release as (It will suggest the version you get by omitting the `-SNAPSHOT` suffix)
-2. The name of the tag the release commit will be tagged with in the SCM (Name it `release/{release-version}`
-3. The next development version (The version present in the pom after the release)
+2. The name of the tag the release commit will be tagged with in the SCM (Name it `release/{release-version}` (`release/{current-full-version}` in our case)
+3. The next development version (The version present in the pom after the release) (`{current-next-minor-version}` in our case)
 
 Usually for 1 and 3 the defaults are just fine, make sure the tag name is correct as this usually is different.
 
@@ -187,7 +197,7 @@ What the plugin now does, is automatically execute the following operations:
 1. Check we aren't referencing any `SNAPSHOT` dependencies.
 2. Update all pom versions to the release version.
 3. Run a build with all tests
-4. Commit the changes (commit message: `[maven-release-plugin] prepare release {tagname}`)
+4. Commit the changes (commit message: `[maven-release-plugin] prepare release release/{current-full-version}`)
 5. Push the commit
 6. Tag the commit
 7. Update all poms to the next development version.
@@ -201,7 +211,7 @@ is in the correct state. Please select the release branch and verify the commit
 
 image::release-git-history.png[]
 
-It is important that the commit with the message "[maven-release-plugin] prepare release XXX" is tagged with the release tag (in this case release/0.3.0)
+It is important that the commit with the message "[maven-release-plugin] prepare release release/{current-full-version}" is tagged with the release tag (in this case release/0.3.0)
 
 If you check the commit itself, it should mainly consist of version updates like this:
 
@@ -274,14 +284,17 @@ https://dist.apache.org/repos/dist/dev/plc4x/
 
 The directory structure of this directory is as follows:
 
+[subs="verbatim,attributes"]
+----
    ./KEYS
-   ./0.4.0/
-   ./0.4.0/rc1
-   ./0.4.0/rc1/README
-   ./0.4.0/rc1/RELEASE_NOTES
-   ./0.4.0/rc1/apache-plc4x-0.1.0-source-release.zip
-   ./0.4.0/rc1/apache-plc4x-0.1.0-source-release.zip.asc
-   ./0.4.0/rc1/apache-plc4x-0.1.0-source-release.zip.sha512
+   ./{current-full-version}/
+   ./{current-full-version}/rc1
+   ./{current-full-version}/rc1/README
+   ./{current-full-version}/rc1/RELEASE_NOTES
+   ./{current-full-version}/rc1/apache-plc4x-{current-full-version}-source-release.zip
+   ./{current-full-version}/rc1/apache-plc4x-{current-full-version}-source-release.zip.asc
+   ./{current-full-version}/rc1/apache-plc4x-{current-full-version}-source-release.zip.sha512
+----
 
 The `KEYS` file contains the PGP public key which belongs to the private key used to sign the release artifacts.
 
@@ -303,20 +316,21 @@ After staging the release candidate in the Apache SVN, it is time to actually ca
 For this we usually send two emails.
 The following would be the one used to do our first TLP release:
 
-```
+[subs="verbatim,attributes"]
+----
    E-Mail Topic:
-   [VOTE] Apache PLC4X 0.4.0 RC1
+   [VOTE] Apache PLC4X {current-full-version} RC1
 
    Message:
-   Apache PLC4X 0.4.0 has been staged under [2] and it’s time to vote
+   Apache PLC4X {current-full-version} has been staged under [2] and it’s time to vote
    on accepting it for release. All Maven artifacts are available under [1].
    Voting will be open for 72hr.
 
    A minimum of 3 binding +1 votes and more binding +1 than binding -1
    are required to pass.
 
-   Release tag: release/0.4.0
-   Hash for the release tag: 8c1e0c1b85ce15814f2c08e0eec5d593951d168d
+   Release tag: release/{current-full-version}
+   Hash for the release tag: {replacethiswiththerealgitcommittag}
 
    Per [3] "Before voting +1 PMC members are required to download
    the signed source code package, compile it as provided, and test
@@ -330,18 +344,19 @@ The following would be the one used to do our first TLP release:
    [ ]  -1 reject (explanation required)
 
 
-   [1] https://repository.apache.org/content/repositories/orgapacheplc4x-1010
-   [2] https://dist.apache.org/repos/dist/dev/plc4x/0.4.0/rc1
+   [1] https://repository.apache.org/content/repositories/orgapacheplc4x-{somefourdigitnumber}
+   [2] https://dist.apache.org/repos/dist/dev/plc4x/{current-full-version}/rc1
    [3] https://www.apache.org/dev/release.html#approving-a-release
    [4] https://cwiki.apache.org/confluence/display/PLC4X/Validating+a+staged+Release
-```
+----
 
 As it is sometimes to do the vote counting, if voting and discussions are going on in the same thread, we send a second email:
 
 
-```
+[subs="verbatim,attributes"]
+----
    E-Mail Topic:
-   [DISCUSS] Apache PLC4X 0.4.0 RC1
+   [DISCUSS] Apache PLC4X {current-full-version} RC1
 
    Message:
    This is the discussion thread for the corresponding VOTE thread.
@@ -349,7 +364,7 @@ As it is sometimes to do the vote counting, if voting and discussions are going
    Please keep discussions in this thread to simplify the counting of votes.
 
    If you have to vote -1 please mention a brief description on why and then take the details to this thread.
-```
+----
 
 Now we have to wait 72 hours till we can announce the result of the vote.
 
@@ -359,25 +374,28 @@ The vote passes, if at least 3 `+1` votes are received and more `+1` are receive
 
 After the 72 hour minimum wait period is over and we have fulfilled the requirement of at least 3 +1 votes and more +1 than -1, a final reply is sent to the vote thread with a prefix of `[RESULT]` in the title in which the summary of the vote is presented in an aggregated form.
 
-```
+[subs="verbatim,attributes"]
+----
     E-Mail Topic:
-    [RESULT] [DISCUSS] Apache PLC4X 0.1.0 RC1
+    [RESULT] [DISCUSS] Apache PLC4X {current-full-version} RC1
 
     Message:
     So, the vote passes with 3 +1 votes by PMC members and one +1 vote by a non PMC member.
 
     Chris
-
-```
+----
 
 === Releasing after a successful vote
 
 As soon as the votes are finished and the results were in favor of a release, the staged artifacts can be released.
 This is done by moving them inside the Apache SVN.
 
-   svn move -m "Release Apache PLC4X 0.4.0" \
-       https://dist.apache.org/repos/dist/dev/plc4x/0.4.0/rc1 \
-       https://dist.apache.org/repos/dist/release/plc4x/0.4.0
+[subs="verbatim,attributes"]
+----
+   svn move -m "Release Apache PLC4X {current-full-version}" \
+       https://dist.apache.org/repos/dist/dev/plc4x/{current-full-version}/rc1 \
+       https://dist.apache.org/repos/dist/release/plc4x/{current-full-version}
+----
 
 This will make the release artifacts available and will trigger them being copied to mirror sites.
 
@@ -408,15 +426,18 @@ All release artifacts released to the Apache release repo, will automatically be
 The master branch should always point to the last released version.
 This has to be done with git
 
-```
+[subs="verbatim,attributes"]
+----
 git checkout master
-git merge {tag-of-release}
-```
+git merge release/{current-full-version}
+----
 
 When there are conflicts it could help to use the "theirs" merge strategy, i.e.,
-```
-git merge -X theirs {tag-of-release}
-```
+
+[subs="verbatim,attributes"]
+----
+git merge -X theirs release/{current-full-version}
+----
 
 Possibly a manual conflict resolution has to be done afterwards. After that, changes need to
 be pushed.
@@ -433,7 +454,7 @@ has to be listed there.
 This is done by changing the `download.adoc` under `src/site/users/` (**in the develop branch, as this is where the site is generated from!**)
 
 1. Copy the last release down to _Previous Releases_
-2. Point the download links of the last release to archive, e.g. `http://archive.apache.org/dist/plc4x/0.3.0/apache-plc4x-0.3.0-source-release.zip`
+2. Point the download links of the last release to archive, e.g. `http://archive.apache.org/dist/plc4x/{current-full-version}/apache-plc4x-{current-full-version}-source-release.zip`
 3. Add the new Release under _Current Releases_ and change all links.
 _Note: Please add an anchor for the toc_
 4. Update the sections for the changes according to the _RELEASE_NOTES_ from the release
@@ -446,7 +467,8 @@ Make sure you have given the Apache mirrors time to fetch the release files by w
 
 After that it is time to announce your release to the world:
 
-```
+[subs="verbatim,attributes"]
+----
     From:
 your apache email address
     To:
@@ -456,12 +478,10 @@ announce@apache.org
 dev@plc4x.apache.org
 
     E-Mail Topic:
-[ANNOUNCE] Apache PLC4X 0.5.0 released
+[ANNOUNCE] Apache PLC4X {current-full-version} released
 
     Message:
-The Apache PLC4X team is pleased to announce the release of Apache PLC4X 0.5.0
-
-This is the first official release of PLC4X.
+The Apache PLC4X team is pleased to announce the release of Apache PLC4X {current-full-version}
 
 PLC4X is a set of libraries for communicating with industrial programmable
 logic controllers (PLCs) using a variety of protocols but with a shared API.
@@ -487,14 +507,14 @@ The Apache PLC4X team
 
 [1] http://plc4x.apache.org
 [2] http://plc4x.apache.org/users/download.html
+----
 
-```
 It is important to note that you have to send this email from your apache email address or it will be rejected.
 This wasn't very simple for me to setup.
 A general description can be found here:
 https://reference.apache.org/committer/email
 Here's what I did in google mail to allow sending of emails:
 https://gmail.googleblog.com/2009/07/send-mail-from-another-address-without.html
-Note ... you will be able to select the alternat sending address if you click into the recipients line of a new email (Not very intuitive).
+Note ... you will be able to select the alternate sending address if you click into the recipients line of a new email (Not very intuitive).
 
 After that email is out the door, you're done. Congrats!
\ No newline at end of file
diff --git a/src/site/asciidoc/developers/website.adoc b/src/site/asciidoc/developers/website.adoc
index 5f2d667..a73a4fe 100644
--- a/src/site/asciidoc/developers/website.adoc
+++ b/src/site/asciidoc/developers/website.adoc
@@ -175,3 +175,24 @@ Only on these machines are jobs allowed to push changes to a Git repo and here o
 See https://builds.apache.org/view/M-R/job/PLC4X/job/PLC4X%20Site/ for details on the PLC4X Jenkins Website build job.
 
 As soon as content is updated in the `asf-site` the `gitpubsub` mechanism will make those changes available at https://plc4x.apache.org
+
+== Bells and Whistles
+
+=== Making all pom properties available to asciidoctor
+
+While trying to automate keeping the content of the release documentation up-to-date, we added a groovy script to automatically calculate some version numbers.
+Unfortunately it wasn't possible to use these in asciidoctor using the normal `attributes` as the values aren't set as soon as Maven configures the plugin.
+
+We came up with an option to still achieve this:
+
+* The `groovy-maven-plugin` sets the dynamic properties in the `provide-custom-properties` execution.
+* Then we use the `properties-maven-plugin` to write all maven properties into a property file `target/pom.adoc`.
+* As Asciidoctor doesn't understand property files, we use the `replacer` to convert the content into an Asciidoctor property file in the `convert-property-to-adoc` execution.
+* Now we provide access to the location of this file by setting the `pom-adoc` attribute.
+* If we now need to access the properties, all we need to do, is to import the `pom.adoc` file with the following statement:
+
+   include::{pom-adoc}[]
+
+* After this all maven properties can be accessed via:
+
+   We are currently working on releasing ApachePLC4X {current-full-version}