1

Sorry if the question was already answered, I didn't understand the other threads.

I have a springboot project that have maven dependency on 2 java projects packaged as jboss-sar on our repository.

The problem is that when I put the dependency in the pom, it doesn't download the sources and my project doesn't compile because of many NoClassFound errors.

My solution was to use maven-shade-plugin to build a uber-jar from the 2 SAR projects.

In the pom I have the dependencies to the 2 SAR projects

then

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <!--filters>
                            <artifact>*.*</artifact>
                            <includes>
                                <include>**/*.class</include>
                            </includes>
                        </filters-->
                        <artifactSet>
                            <includes>
                                <include>${project.groupId}}:${project.artifactId}</include>
                            </includes>
                        </artifactSet>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/sarl</resource>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Old : [ The problem now is that, if I use the phase initialize, the main artifact is not built so the uber-jar failed to build. If I use the phase package, my project doesn't compile because of missing dependencies.

Is there a way to first build the uber-jar and then build the whole project? ]

UPDATE : I found an error in my pom so I can update my post. Currently if I do a mvn clean install I encounter no problem, the project compile. But then if I run my SpringBoot application it fails to launch because of ClassNotFound exceptions. All the classes that are in the project jboss-sar, are not found by Spring. Only maven manages to compile my project, even Intellij draws me redlines everywhere the classes are used because it doesn't find the classes in the classpath. How can I use this maven shade plugin to have actually the classes of the jboss-sar in my classpath?

3
  • Why it doesn't download the sources ? The sources are not downloaded by default because the jar's are the parts which are required... Commented Feb 5, 2024 at 18:03
  • Hello, there is no jars, only sars. When you put dependency on a sar in your pom the classes are not imported in the project. You end up with many errors NoClassFoundException. Commented Feb 7, 2024 at 7:45
  • The same for sars... sources package are something different... -sources...... Commented Feb 7, 2024 at 10:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.