'generated sources of other modules
I have a multi-module maven project. I use maven build helper plugin to automatically add generated sources to the classpath.
I am able to use the generated sources of module-X in module-X, however, when I add module-X as a dependency to module-Y, the generated sources of module-X are not visible because they are not included in the X.jar file.
Is there a way to include the generated sources in the jar file or force maven to generate sources of dependencies?
Solution 1:[1]
You can explicitly specify that the generated classes should be part of the output jar file:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<includes>
<include>generatedClassesFolderPath</include>
</includes>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
Replace the generatedClassesFolderPath
with the relative path of the folder where the generated classes are.
More info:
Solution 2:[2]
I had the same question and I solve it as follows:
Add an application class under package such as src/main/java/com.....
in your module-X
and add a @SpringBootApplication
annotation. In addition to this, the application class can be no content.
Make sure module-X
in module-Y
dependencies and restart `module-Y.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Konstantin Yovkov |
Solution 2 | Tyler2P |