2

tl;dr: I'm trying to solve this issue.

I have a project which builds a platform-dependent JAR and adds a classifier according to the os-maven-plugin:

<modelVersion>4.0.0</modelVersion>
<groupId>com.github.levyfan</groupId>
<artifactId>sentencepiece</artifactId>
<version>0.0.2</version>


<build>
    <extensions>
        <extension>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
            <version>1.6.1</version>
        </extension>
    </extensions>
    <!-- ... -->
    <plugins>
        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <classifier>${os.detected.classifier}</classifier>
            </configuration>
        </plugin>
    </plugins>
</build>

When I build and publish the artrifact with mvn --batch-mode deploy to GitHub Packages, I'm met with a conflict error. This is because the artifacts share a pom (sentencepiece-0.0.2.pom), but the JAR artifact is determined by the os-maven-plugin value (sentencepiece-0.0.2-XYZ.jar).

How can I inject this plugin-defined property at build-time to create unique artifact names?

erip
  • 16,374
  • 11
  • 66
  • 121

1 Answers1

1

Let me have a second try.

The items artifactId and version cannot be influenced by plugin generated properties. To influence them, the property must be given on the command line (or maybe in the POM directly).

So we are left with the classifier.

You need to build all artifacts with classifiers in the same build. So you need to change the build in a way that it builds for the different OS in one go. I don't know whether that is possible (depending on whether you can build e.g. for Windows on Linux) but it seems to be the only "Maven way" solution for you problem.

Of course, you could still try tricks like deleting the POM after you have deployed it, but if possible this should be avoided.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142