|
87 | 87 | <asciidoctor-maven-plugin.version>2.2.4</asciidoctor-maven-plugin.version> |
88 | 88 | <docker-maven-plugin.version>0.43.4</docker-maven-plugin.version> |
89 | 89 | <exam-maven-plugin.version>4.13.5</exam-maven-plugin.version> |
| 90 | + <gmavenplus-plugin.version>3.0.2</gmavenplus-plugin.version> |
90 | 91 | <!-- `surefire.version` property used in `apache.org:apache`: --> |
91 | 92 | <surefire.version>3.5.0</surefire.version> |
92 | 93 |
|
|
805 | 806 | </executions> |
806 | 807 | </plugin> |
807 | 808 |
|
| 809 | + <plugin> |
| 810 | + <groupId>org.codehaus.gmavenplus</groupId> |
| 811 | + <artifactId>gmavenplus-plugin</artifactId> |
| 812 | + <version>${gmavenplus-plugin.version}</version> |
| 813 | + <dependencies> |
| 814 | + <dependency> |
| 815 | + <groupId>org.apache.groovy</groupId> |
| 816 | + <artifactId>groovy-ant</artifactId> |
| 817 | + <version>${groovy.version}</version> |
| 818 | + <scope>runtime</scope> |
| 819 | + </dependency> |
| 820 | + <dependency> |
| 821 | + <groupId>org.apache.groovy</groupId> |
| 822 | + <artifactId>groovy</artifactId> |
| 823 | + <version>${groovy.version}</version> |
| 824 | + <scope>runtime</scope> |
| 825 | + </dependency> |
| 826 | + </dependencies> |
| 827 | + <executions> |
| 828 | + <execution> |
| 829 | + <id>ban-static-transitive</id> |
| 830 | + <goals> |
| 831 | + <goal>execute</goal> |
| 832 | + </goals> |
| 833 | + <phase>verify</phase> |
| 834 | + <configuration> |
| 835 | + <continueExecuting>false</continueExecuting> |
| 836 | + <scripts> |
| 837 | + <script><![CDATA[ |
| 838 | + import java.io.StringWriter |
| 839 | + import java.util.spi.ToolProvider |
| 840 | +
|
| 841 | + if ("jar" != project.packaging) { |
| 842 | + log.info("Skipping module descriptor check, since the project type is not `jar`.") |
| 843 | + return |
| 844 | + } |
| 845 | + String jarFile = project.build.directory + "/" + project.build.finalName + ".jar"; |
| 846 | + if (!new File(jarFile).exists()) { |
| 847 | + log.info("Skipping module descriptor check, since `" + jarFile + "` is missing.") |
| 848 | + return |
| 849 | + } |
| 850 | + StringWriter out = new StringWriter() |
| 851 | + StringWriter err = new StringWriter() |
| 852 | + ToolProvider jar = ToolProvider.findFirst("jar").orElseThrow() |
| 853 | + int result = jar.run(new PrintWriter(out), new PrintWriter(err), "-d", "-f", jarFile) |
| 854 | + if (result != 0) { |
| 855 | + throw new RuntimeException("Failed to decompile the module descriptor in `" + jarFile + "`:\n" + err) |
| 856 | + } |
| 857 | + log.debug("Module descriptor: " + out) |
| 858 | + for (String line : out.toString().split("\r?\n", -1)) { |
| 859 | + if (line.contains("static") && line.contains("transitive")) { |
| 860 | + throw new RuntimeException("The `static` and `transitive` modifiers should not be use together: " + line) |
| 861 | + } |
| 862 | + } |
| 863 | + log.info("Successfully verified module descriptor in `" + jarFile + "`.") |
| 864 | + ]]></script> |
| 865 | + </scripts> |
| 866 | + </configuration> |
| 867 | + </execution> |
| 868 | + </executions> |
| 869 | + </plugin> |
| 870 | + |
808 | 871 | </plugins> |
809 | 872 | </build> |
810 | 873 |
|
|
0 commit comments