1

We have a utility library that has improved over the time. Now there is this idea to also deploy this library to another repository. However, due to some constraints there we need to change the groupId during that (the content of the JAR shouldn't change).

The current pom.xml looks like 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.sjngm.common</groupId>
  <artifactId>common-lib</artifactId>
  <version>1.0.5-SNAPSHOT</version>
  <packaging>jar</packaging>

  <distributionManagement>
    <repository>
      <id>ta</id>
      <url>http://archiva.local/archiva/repository/ta/</url>
    </repository>
    <snapshotRepository>
      <id>archiva.snapshots</id>
      <url>http://archiva.local/archiva/repository/snapshots/</url>
    </snapshotRepository>
  </distributionManagement>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>1.5.4.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- plenty of that -->
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <!-- ... -->
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <!-- ... -->
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <!-- ... -->
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <!-- ... -->
      </plugin>
    </plugins>
  </build>

</project>

The new groupId could be something like com.sjngmaway.common.

I noticed relocation, but I don't understand how I can use it for my task:

  1. That seems to be a one-time thing, but we'll use this in parallel.
  2. Can I put this in the same pom.xml? With profiles or something? At least the <distributionManagement> is different.
  3. If that should be another pom.xml should I add a <dependency> there? Or can I refer to or import my current pom.xml?

Or is this all just misleading and I need some other approach?

How do I proceed?

Since I'm not the Maven-genius it would be nice if you could use my snippet from above rather than just explain it in words what I can do :) Thanks!

sjngm
  • 12,423
  • 14
  • 84
  • 114
  • Why not changing the groupId inside your project and that's it? Apart from that why not let the other access to your repository manager where the artifact already exists? – khmarbaise Feb 01 '18 at 21:57
  • @khmarbaise The situation is too complicated to explain in a few words. Your ideas of course would be the best possible options. – sjngm Feb 02 '18 at 09:38

1 Answers1

0

You can add the deploy:deploy-file goal to the deploy phase of your Maven Build http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html

It is meant to make additional deployments in addition to the standard one.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thanks. I found [this answer](https://stackoverflow.com/a/35163352/483113) also very helpful as it explains in a comment how to have Maven call that specific goal. – sjngm Feb 05 '18 at 11:10