This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch drop-storm-buildtools-check in repository https://gitbox.apache.org/repos/asf/storm.git
commit 39bb4278341eee26e31088037bf04e6b27b849ff Author: Richard Zowalla <[email protected]> AuthorDate: Tue Apr 28 11:31:10 2026 +0200 build: replace storm-maven-plugins with git-commit-id-maven-plugin The custom version-info Mojo in storm-buildtools/storm-maven-plugins only populated SCM commit/branch/uri, build time and a source MD5 used to filter storm-{client,core}-version-info.properties at build time. All of that is covered by io.github.git-commit-id:git-commit-id-maven-plugin (commit, branch) plus the plugin's own build timestamp, so the bespoke module is no longer needed. - Drop storm-buildtools/ tree (storm-maven-plugins module + leftover empty maven-shade-clojure-transformer dir from the Clojure removal). - Remove the storm-buildtools/storm-maven-plugins module from the root pom. - Manage git-commit-id-maven-plugin 9.0.1 in the parent pluginManagement. - Wire it into storm-client and storm-core in the initialize phase. - Update version-info templates to reference git.commit.id, git.branch and git.build.time. Drop srcChecksum from the templates (runtime VersionInfo already returns "Unknown" when the property is absent, preserving the IVersionInfo API and REST cluster-summary shape). --- pom.xml | 6 +- storm-buildtools/storm-maven-plugins/pom.xml | 84 ------ .../storm/maven/plugin/util/CommandExec.java | 83 ------ .../maven/plugin/versioninfo/VersionInfoMojo.java | 316 --------------------- storm-client/pom.xml | 25 +- .../resources/storm-client-version-info.properties | 9 +- storm-core/pom.xml | 25 +- .../resources/storm-core-version-info.properties | 9 +- 8 files changed, 35 insertions(+), 522 deletions(-) diff --git a/pom.xml b/pom.xml index 56a863aa3..729b86171 100644 --- a/pom.xml +++ b/pom.xml @@ -171,7 +171,6 @@ <module>storm-multilang/javascript</module> <module>storm-multilang/python</module> <module>storm-multilang/ruby</module> - <module>storm-buildtools/storm-maven-plugins</module> <module>storm-client</module> <module>storm-server</module> <module>storm-core</module> @@ -1372,6 +1371,11 @@ <artifactId>exec-maven-plugin</artifactId> <version>3.6.3</version> </plugin> + <plugin> + <groupId>io.github.git-commit-id</groupId> + <artifactId>git-commit-id-maven-plugin</artifactId> + <version>9.0.1</version> + </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>license-maven-plugin</artifactId> diff --git a/storm-buildtools/storm-maven-plugins/pom.xml b/storm-buildtools/storm-maven-plugins/pom.xml deleted file mode 100644 index 3f2fa8869..000000000 --- a/storm-buildtools/storm-maven-plugins/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <artifactId>storm</artifactId> - <groupId>org.apache.storm</groupId> - <version>3.0.0-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <artifactId>storm-maven-plugins</artifactId> - <packaging>maven-plugin</packaging> - <name>storm-maven-plugins</name> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.dependency.version>3.8.1</maven.dependency.version> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-api</artifactId> - <version>${maven.dependency.version}</version> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - <version>${maven.dependency.version}</version> - </dependency> - <dependency> - <groupId>org.apache.maven.plugin-tools</groupId> - <artifactId>maven-plugin-annotations</artifactId> - <version>${maven.dependency.version}</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-plugin-plugin</artifactId> - <version>${maven.dependency.version}</version> - <configuration> - <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> - </configuration> - <executions> - <execution> - <id>mojo-descriptor</id> - <goals> - <goal>descriptor</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - <!--Note - the version would be inherited--> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> diff --git a/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/util/CommandExec.java b/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/util/CommandExec.java deleted file mode 100644 index 031bf74a7..000000000 --- a/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/util/CommandExec.java +++ /dev/null @@ -1,83 +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. - */ - -package org.apache.storm.maven.plugin.util; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import org.apache.maven.plugin.Mojo; - -public class CommandExec { - private Mojo mojo; - - public CommandExec(Mojo mojo) { - this.mojo = mojo; - } - - public int run(List<String> command, List<String> output) { - int retCode = 1; - ProcessBuilder pb = new ProcessBuilder(command); - try { - Process p = pb.start(); - OutputBufferThread stdOut = new OutputBufferThread(p.getInputStream()); - OutputBufferThread stdErr = new OutputBufferThread(p.getErrorStream()); - stdOut.start(); - stdErr.start(); - retCode = p.waitFor(); - if (retCode != 0) { - mojo.getLog().warn(command + " failed with error code " + retCode); - for (String s : stdErr.getOutput()) { - mojo.getLog().debug(s); - } - } - stdOut.join(); - stdErr.join(); - output.addAll(stdOut.getOutput()); - } catch (Exception ex) { - mojo.getLog().warn(command + " failed: " + ex.toString()); - } - return retCode; - } - - private static class OutputBufferThread extends Thread { - private List<String> output; - private BufferedReader reader; - - OutputBufferThread(InputStream is) { - this.setDaemon(true); - output = new ArrayList<String>(); - reader = new BufferedReader(new InputStreamReader(is)); - } - - @Override - public void run() { - try { - String line = reader.readLine(); - while (line != null) { - output.add(line); - line = reader.readLine(); - } - } catch (IOException ex) { - throw new RuntimeException("make failed with error code " - + ex.toString()); - } - } - - public List<String> getOutput() { - return output; - } - } -} diff --git a/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/versioninfo/VersionInfoMojo.java b/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/versioninfo/VersionInfoMojo.java deleted file mode 100644 index 1cbefeb9c..000000000 --- a/storm-buildtools/storm-maven-plugins/src/main/java/org/apache/storm/maven/plugin/versioninfo/VersionInfoMojo.java +++ /dev/null @@ -1,316 +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. - */ - -package org.apache.storm.maven.plugin.versioninfo; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; -import org.apache.maven.model.FileSet; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.apache.storm.maven.plugin.util.CommandExec; -import org.codehaus.plexus.util.FileUtils; - -@Mojo(name = "version-info") -public class VersionInfoMojo extends AbstractMojo { - - @Parameter(defaultValue = "${project}") - private MavenProject project; - - @Parameter(required = true) - private FileSet source; - - @Parameter(defaultValue = "version-info.build.time") - private String buildTimeProperty; - - @Parameter(defaultValue = "version-info.source.md5") - private String md5Property; - - @Parameter(defaultValue = "version-info.scm.uri") - private String scmUriProperty; - - @Parameter(defaultValue = "version-info.scm.branch") - private String scmBranchProperty; - - @Parameter(defaultValue = "version-info.scm.commit") - private String scmCommitProperty; - - @Parameter(defaultValue = "git") - private String gitCommand; - - @Parameter(defaultValue = "svn") - private String svnCommand; - private List<String> scmOut; - - @SuppressWarnings("rawtypes") - private static String getCommaSeparatedList(List list) { - StringBuilder buffer = new StringBuilder(); - String separator = ""; - for (Object e : list) { - buffer.append(separator).append(e); - separator = ","; - } - return buffer.toString(); - } - - @SuppressWarnings("unchecked") - public static List<File> convertFileSetToFiles(FileSet source) - throws IOException { - String includes = getCommaSeparatedList(source.getIncludes()); - String excludes = getCommaSeparatedList(source.getExcludes()); - return FileUtils.getFiles(new File(source.getDirectory()), includes, - excludes); - } - - @Override - public void execute() throws MojoExecutionException { - try { - SCM scm = determineScm(); - project.getProperties().setProperty(buildTimeProperty, getBuildTime()); - project.getProperties().setProperty(scmUriProperty, getSCMUri(scm)); - project.getProperties().setProperty(scmBranchProperty, getSCMBranch(scm)); - project.getProperties().setProperty(scmCommitProperty, getSCMCommit(scm)); - project.getProperties().setProperty(md5Property, computeMD5()); - } catch (Throwable ex) { - throw new MojoExecutionException(ex.toString(), ex); - } - } - - private String getBuildTime() { - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - return dateFormat.format(new Date()); - } - - /** - * Determines which SCM is in use (Subversion, git, or none) and captures - * output of the SCM command for later parsing. - * - * @return SCM in use for this build - * @throws Exception if any error occurs attempting to determine SCM - */ - private SCM determineScm() throws Exception { - CommandExec exec = new CommandExec(this); - SCM scm = SCM.NONE; - scmOut = new ArrayList<String>(); - int ret = exec.run(Arrays.asList(svnCommand, "info"), scmOut); - if (ret == 0) { - scm = SCM.SVN; - } else { - ret = exec.run(Arrays.asList(gitCommand, "branch"), scmOut); - if (ret == 0) { - ret = exec.run(Arrays.asList(gitCommand, "remote", "-v"), scmOut); - if (ret != 0) { - scm = SCM.NONE; - scmOut = null; - } else { - ret = exec.run(Arrays.asList(gitCommand, "log", "-n", "1"), scmOut); - if (ret != 0) { - scm = SCM.NONE; - scmOut = null; - } else { - scm = SCM.GIT; - } - } - } - } - if (scmOut != null) { - getLog().debug(scmOut.toString()); - } - getLog().info("SCM: " + scm); - return scm; - } - - private String[] getSvnUriInfo(String str) { - String[] res = new String[]{ "Unknown", "Unknown" }; - try { - String path = str; - int index = path.indexOf("trunk"); - if (index > -1) { - res[0] = path.substring(0, index - 1); - res[1] = "trunk"; - } else { - index = path.indexOf("branches"); - if (index > -1) { - res[0] = path.substring(0, index - 1); - int branchIndex = index + "branches".length() + 1; - index = path.indexOf("/", branchIndex); - if (index > -1) { - res[1] = path.substring(branchIndex, index); - } else { - res[1] = path.substring(branchIndex); - } - } - } - } catch (Exception ex) { - getLog().warn("Could not determine URI & branch from SVN URI: " + str); - } - return res; - } - - @SuppressWarnings("checkstyle:AbbreviationAsWordInName") - private String getSCMUri(SCM scm) { - String uri = "Unknown"; - switch (scm) { - case SVN: - for (String s : scmOut) { - if (s.startsWith("URL:")) { - uri = s.substring(4).trim(); - uri = getSvnUriInfo(uri)[0]; - break; - } - } - break; - case GIT: - for (String s : scmOut) { - if (s.startsWith("origin") && s.endsWith("(fetch)")) { - uri = s.substring("origin".length()); - uri = uri.substring(0, uri.length() - "(fetch)".length()); - break; - } - } - break; - case NONE: - break; - default: - throw new IllegalArgumentException(String.format("SCM %s is not supported", - scm)); - } - return uri.trim(); - } - - @SuppressWarnings("checkstyle:AbbreviationAsWordInName") - private String getSCMCommit(SCM scm) { - String commit = "Unknown"; - switch (scm) { - case SVN: - for (String s : scmOut) { - if (s.startsWith("Revision:")) { - commit = s.substring("Revision:".length()); - break; - } - } - break; - case GIT: - for (String s : scmOut) { - if (s.startsWith("commit")) { - commit = s.substring("commit".length()); - break; - } - } - break; - case NONE: - break; - default: - throw new IllegalArgumentException(String.format("SCM %s is not supported", - scm)); - } - return commit.trim(); - } - - @SuppressWarnings("checkstyle:AbbreviationAsWordInName") - private String getSCMBranch(SCM scm) { - String branch = "Unknown"; - switch (scm) { - case SVN: - for (String s : scmOut) { - if (s.startsWith("URL:")) { - branch = s.substring(4).trim(); - branch = getSvnUriInfo(branch)[1]; - break; - } - } - break; - case GIT: - for (String s : scmOut) { - if (s.startsWith("*")) { - branch = s.substring("*".length()); - break; - } - } - break; - case NONE: - break; - default: - throw new IllegalArgumentException(String.format("SCM %s is not supported", - scm)); - } - return branch.trim(); - } - - private byte[] readFile(File file) throws IOException { - RandomAccessFile raf = new RandomAccessFile(file, "r"); - byte[] buffer = new byte[(int) raf.length()]; - raf.readFully(buffer); - raf.close(); - return buffer; - } - - private byte[] computeMD5(List<File> files) throws IOException, - NoSuchAlgorithmException { - MessageDigest md5 = MessageDigest.getInstance("MD5"); - for (File file : files) { - getLog().debug("Computing MD5 for: " + file); - md5.update(readFile(file)); - } - return md5.digest(); - } - - private String computeMD5() throws Exception { - List<File> files = convertFileSetToFiles(source); - // File order of MD5 calculation is significant. Sorting is done on - // unix-format names, case-folded, in order to get a platform-independent - // sort and calculate the same MD5 on all platforms. - Collections.sort(files, new Comparator<File>() { - @Override - public int compare(File lhs, File rhs) { - return normalizePath(lhs).compareTo(normalizePath(rhs)); - } - - private String normalizePath(File file) { - return file.getPath().toUpperCase().replaceAll("\\\\", "/"); - } - }); - byte[] md5 = computeMD5(files); - String md5str = byteArrayToString(md5); - getLog().info("Computed MD5: " + md5str); - return md5str; - } - - private String byteArrayToString(byte[] array) { - StringBuilder sb = new StringBuilder(); - for (byte b : array) { - sb.append(Integer.toHexString(0xff & b)); - } - return sb.toString(); - } - - @SuppressWarnings("checkstyle:AbbreviationAsWordInName") - private enum SCM { - NONE, SVN, GIT - } -} diff --git a/storm-client/pom.xml b/storm-client/pom.xml index b8e7ccf37..a3e421119 100644 --- a/storm-client/pom.xml +++ b/storm-client/pom.xml @@ -309,26 +309,23 @@ </executions> </plugin> <plugin> - <groupId>org.apache.storm</groupId> - <artifactId>storm-maven-plugins</artifactId> - <version>${project.version}</version> + <groupId>io.github.git-commit-id</groupId> + <artifactId>git-commit-id-maven-plugin</artifactId> <executions> <execution> - <id>version-info</id> - <phase>generate-resources</phase> + <id>get-the-git-infos</id> + <phase>initialize</phase> <goals> - <goal>version-info</goal> + <goal>revision</goal> </goals> - <configuration> - <source> - <directory>${basedir}/src/</directory> - <includes> - <include>jvm/**/*.java</include> - </includes> - </source> - </configuration> </execution> </executions> + <configuration> + <dateFormat>yyyy-MM-dd'T'HH:mm'Z'</dateFormat> + <dateFormatTimeZone>UTC</dateFormatTimeZone> + <failOnNoGitDirectory>false</failOnNoGitDirectory> + <generateGitPropertiesFile>false</generateGitPropertiesFile> + </configuration> </plugin> </plugins> </build> diff --git a/storm-client/src/resources/storm-client-version-info.properties b/storm-client/src/resources/storm-client-version-info.properties index b92dfcef6..89db9e2d2 100644 --- a/storm-client/src/resources/storm-client-version-info.properties +++ b/storm-client/src/resources/storm-client-version-info.properties @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -version=${pom.version} -revision=${version-info.scm.commit} -branch=${version-info.scm.branch} -date=${version-info.build.time} -srcChecksum=${version-info.source.md5} +version=${project.version} +revision=${git.commit.id} +branch=${git.branch} +date=${git.build.time} diff --git a/storm-core/pom.xml b/storm-core/pom.xml index 860c19a58..961d04f5e 100644 --- a/storm-core/pom.xml +++ b/storm-core/pom.xml @@ -257,26 +257,23 @@ </configuration> </plugin> <plugin> - <groupId>org.apache.storm</groupId> - <artifactId>storm-maven-plugins</artifactId> - <version>${project.version}</version> + <groupId>io.github.git-commit-id</groupId> + <artifactId>git-commit-id-maven-plugin</artifactId> <executions> <execution> - <id>version-info</id> - <phase>generate-resources</phase> + <id>get-the-git-infos</id> + <phase>initialize</phase> <goals> - <goal>version-info</goal> + <goal>revision</goal> </goals> - <configuration> - <source> - <directory>${basedir}/src/</directory> - <includes> - <include>jvm/**/*.java</include> - </includes> - </source> - </configuration> </execution> </executions> + <configuration> + <dateFormat>yyyy-MM-dd'T'HH:mm'Z'</dateFormat> + <dateFormatTimeZone>UTC</dateFormatTimeZone> + <failOnNoGitDirectory>false</failOnNoGitDirectory> + <generateGitPropertiesFile>false</generateGitPropertiesFile> + </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/storm-core/src/resources/storm-core-version-info.properties b/storm-core/src/resources/storm-core-version-info.properties index b92dfcef6..89db9e2d2 100644 --- a/storm-core/src/resources/storm-core-version-info.properties +++ b/storm-core/src/resources/storm-core-version-info.properties @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -version=${pom.version} -revision=${version-info.scm.commit} -branch=${version-info.scm.branch} -date=${version-info.build.time} -srcChecksum=${version-info.source.md5} +version=${project.version} +revision=${git.commit.id} +branch=${git.branch} +date=${git.build.time}
