1

I am using maven to build a java project. The java project has a pom file which contains the URL that I need to upload the build artifact to. I could use regex to extract the URL, however I'd like to know if there is a 'better' or more standard approach. Here is the top of my pom file. As you can see, there is a URL (example.com) that I want to extract.

<?xml version="1.0" encoding="UTF-8"?>
<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>ca.pensionsbc.services</groupId>
    <artifactId>penc-utility-srv</artifactId>
    <version>1.7.5</version>
    <packaging>jar</packaging>
    <name>penc-utility-srv</name>
    <description>Utility Service</description>

    <repositories>
        <repository>
            <id>nexus-public</id>
            <url>https://example.com/path</url>
        </repository>

    </repositories>
Mathew
  • 1,116
  • 5
  • 27
  • 59

1 Answers1

1

Check in command-line first if mvn dependency:list-repositories would be able to list the URL for you.

If so, you could run the same command from Java, and post-process its result to get the URL.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250