Maven plugin to help rewrite POMs for cross-compiled Scala libraries
BSD-3-CLAUSE License
This plugin enables you to publish "clean" POM files after interpolating values for the Scala version and Scala binary version.
A common way to vary Scala binary versions is to use Maven profiles, declaring one profile for each binary version you want to cross compile to. Then you run Maven once for each binary version, activating the appropriate profile, to build and deploy artifacts.
However, the published POMs end up not working so well:
To make this work, ideally your POM and build should conform to a convention like so:
scala-2.11
, scala-2.12
, etc.scala-*
profiles are active by default.scala.version
and scala.binary.version
scala.compat.version
) to determine which Scala versions to use.scala.binary.version
, even ifIf you've fulfilled the above, you can just do the following:
<build>
<plugins>
..
<plugin>
<groupId>org.spurint.maven.plugins</groupId>
<artifactId>scala-cross-maven-plugin</artifactId>
<version>{see tags for latest version}</version>
<executions>
<execution>
<id>rewrite-pom</id>
<goals>
<goal>rewrite-pom</goal>
</goals>
</execution>
</executions>
</plugin>
..
</plugins>
</build>
When you run your build, pass -Pscala-2.12
(or whichever profile you
want) to Maven, and things will just work.
In reality, the plugin will take any properties defined in your Scala-version profile and interpolate them into group and artifact IDs in the rest of the POM.
For reference, here's an example of some profiles you might use:
<profiles>
<profile>
<id>scala-2.11</id>
<properties>
<scala.binary.version>2.11</scala.binary.version>
<scala.version>2.11.12</scala.version>
</properties>
</profile>
<profile>
<id>scala-2.12</id>
<properties>
<scala.binary.version>2.12</scala.binary.version>
<scala.version>2.12.10</scala.version>
</properties>
</profile>
</profiles>
There are a few settings you can use to tailor execution to your environment.
Name | Default | Description |
---|---|---|
rewrittenPomPath |
${project.build.directory}/.scala-cross-pom.xml |
Full path to where to write the interpolated POM file. |
scalaProfilePrefix |
scala- |
Prefix for profile names used to for scala cross-compilation. The assumed suffix is the Scala binary version. |
scalaProfileId |
(none) | Alternatively, you can specify the full name of the profile to use (scalaProfilePrefix will be ignored). |
scrubProfiles |
false |
Before writing the final POM, remove all detected Scala-version profiles. |