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

pkarwasz pushed a commit to branch feature/2.x/2929_remove_transitive_static
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit eb7f4e5693fa75c8ad5a60c790c56dc53b254b4e
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Sun Sep 8 10:58:36 2024 +0200

    Fail build for `static transitive` modules
---
 log4j-parent/pom.xml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/log4j-parent/pom.xml b/log4j-parent/pom.xml
index 65d6456746..dc9a4c993f 100644
--- a/log4j-parent/pom.xml
+++ b/log4j-parent/pom.xml
@@ -53,6 +53,7 @@
     <asciidoctor-maven-plugin.version>2.2.4</asciidoctor-maven-plugin.version>
     <docker-maven-plugin.version>0.45.0</docker-maven-plugin.version>
     <exam-maven-plugin.version>4.13.5</exam-maven-plugin.version>
+    <gmavenplus-plugin.version>3.0.2</gmavenplus-plugin.version>
     <maven-taglib-plugin.version>2.4</maven-taglib-plugin.version>
     <!-- `surefire.version` property used in `apache.org:apache`: -->
     <surefire.version>3.5.0</surefire.version>
@@ -995,6 +996,55 @@
         </executions>
       </plugin>
 
+      <plugin>
+        <groupId>org.codehaus.gmavenplus</groupId>
+        <artifactId>gmavenplus-plugin</artifactId>
+        <version>${gmavenplus-plugin.version}</version>
+        <configuration>
+          <continueExecuting>false</continueExecuting>
+          <scripts>
+            <script><![CDATA[
+              if ("jar" != project.packaging) {
+                  return;
+              }
+              String jarCommand = System.getProperty('java.home') + '/bin/jar';
+              String jarFile = project.build.directory + '/' + 
project.build.finalName + '.jar';
+              if (!new File(jarFile).exists()) {
+                  return;
+              }
+              String[] command = [jarCommand, '-d', '-f', jarFile];
+              Process process = command.execute();
+              process.waitFor();
+              if (process.exitValue() != 0) {
+                  throw new RuntimeException('Failed to decompile the module 
descriptor in ' + jarFile);
+              }
+              for (String line : process.text.split(System.lineSeparator(), 
-1)) {
+                  if (line.contains('static') && line.contains('transitive')) {
+                      throw new RuntimeException("The 'static' and 
'transitive' modifiers should not be use together: " + line);
+                  }
+              }
+          ]]></script>
+          </scripts>
+        </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+            <scope>runtime</scope>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <id>ban-static-transitive</id>
+            <goals>
+              <goal>execute</goal>
+            </goals>
+            <phase>verify</phase>
+          </execution>
+        </executions>
+      </plugin>
+
     </plugins>
   </build>
 

Reply via email to