Home > other >  maven doesn't package the compiled source files
maven doesn't package the compiled source files

Time:11-04

I have the following in my pom.xml

<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>17</source>
                <target>17</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/java</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The only classes found in the 0.0.1-SNAPSHOT.jar are from org.springframework.boot.loader package. None of the class files compiled from my source files is there. Below is the output of maven install:

INFO] --------------------< com.stocktrader:stock-trader

-------------------- [INFO] Building stock-trader 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- build-helper-maven-plugin:3.0.0:add-source (default) @ stock-trader --- [INFO] Source directory: C:\Users\kannanj\IdeaProjects\ibkr\src\main\java added. [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ stock-trader --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ stock-trader --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ stock-trader --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] skip non existing resourceDirectory C:\Users\kannanj\IdeaProjects\ibkr\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ stock-trader --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ stock-trader --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ stock-trader --- [INFO] Building jar: C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.7.0:repackage (repackage) @ stock-trader --- [INFO] Replacing main artifact with repackaged archive [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ stock-trader --- [INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\target\stock-trader-0.0.1-SNAPSHOT.jar to C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.jar [INFO] Installing C:\Users\kannanj\IdeaProjects\ibkr\pom.xml to C:\Users\kannanj.m2\repository\com\stocktrader\stock-trader\0.0.1-SNAPSHOT\stock-trader-0.0.1-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS

Please help before I shoot myself.

CodePudding user response:

If you want to use some common parts in another project there are two possible solutions.

  • First make a multi module build and separate the common from the other parts. The commons part will be a simple jar (also possible with some spring support)
  • Create a complete separate standalone project and consume that.
  • Related