I had to revive an old project that worked about a year and a half ago, but now when I do:
mvn clean install
either on the command line or via eclipse, it compiles fine but does not add the main-class in the manifest AND I do have the proper directive.
I'm using:
So here is the abbreviated version of the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.a.b.c</groupId>
<artifactId>JarNameHere</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<log4j.version>2.4</log4j.version>
<http.client.version>4.5.2</http.client.version>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>
<dependencies>
<!-- DEPENDENCIES HERE, BUT REMOVED TO MAKE MORE READABLE -->
...
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>com.a.b.c.MainClass</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- AspectJ configuration -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>1.11</complianceLevel>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- -->
</plugins>
</pluginManagement>
</build>
</project>
I have no doubt that the answer given by @kriegaex would work pre-Java 9, as my old pom.xml was working for years on Java 8. It turns out I didn't give enough info in my question to properly answer this. It was my upgrade from Java 8 to Java 10 that messed up the AspectJ Integration, so it would fail before Maven got to the creation of the jar.
Note: I will continue to refine this as it may be better to use the pluginManagement tag. Unfortunately, I don't modify the pom.xml that often other than dependency tags which are easy. So I get good for a short period working through hard things only to never touch/make major changes for years forgetting all I learned the previous time through.
I found the solution here: Maven AspectJ plugin fails to build with Java 9 due to missing tools.jar
THE ACTUAL SOLUTION: Changing a few lines in my pom.xml did the trick:
<groupId>com.github.m50d</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11.1</version>
<!--
THESE WERE THE ORIGINAL LINES
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
-->
I figured this out doing this on the command line:
mvn -X clean install
Even the latest version of AspectJ was still looking for the tools.jar file:
<properties>
<!-- Other lines removed for brevity -->
<aspect.version>1.9.1</aspect.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.machinepublishers/jbrowserdriver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspect.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspect.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspect.version}</version>
</dependency>
<!-- OTHER DEPENDENCIES REMOVED FOR BREVITY -->
</dependencies>
<build>
<plugins>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>a.b.c.Foo</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
<!-- AspectJ configuration -->
<plugin>
<groupId>com.github.m50d</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11.1</version>
<!--
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
-->
<configuration>
<!-- MUST use 10, NOT 1.10 or ajc breaks -->
<complianceLevel>10</complianceLevel>
<source>10</source>
<target>10</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
<!-- -->
</plugins>
</build>