I have build a Maven-project-tree consisting of a top pom-project (named MyElectricity) and two subsequent jar-projects.
The project is meant to grow, so I split it to one (named MyElectricity-Common) holding the common classes and bindings (created with jaxb/jakarta) and one holding the logic (named MyElectricity-aWattar). It is meant to run as a standalone-jar, so alle needed artifacts/modules have to become packaged to a single jar, when installing the “MyElectricity-aWattar”.
The project has several dependencies. Some self created artifacts and several others from public sources (e.g. SpringBoot, MyBatis etc). As far as I can see all of them are resolved and packed to the jar created by the install-process. All – but “MyElectricity-aWattar”.
And I do not see why this one is missing.
Any guess or help is appreciated!
The top project is defined by this pom:
<groupId>de.gombers.electricity</groupId>
<artifactId>MyElectricity</artifactId>
<packaging>pom</packaging>
<properties>
<revision>1.0.0</revision>
</properties>
<parent>
<groupId>de.gombers.myhome</groupId>
<artifactId>MyHome</artifactId>
<version>1.0.0</version>
</parent>
<modules>
<module>MyElectricity-aWattar</module>
<module>MyElectricity-Common</module>
</modules>
The “MyElectricity-Common” definitions are defined by this pom:
<artifactId>MyElectricity-Common</artifactId>
<parent>
<groupId>de.gombers.electricity</groupId>
<artifactId>MyElectricity</artifactId>
<version>1.0.0</version>
</parent>
<build>
<finalName>Common</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<clearOutputDir>true</clearOutputDir>
<extension>true</extension>
<sources>
<!-- only xsd files under here -->
<source>src/main/xsd</source>
</sources>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${version.maven.org.glassfish.jaxb}</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>${version.maven.jakarta.activation.api}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${version.maven.jakarta.xml.bind-api}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${version.maven.jaxb-impl}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
The “MyElectricity-aWattar” definitions are defined by this pom:
<artifactId>MyElectricity-aWattar</artifactId>
<parent>
<groupId>de.gombers.electricity</groupId>
<artifactId>MyElectricity</artifactId>
<version>1.0.0</version>
</parent>
<build>
<finalName>aWattar</finalName>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>de.gombers.electricity.awattar.MainDataGatherer</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>de.gombers.electricity</groupId>
<artifactId>MyElectricity-Common</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
Java-Version: is 17
IDE: is Eclipse of 2024-09
Maven: Apache Maven 3.9.9
3
The problem was:
-
As already said in my comments, I made a mistake, when telling, the “MyElectricity-Common” was not included to the package of “MyElectricity-aWattar“. I had searched at the wrong place in the list of modules in the /lib. I had not realized the different sort order due to the uppercase name od the artifact. But I still do not understand why Eclipse did the install, while maven didn’t – and Maven is correct.
-
The “MyElectricity-Common“-install did not put the generated classes to the root of the created JAR. So they could not be found and running the programs failed with missing classes. I solved this with adding the term
<spring-boot.repackage.skip>true</spring-boot.repackage.skip> to the properties.
This avoids failing the repackaging, which does not work for modules without main-classes
see also Execution Repackaging: Unable to repackage goal : main class not found