0

I am trying to generate sources.jar file for my project using maven-source-plugin. Here is the relevant part of my pom.xml

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>${project.build.sourceEncoding}</encoding>
                <annotationProcessors>
                    <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
                    </annotationProcessor>
                    <annotationProcessor>org.mapstruct.ap.MappingProcessor</annotationProcessor>
                </annotationProcessors>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>jar</goal>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <excludes>
                    <exclude>application.properties</exclude>
                </excludes>
                <archive>
                    <manifest>
                        <addClasspath>false</addClasspath>
                        <mainClass>com.company.application.Application</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.6.201602180812</version>
            <configuration>
                <append>true</append>
                <excludes>
                    <exclude>**/backend/**/*.*</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <id>agent-for-ut</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>agent-for-it</id>
                    <goals>
                        <goal>prepare-agent-integration</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</pluginManagement>

I am following this link and when I run mvn package I do not see any xxx-sources.jar file in my maven repository.

Here is the output of the mvn package

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building  App - Core 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ plmapp-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ plmapp-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 131 source files to C:\Users\taaupsa1\GitWS\plmapp-core\target\classes
[INFO] /C:/Users/taaupsa1/GitWS/plmapp-core/src/main/java/com/plm/core/factory/NeoConnectionFactory.java: C:\Users\taaupsa1\GitWS\plmapp-core\src\main\java\com\plm\core\factory\NeoConnectionFactory.java uses or overrides a deprecated API.
[INFO] /C:/Users/taaupsa1/GitWS/plmapp-core/src/main/java/com/plm/core/factory/NeoConnectionFactory.java: Recompile with -Xlint:deprecation for details.
[INFO] /C:/Users/taaupsa1/GitWS/plmapp-core/src/main/java/com/plm/core/model/PlmCSV.java: C:\Users\taaupsa1\GitWS\plmapp-core\src\main\java\com\plm\core\model\PlmCSV.java uses unchecked or unsafe operations.
[INFO] /C:/Users/taaupsa1/GitWS/plmapp-core/src/main/java/com/plm/core/model/PlmCSV.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ plmapp-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ plmapp-core ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ plmapp-core ---
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ plmapp-core ---
[INFO] Building jar: C:\Users\taaupsa1\GitWS\plmapp-core\target\plmapp-core.jar
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default) @ plmapp-core ---
[INFO] 
[INFO] --- maven-jar-plugin:2.6:test-jar (default) @ plmapp-core ---
[INFO] Building jar: C:\Users\taaupsa1\GitWS\plmapp-core\target\plmapp-core-tests.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.282 s
[INFO] Finished at: 2016-05-06T11:15:56+02:00
[INFO] Final Memory: 33M/441M
[INFO] ------------------------------------------------------------------------
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"

Process finished with exit code 0

What am I doing wrong here?

Sai Upadhyayula
  • 2,404
  • 3
  • 23
  • 35
  • I can't reproduce that with Maven 3.3.3. Which version of Maven are you using? – Tunaki May 06 '16 at 09:25
  • @Tunaki I am using apache-maven-3.2.5. The strange thing is I am able to generate sources for another project but not this one. – Sai Upadhyayula May 06 '16 at 09:28
  • Ah I missed it at first. This is your `pluginManagement` section. Move it in `plugins` – Tunaki May 06 '16 at 09:29
  • Ah ok, thanks I am seeing a different output now. Please post this as an answer :) – Sai Upadhyayula May 06 '16 at 09:33
  • This answer http://stackoverflow.com/questions/26736876/difference-between-plugins-and-pluginmanager-tag-in-maven-pom-xml was helpful in understanding the difference between pluginManagement and plugin. – Sai Upadhyayula May 06 '16 at 09:35

0 Answers0