Skip to content

Commit

Permalink
ZOOKEEPER-3786: Simplify version generation
Browse files Browse the repository at this point in the history
Simplify generation of VersionInfoMain.java and Info.java by using
maven-resource-plugin's built-in resource filtering at build time.

This eliminates the need to use VerGen to generate java source files
during the build.

Also make other slight pom improvements:
1. Remove trailing tab character in Ted's name in pom.xml
2. Simplify spotbugs skipping in contrib pom.xml
3. Add m2e configuration for build plugin executions to be ignored by
   Eclipse, for developers (like me) using Eclipse IDE
4. Format build time in a more international-friendly and less ambiguous
   way (year first, then month, then day, using UTC instead of GMT)

Link to issue: https://issues.apache.org/jira/browse/ZOOKEEPER-3786

Author: Christopher Tubbs <[email protected]>

Reviewers: Enrico Olivelli <[email protected]>, Mate Szalay-Beko <[email protected]>

Closes apache#1310 from ctubbsii/use-resource-filtering-for-version-info
  • Loading branch information
ctubbsii authored and RokLenarcic committed Aug 31, 2022
1 parent 51da75c commit 45e252b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 318 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<developers>
<developer>
<id>tdunning</id>
<name>Ted Dunning </name>
<name>Ted Dunning</name>
<email>[email protected]</email>
<timezone>-8</timezone>
</developer>
Expand Down
13 changes: 4 additions & 9 deletions zookeeper-contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@
</profile>
</profiles>

<properties>
<spotbugs.skip>true</spotbugs.skip>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.9</version>
<configuration>
<!-- No spotbugs for contrib modules -->
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
55 changes: 20 additions & 35 deletions zookeeper-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,29 @@

<build>
<plugins>
<plugin> <!-- ${maven.build.timestamp} does not support timezone :( -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<!-- ${maven.build.timestamp} does not support timezone :( -->
<id>tbuild-time</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>build.time</name>
<pattern>MM/dd/yyyy HH:mm zz</pattern>
<pattern>yyyy-MM-dd HH:mm zz</pattern>
<locale>en_US</locale>
<timeZone>GMT</timeZone>
<timeZone>UTC</timeZone>
</configuration>
</execution>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
<execution>
<phase>generate-sources</phase>
<goals>
Expand All @@ -197,44 +204,22 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>pre-compile-vergen</id>
<phase>generate-sources</phase>
<configuration>
<includes>
<include>org/apache/zookeeper/version/**/*.java</include>
</includes>
</configuration>
<id>prepare-filtered-java-source</id>
<goals>
<goal>compile</goal>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-version-info</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${project.basedir}/src/main/java/</workingDirectory>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>org.apache.zookeeper.version.util.VerGen</argument>
<argument>${project.version}</argument>
<argument>${mvngit.commit.id}</argument>
<argument>${build.time}</argument>
<argument>${project.basedir}/target/generated-sources/java</argument>
</arguments>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
<resources>
<resource>
<directory>src/main/java-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.apache.zookeeper.version;

public interface Info {
int MAJOR=${parsedVersion.majorVersion};
int MINOR=${parsedVersion.minorVersion};
int MICRO=${parsedVersion.incrementalVersion};
String QUALIFIER="${parsedVersion.qualifier}".isEmpty() ? null : "${parsedVersion.qualifier}";
int REVISION=-1; //@deprecated, please use REVISION_HASH
String REVISION_HASH="${mvngit.commit.id}";
String BUILD_DATE="${build.time}";
}
Original file line number Diff line number Diff line change
@@ -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.
*/

package org.apache.zookeeper.version;

public class VersionInfoMain implements org.apache.zookeeper.version.Info {
public static void main(String[] args) {
System.out.println("Apache ZooKeeper, version ${project.version} ${build.time}");
}
}

This file was deleted.

Loading

0 comments on commit 45e252b

Please sign in to comment.