This guide will help you integrate SourceNinja into your Maven work-flow. This only needs to be done once.
The SourceNinja maven plugin can be included in your build and release work-flow to allow seamless integration with SourceNinja. The SourceNinja plugin will send all of your artifacts and versions to SourceNinja to begin managing your open source libraries.
-
Create a SourceNinja account.
-
Log into SourceNinja and create a product. The product you create will be paired with your application.
-
After you create a product, you will be directed to a page asking what language your application is running. Select
Java
from the menu on the left side. -
You will be presented with two values, you'll need these two values later.
Example:
SOURCENINJA_PRODUCT_ID="477fcfa7-765a-4b91-b6a5-2ebe4c4f9d58" SOURCENINJA_TOKEN="50a336d92da8ddea1ae0a6c0d06a172"
-
Add the SourceNinja plugin to your Maven project. You can do this by adding the following lines to your
pom.xml
.<plugins> <plugin> <groupId>com.sourceninja</groupId> <artifactId>sourceninja-maven-plugin</artifactId> <version>0.1.5</version> <configuration> <id>${env.PRODUCT_ID}</id> <token>${env.PRODUCT_TOKEN}</token> </configuration> </plugin> </plugins>
-
Set the values of and in the configuration block of the XML from the previous step using the values obtained in step 4. You can choose to store these values as environment variables as demonstrated above, or you can embed them as string literals.
-
At this point the module is configured. Dependency data is sent to SourceNinja by triggering the
send
goal. This goal needs to be triggered after your dependencies are resolved, typically after the compile or test phase.mvn com.sourceninja:sourceninja-maven-plugin:0.1.5:send
-
If you want your open source usage sent to SourceNinja when your artifacts are built, you can configure maven to trigger the plugin during the package phase. For example the configuration below will send data to SourceNinja every time the build is packaged.
<plugins> <plugin> <groupId>com.sourceninja</groupId> <artifactId>sourceninja-maven-plugin</artifactId> <version>0.1.5</version> <configuration> <id>${env.PRODUCT_ID}</id> <token>${env.PRODUCT_TOKEN}</token> </configuration> <executions> <execution> <id>package</id> <phase>package</phase> <goals> <goal>send</goal> </goals> </execution> </executions> </plugin> </plugins>
Feel free to email us at support at sourceninja dot com if you have any questions or issues.