Skip to content

Drop sbt-compiler-maven-plugin (it's effectively dead) #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ internal mojos:

### Prerequisites / limitations

- The plugin is compatible with two Maven Scala compiler plugins:

- [Scala Maven Plugin](http://davidb.github.io/scala-maven-plugin/) - version `3.0.0` or later required, [addScalacArgs](http://davidb.github.io/scala-maven-plugin/compile-mojo.html#addScalacArgs) and [analysisCacheFile](http://davidb.github.io/scala-maven-plugin/compile-mojo.html#analysisCacheFile) configuration parameters cannot be set directly, use project properties `addScalacArgs` and `analysisCacheFile` instead.

- [SBT Compiler Maven Plugin](https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/) - version `1.0.0-beta5` or later required. Currently it works only with Scoverage Maven Plugin `1.4.11` or earlier.

- Starting with version `2.0.0` the plugin supports Scala `2.12.8+`, `2.13.0+` and `3.2.0+`. For Scala `2.10` and `2.11` support please use version `1.4.11`.
- The plugin is compatible with [Scala Maven Plugin](http://davidb.github.io/scala-maven-plugin/)
- version `3.0.0` or later required
- [addScalacArgs](http://davidb.github.io/scala-maven-plugin/compile-mojo.html#addScalacArgs) and [analysisCacheFile](http://davidb.github.io/scala-maven-plugin/compile-mojo.html#analysisCacheFile) configuration parameters cannot be set directly, use project properties `addScalacArgs` and `analysisCacheFile` instead.
- Starting with version `2.0.0` the plugin supports Scala `2.12.8+`, `2.13.0+` and `3.2.0+`. For Scala `2.12.7` and lower please use version `1.4.11` of the plugin.
- The plugin is not thread-safe, so it should not be used in multi-threaded builds.


Expand All @@ -78,7 +75,7 @@ If all the attempts to resolve the Scala version fail, then coverage will not be
```xml
<project>
<properties>
<scala.version>2.13.12</scala.version>
<scala.version>2.13.15</scala.version>
</properties>
</project>
```
Expand All @@ -94,7 +91,7 @@ or
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalaVersion>2.13.12</scalaVersion>
<scalaVersion>2.13.15</scalaVersion>
<!-- other parameters -->
</configuration>
</plugin>
Expand Down
25 changes: 1 addition & 24 deletions src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
* Supported compiler plugins:
* <ul>
* <li><a href="https://davidb.github.io/scala-maven-plugin/">net.alchim31.maven:scala-maven-plugin</a></li>
* <li><a href="https://sbt-compiler-maven-plugin.github.io/sbt-compiler-maven-plugin/">com.google.code.sbt-compiler-maven-plugin:sbt-compiler-maven-plugin</a></li>
* </ul>
* <br>
* This is internal mojo, executed in forked {@code scoverage} life cycle.
Expand Down Expand Up @@ -203,8 +202,7 @@ public void execute() throws MojoExecutionException
Properties projectProperties = project.getProperties();

// for maven-resources-plugin (testResources), maven-compiler-plugin (testCompile),
// sbt-compiler-maven-plugin (testCompile), scala-maven-plugin (testCompile),
// maven-surefire-plugin and scalatest-maven-plugin
// scala-maven-plugin (testCompile), maven-surefire-plugin and scalatest-maven-plugin
setProperty( projectProperties, "maven.test.skip", "true" );
// for scalatest-maven-plugin and specs2-maven-plugin
setProperty( projectProperties, "skipTests", "true" );
Expand Down Expand Up @@ -273,23 +271,19 @@ public void execute() throws MojoExecutionException
}

String arg = ( scala2 ? SCALA2_DATA_DIR_OPTION : SCALA3_COVERAGE_OUT_OPTION ) + dataDirectory.getAbsolutePath();
String _scalacOptions = quoteArgument( arg );
String addScalacArgs = arg;

arg = scala2 ? ( SOURCE_ROOT_OPTION + session.getExecutionRootDirectory() ) : "";
_scalacOptions = _scalacOptions + SPACE + quoteArgument( arg );
addScalacArgs = addScalacArgs + PIPE + arg;

if ( !StringUtils.isEmpty( excludedPackages ) )
{
if ( scala2 ) {
arg = SCALA2_EXCLUDED_PACKAGES_OPTION + excludedPackages.replace( "(empty)", "<empty>" );
_scalacOptions = _scalacOptions + SPACE + quoteArgument( arg );
addScalacArgs = addScalacArgs + PIPE + arg;
} else if ( filePackageExclusionSupportingScala3 ) {
String scala3FormatExcludedPackages = excludedPackages.replace( ";", "," );
arg = SCALA3_EXCLUDED_PACKAGES_OPTION + scala3FormatExcludedPackages;
_scalacOptions = _scalacOptions + SPACE + quoteArgument( arg );
addScalacArgs = addScalacArgs + PIPE + arg;
} else {
getLog().warn( "Package exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+" );
Expand All @@ -300,12 +294,10 @@ public void execute() throws MojoExecutionException
{
if ( scala2 ) {
arg = SCALA2_EXCLUDED_FILES_OPTION + excludedFiles;
_scalacOptions = _scalacOptions + SPACE + quoteArgument( arg );
addScalacArgs = addScalacArgs + PIPE + arg;
} else if ( filePackageExclusionSupportingScala3 ) {
String scala3FormatExcludedFiles = excludedFiles.replace( ";", "," );
arg = SCALA3_EXCLUDED_FILES_OPTION + scala3FormatExcludedFiles;
_scalacOptions = _scalacOptions + SPACE + quoteArgument( arg );
addScalacArgs = addScalacArgs + PIPE + arg;
} else {
getLog().warn( "File exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+" );
Expand All @@ -314,24 +306,16 @@ public void execute() throws MojoExecutionException

if ( highlighting && scala2 )
{
_scalacOptions = _scalacOptions + SPACE + "-Yrangepos";
addScalacArgs = addScalacArgs + PIPE + "-Yrangepos";
}

String _scalacPlugins = scala2 ? pluginArtifacts.stream()
.map(x -> String.format("%s:%s:%s", x.getGroupId(), x.getArtifactId(), x.getVersion())).collect(Collectors.joining(" ")) : "";

if ( scala2 ) {
arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(String.valueOf(java.io.File.pathSeparatorChar)));
addScalacArgs = addScalacArgs + PIPE + arg;
}

Properties projectProperties = project.getProperties();

// for sbt-compiler-maven-plugin (version 1.0.0-beta5+)
setProperty( projectProperties, "sbt._scalacOptions", _scalacOptions );
// for sbt-compiler-maven-plugin (version 1.0.0-beta5+)
setProperty( projectProperties, "sbt._scalacPlugins", _scalacPlugins );
// for scala-maven-plugin (version 3.0.0+)
setProperty( projectProperties, "addScalacArgs", addScalacArgs );
// for scala-maven-plugin (version 3.1.0+)
Expand Down Expand Up @@ -371,15 +355,8 @@ public void execute() throws MojoExecutionException
private static final String SCALA3_EXCLUDED_FILES_OPTION = "-coverage-exclude-files:";
private static final String PLUGIN_OPTION = "-Xplugin:";

private static final char DOUBLE_QUOTE = '\"';
private static final char SPACE = ' ';
private static final char PIPE = '|';

private String quoteArgument( String arg )
{
return arg.indexOf( SPACE ) >= 0 ? DOUBLE_QUOTE + arg + DOUBLE_QUOTE : arg;
}

private ScalaVersion resolveScalaVersion()
{
String result = scalaVersion;
Expand Down