0

I created a common jar with below dependency -

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

While running, this is creating 2 jars one is main application jar and the 2nd one is the attached-source jar, Is there any way so that i can combine the source jar and it will build a single jar which should consist the source inside it also.

Umair Mubeen
  • 823
  • 4
  • 22
Suman
  • 131
  • 1
  • 2
  • 7
  • 2
    While I'm sure there's a way (assembly plugin?) - this question sounds _very_ unusual. We always want to separate sources from compiled binaries. What's the reason for this in your situation? – Stanislav Bashkyrtsev Jul 21 '20 at 17:20
  • IDEs like Eclipse expect a `sources` jar. Then they can find the source code automatically. What should be the advantage of bundling the sources into the main jar? – J Fabian Meier Jul 21 '20 at 17:20
  • Wanted to add the main jar to nexus repository, so if the source jar is different then that also i have to upload over there and have to use both the dependency for main and source jar to download in local. – Suman Jul 21 '20 at 17:34
  • The usual way is to have a separate jar file which contains the classes which you can consume and a so called sources jar which looks like `xyz-VERSION-sources.jar` which IDE's etc. can correctly handle (Configured in the IDE to download them). In your pom you only define the usual jar which is being consumed. A large example is Central repository https://repo1.maven.org/maven2/com/soebes/itf/jupiter/extension/itf-jupiter-extension/0.8.0/ (also separate the `xyz-VERSION-javadoc.jar` )...Easy and most important convention do not try to go different way which will cause other issue. – khmarbaise Jul 21 '20 at 18:38
  • Ok got it... Thanks for you suggestion – Suman Jul 22 '20 at 05:53

0 Answers0