Search code examples
mavenjitpack

Add sources to JitPack artifact


I have a public GitHub repository with a Maven managed project. I am using JitPack as Maven repo to deploy artifact versions, and it works like a charm.

However, I don't know how to add a new artifact with sources classifier. Someone knows how to do it?


Solution

  • To add sources to a Maven project you need use the maven-source-plugin. If the project builds a sources jar then it will be published by JitPack.

    Add this to pom.xml

    <build>
      <plugins>
         <plugin>  <!-- Create sources.jar -->
            <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>
      </plugins>
    </build>
    

    For example https://github.com/jitpack/maven-simple/blob/master/pom.xml#L35-L46: