]> source.dussan.org Git - aspectj.git/commitdiff
Prepare main artifacts to be deployed via Maven, step 1 41/head
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 26 Apr 2021 03:02:15 +0000 (10:02 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 26 Apr 2021 03:02:15 +0000 (10:02 +0700)
This change affects the following modules:
  - aspectjmatcher
  - aspectjrt
  - aspectjtools
  - aspectjweaver
  - installer

They have in common that they all use Maven Assembly Plugin in order to
create some kind of uber JARs with constituent modules and/or libraries.
Except for the installer, they are all available on Maven Central today,
but I think it would not hurt to deploy the installer to there, too.

Changes made:
  - Use Flatten Maven Plugin in order to create simple POMs with only
    basic information and - most importantly - without dependencies.
  - The new dependency-reduced POM (DRP) or "flattened POM" gets
    attached to the build, i.e. it will be installed and deployed as a
    replacement of the original POM.
  - Attaching the DRP only works for 'jar' type modules, which is why I
    changed the packaging type for each module from 'pom' to 'jar'.
  - Deactivate generation of the default JAR for each module. This is
    necessary now, since we have the 'jar' packaging type.
  - Make sure that assembly descriptors using 'dependencySet' entries
    have set option 'useProjectArtifact=false' in order to avoid
    warnings about the non-existing main artifact.

TODO:
  - Explore option to migrate from Maven Assembly to Maven Shade,
    because it does not need descriptor files, can also generate source
    JARs and can automatically create and attach a DRP which is less
    fragmentary than the one created by Flatten Maven, basically the
    original JAR minus the dependencies.
  - If in the future we want to make sure to only deploy the modules
    listed above, e.g. to Maven Central, if simply calling 'mvn deploy'
    for the whole project, we could use 'maven.deploy.skip=true' in the
    parent POM and override it by 'maven.deploy.skip=false' just in the
    few modules which need to be deployed. See also:
    https://stackoverflow.com/a/29574812/1082681
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
aspectjmatcher/pom.xml
aspectjrt/pom.xml
aspectjtools/aspectjtools-assembly.xml
aspectjtools/pom.xml
aspectjweaver/aspectjweaver-assembly.xml
aspectjweaver/pom.xml
installer/pom.xml
pom.xml

index b183bd3d60b53392f3bc5555df52b5feab70cfdb..c398420af4af87ad3a21e43dd415cce6fb106098 100644 (file)
        </parent>
 
        <artifactId>aspectjmatcher</artifactId>
-       <packaging>pom</packaging>
        <name>AspectJ Matcher</name>
 
        <build>
                <plugins>
 
-                       <!-- skip creation of test-jar in here -->
+                       <!-- Skip creation of main + test JARs -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <executions>
+                                       <execution>
+                                               <id>default-jar</id>
+                                               <phase>none</phase>
+                                       </execution>
                                        <execution>
                                                <id>test-jar</id>
                                                <phase>none</phase>
                                </executions>
                        </plugin>
 
+                       <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>flatten-maven-plugin</artifactId>
+                               <executions>
+                                       <!-- Remove dependencies declared in this POM (if any) from uber JAR and strip down POM -->
+                                       <execution>
+                                               <id>flatten</id>
+                                               <phase>process-resources</phase>
+                                               <goals>
+                                                       <goal>flatten</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <flattenMode>oss</flattenMode>
+                                                       <pomElements>
+                                                               <dependencies>remove</dependencies>
+                                                               <repositories>remove</repositories>
+                                                       </pomElements>
+                                                       <outputDirectory>${project.build.directory}</outputDirectory>
+                                                       <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
 </project>
index 930ba02ca6e6eafbad4036ce9c07b55728348051..5e41a1558774d32db5b61c7678b315bbfb88fb4a 100644 (file)
@@ -11,7 +11,6 @@
        </parent>
 
        <artifactId>aspectjrt</artifactId>
-       <packaging>pom</packaging>
        <name>AspectJ Runtime</name>
 
        <dependencies>
        <build>
                <plugins>
 
-                       <!-- skip creation of test-jar in here -->
+                       <!-- Skip creation of main + test JARs -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <executions>
+                                       <execution>
+                                               <id>default-jar</id>
+                                               <phase>none</phase>
+                                       </execution>
                                        <execution>
                                                <id>test-jar</id>
                                                <phase>none</phase>
                                </executions>
                        </plugin>
 
+                       <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>flatten-maven-plugin</artifactId>
+                               <executions>
+                                       <!-- Remove dependencies declared in this POM (if any) from uber JAR and strip down POM -->
+                                       <execution>
+                                               <id>flatten</id>
+                                               <phase>process-resources</phase>
+                                               <goals>
+                                                       <goal>flatten</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <flattenMode>oss</flattenMode>
+                                                       <pomElements>
+                                                               <dependencies>remove</dependencies>
+                                                               <repositories>remove</repositories>
+                                                       </pomElements>
+                                                       <outputDirectory>${project.build.directory}</outputDirectory>
+                                                       <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
 </project>
index fbf45c8085f68fb94fa9d26b0ee66587cf083e40..9a6777509949bca150081c5a3ebecc83e5279e66 100644 (file)
@@ -13,6 +13,8 @@
        <dependencySets>
                <dependencySet>
                        <unpack>true</unpack>
+                       <!-- Avoid warning when trying to add non-existing main artifact JAR -->
+                       <useProjectArtifact>false</useProjectArtifact>
                        <includes>
                                <include>org.aspectj:org.eclipse.jdt.core</include>
                                <include>org.aspectj:asm-renamed</include>
index 62cf15ebf18a13b6573b95964dc2b93df729b09a..7860f3a5a691531769bfe6de9f37f7e28bb3677c 100644 (file)
        </parent>
 
        <artifactId>aspectjtools</artifactId>
-       <packaging>pom</packaging>
        <name>AspectJ Compiler</name>
 
        <build>
                <plugins>
 
-                       <!-- skip creation of test-jar in here -->
+                       <!-- Skip creation of main + test JARs -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <executions>
+                                       <execution>
+                                               <id>default-jar</id>
+                                               <phase>none</phase>
+                                       </execution>
                                        <execution>
                                                <id>test-jar</id>
                                                <phase>none</phase>
                                </executions>
                        </plugin>
 
+                       <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>flatten-maven-plugin</artifactId>
+                               <executions>
+                                       <!-- Remove dependencies declared in this POM (if any) from uber JAR and strip down POM -->
+                                       <execution>
+                                               <id>flatten</id>
+                                               <phase>process-resources</phase>
+                                               <goals>
+                                                       <goal>flatten</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <flattenMode>oss</flattenMode>
+                                                       <pomElements>
+                                                               <dependencies>remove</dependencies>
+                                                               <repositories>remove</repositories>
+                                                       </pomElements>
+                                                       <outputDirectory>${project.build.directory}</outputDirectory>
+                                                       <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
 
index 4130c3c32d9547c1f48fb56eae1f7eb95ca8ec55..3325043167124898531502c81e99134f186691b5 100644 (file)
@@ -13,6 +13,8 @@
        <dependencySets>
                <dependencySet>
                        <unpack>true</unpack>
+                       <!-- Avoid warning when trying to add non-existing main artifact JAR -->
+                       <useProjectArtifact>false</useProjectArtifact>
                        <includes>
                                <include>org.aspectj:asm-renamed</include>
                        </includes>
index 3552ab630a5c8970bb3e0d4e6aaa09b8e89404aa..69952e3b4650f9a5bc3250f96353e2191b1fbac7 100644 (file)
        </parent>
 
        <artifactId>aspectjweaver</artifactId>
-       <packaging>pom</packaging>
        <name>AspectJ Weaver</name>
 
        <build>
                <plugins>
 
-                       <!-- skip creation of test-jar in here -->
+                       <!-- Skip creation of main + test JARs -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <executions>
+                                       <execution>
+                                               <id>default-jar</id>
+                                               <phase>none</phase>
+                                       </execution>
                                        <execution>
                                                <id>test-jar</id>
                                                <phase>none</phase>
                                </executions>
                        </plugin>
 
+                       <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>flatten-maven-plugin</artifactId>
+                               <executions>
+                                       <!-- Remove dependencies declared in this POM (if any) from uber JAR and strip down POM -->
+                                       <execution>
+                                               <id>flatten</id>
+                                               <phase>process-resources</phase>
+                                               <goals>
+                                                       <goal>flatten</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <flattenMode>oss</flattenMode>
+                                                       <pomElements>
+                                                               <dependencies>remove</dependencies>
+                                                               <repositories>remove</repositories>
+                                                       </pomElements>
+                                                       <outputDirectory>${project.build.directory}</outputDirectory>
+                                                       <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
 
index 977fa1d12a4a8a58087d2e4a6b8c0b1416fa6187..d8ada07d52657331c705b2a154f6d1aef554dcdb 100644 (file)
@@ -11,7 +11,6 @@
        </parent>
 
        <artifactId>installer</artifactId>
-       <packaging>pom</packaging>
        <name>AspectJ Installer</name>
 
        <dependencies>
 
        <build>
                <plugins>
-                       <!-- skip creation of test-jar in here -->
+
+                       <!-- Skip creation of main + test JARs -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <executions>
+                                       <execution>
+                                               <id>default-jar</id>
+                                               <phase>none</phase>
+                                       </execution>
                                        <execution>
                                                <id>test-jar</id>
                                                <phase>none</phase>
                                        </execution>
                                </executions>
                        </plugin>
+
+                       <!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>flatten-maven-plugin</artifactId>
+                               <executions>
+                                       <!-- Remove dependencies declared in this POM (if any) from uber JAR and strip down POM -->
+                                       <execution>
+                                               <id>flatten</id>
+                                               <phase>process-resources</phase>
+                                               <goals>
+                                                       <goal>flatten</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <flattenMode>oss</flattenMode>
+                                                       <pomElements>
+                                                               <dependencies>remove</dependencies>
+                                                               <repositories>remove</repositories>
+                                                       </pomElements>
+                                                       <outputDirectory>${project.build.directory}</outputDirectory>
+                                                       <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
 </project>
diff --git a/pom.xml b/pom.xml
index 61f8d90adc86d244ae04ce53bcf80960d18a632e..8f5a31b2a13a2b57a1399b13c144a02e3b9a748c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                                        <artifactId>maven-assembly-plugin</artifactId>
                                        <version>3.1.1</version>
                                </plugin>
+                               <plugin>
+                                       <groupId>org.codehaus.mojo</groupId>
+                                       <artifactId>flatten-maven-plugin</artifactId>
+                                       <version>1.2.2</version>
+                               </plugin>
                        </plugins>
                </pluginManagement>