Show Table of Contents
4.10. S-RAMP Maven Integration
A key feature of the S-RAMP project is the integration between Maven and S-RAMP. This integration is currently primarily provided by a Maven Wagon that supports the S-RAMP Atom based REST API protocol. You can use this wagon to upload deployable artifacts directly from Maven into a compliant S-RAMP repository.
Additionally, you can use artifacts from the S-RAMP repository as dependencies in a Maven project, also by using the S-RAMP Maven Wagon.
4.10.1. Enabling the S-RAMP Wagon
- In order to use the S-RAMP Wagon in a maven project, enable it in the
pom.xmlbuild section:<build> <extensions> <extension> <groupId>org.overlord.sramp</groupId> <artifactId>s-ramp-wagon</artifactId> <version>${s-ramp-wagon.version}</version> </extension> </extensions> </build>
4.10.2. Deploying to S-RAMP
Once the wagon is enabled, then you can use URLs with a schema of sramp in the
pom.xml's distributionManagement section. For example:
<distributionManagement>
<repository>
<id>local-sramp-repo</id>
<name>S-RAMP Releases Repository</name>
<url>sramp://localhost:8080/s-ramp-server/</url>
</repository>
<snapshotRepository>
<id>local-sramp-repo-snapshots</id>
<name>S-RAMP Snapshots Repository</name>
<url>sramp://localhost:8080/s-ramp-server/</url>
</snapshotRepository>
</distributionManagement>
With these settings, maven deployments are sent directly to the S-RAMP repository using the S-RAMP API. Note that artifacts are added to the S-RAMP repository with an artifact type based on the maven type of the project. You can override this behavior by adding a query parameter to the repository URL in the
pom.xml. For example:
<distributionManagement>
<repository>
<id>local-sramp-repo</id>
<name>S-RAMP Releases Repository</name>
<url>sramp://localhost:8080/s-ramp-server/?artifactType=SwitchYardApplication</url>
</repository>
</distributionManagement>
The above example causes the maven artifact to be uploaded with an S-RAMP artifact type of SwitchYardApplication.
Perform the following steps to deploy the maven artifact directly into s-ramp
- Cd into the sample workflow directory.
- Create a file called
sramp-settings.xmlwith the following content:<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>local-sramp-repo</id> <username>admin</username> <password>ADMIN_PASSWORD</password> </server> <server> <id>local-sramp-repo-snapshots</id> <username>admin</username> <password>ADMIN_PASSWORD</password> </server> </servers> </settings>Here, ADMIN_PASSWORD is the password that you chose during installation. - Run the following maven command:
mvn -s sramp-settings.xml deploy
4.10.3. Adding S-RAMP Artifacts as Dependencies
Once you enable the wagon, you can use artifacts from the S-RAMP repository as dependencies in your maven project.
Firstly, you must configure the S-RAMP repository in the maven project as a maven repository. You can do this with the following markup in the
pom.xml:
<repositories>
<repository>
<id>local-sramp-repo</id>
<name>Local S-RAMP Repository</name>
<url>sramp://localhost:8080/s-ramp-server</url>
<layout>default</layout>
</repository>
</repositories>
Once you configure the repository, you can reference an S-RAMP artifact as a dependency in the following ways:
- If the artifact was added to S-RAMP using the maven integration to deploy it, then the artifact in S-RAMP will contain maven specific properties, allowing it to be referenced as a dependency using those maven specific properties. In this case, add the dependency as shown in this example:
<dependency> <groupId>org.overlord.sramp.wiki</groupId> <artifactId>s-ramp-wiki-example</artifactId> <version>1.0</version> </dependency>
- If an artifact was added to the S-RAMP repository in some other way (and therefore does not have any maven specific properties), you can still use it as a dependency. In this case, you can reference the dependency by using its S-RAMP artifact model, type, and UUID. The model and type are used to make up a maven groupId, while the UUID becomes the maven artifactId. The version information is not used, but is still required in the
pom.xml). For example, if a JAR is added to the S-RAMP repository and you wish to use it as a dependency, yourpom.xmlmight contain the following dependency:<dependency> <groupId>ext.JavaArchive</groupId> <artifactId>8744-437487-4734525-382345-923424</artifactId> <version>1.0</version> </dependency>
4.10.4. Authentication
Whenever the S-RAMP Maven integration features are used, it is likely that you will need to provide valid authentication credentials. You may provide the S-RAMP repository username and password in the Maven
settings.xml file. If no credentials are found there, then you will be prompted to enter them when they are needed during the build. Here is an example of providing credentials in the settings.xml file:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>local-sramp-repo</id>
<username>admin</username>
<password>ADMIN_PASSWORD</password>
</server>
<server>
<id>local-sramp-repo-snapshots</id>
<username>admin</username>
<password>ADMIN_PASSWORD</password>
</server>
</servers>
</settings>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.