metlos/multi-release-jar-maven-plugin

can't pick up created artifact from repository

Closed this issue · 6 comments

since packaging is 'multi-release-jar' I end up with a 'myModule.multi-release-jar' instead of 'myModule.jar' in my maven repository. How do I pick up the created artifact in other maven modules?

Hmm, I never actually tried to deploy such jars into a maven repo, since I only made the plugin as a proof of concept.. Not sure if there is a way of deploying a simple jar even with a custom packaging like this.

Have you tried declaring the dependency with <type>multi-release-jar</type>? It is far from ideal, but could work as a workaround...

I currently lack time to look into the issue and make the plugin deploy normal jars, so if you find a solution for that I would be more than happy to accept a pull request.

I was able to work around it by using 'build-helper-maven-plugin'. This way I still get a .multi-rlease-jar file but additionally get a .jar file which I can use.

Here is the code I use:

<build>

    <extensions>
      <extension>
        <groupId>pw.krejci</groupId>
        <artifactId>multi-release-jar-maven-plugin</artifactId>
        <version>0.1.0</version>
      </extension>
    </extensions>

    <plugins>

      <plugin>
        <groupId>pw.krejci</groupId>
        <artifactId>multi-release-jar-maven-plugin</artifactId>
        <version>0.1.0</version>
        <configuration>
          <archive>
            <manifest>
              <useUniqueVersions>true</useUniqueVersions>
              <addClasspath>true</addClasspath>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/${project.build.finalName}.jar</file>
                  <type>jar</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
    </plugins>

  </build>


  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

I just released version 0.1.1 that should correctly deploy the artifacts with the ".jar" extension. Give it a spin if you want to try it out...

Quickly followed by 0.1.2 - now the mr jar should also declare the Multi-Release: true manifest entry if it is needed.

Works without 'build-helper-maven-plugin' now.

Thanks :) 👍