Macauley
Macauley

Reputation: 399

Building With Maven

Hello I've been trying to create a proper Maven build for a bit now. I created my Pom.xml file which is this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>XO Artifactory</name>
  <url>artifactory:8081/artifactory/webapp/home.html?0</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>

I'm trying to have the build publish to artifactory, I'm also trying to have the builds dependency be artifactory as well. For the build to publish to artifactory it would be something I set up in the settings.xml correct?

Settings.xml:

<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>artifactory:8081/artifactory/webapp/home.html?0</id>
      <username>mhopper</username>
      <password>*******</password>
    </server>
  </servers>

</settings>

Upvotes: 0

Views: 62

Answers (1)

ferdy
ferdy

Reputation: 7716

You need two steps for this:

  1. Add a proper server setting to your local ~/.m2/settings.xml containing an id of your server and the credentials to access it:

    <servers>
      <server>
        <id>deployment</id>
        <username>deployment</username>
        <password>deployment123</password>
      </server>
    </servers>
    
  2. Backref the id in your projects pom.xml where you define the actual url for this:

    <distributionManagement>
      <repository>
        <id>deployment</id>
        <name>Internal Releases</name>
        <url>artifactory:8081/artifactory/releases</url>
      </repository>
      <snapshotRepository>
        <id>deployment</id>
        <name>Internal Snapshots</name>
        <url>artifactory:8081/artifactory/snapshots</url>
      </snapshotRepository>
    </distributionManagement>
    

Upvotes: 1

Related Questions