Skip to content

Commit 569ca45

Browse files
committed
Drop support for Scala 2.10/2.11, bump version to 2.0.0-SNAPSHOT
1 parent 3c25e1e commit 569ca45

File tree

3 files changed

+29
-81
lines changed

3 files changed

+29
-81
lines changed

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Maven generated plugin documentation:
4545
|------------------|--------------------------------------------------------------------------------------------------|
4646
| `1.4.11` | [Plugin Info](http://scoverage.github.io/scoverage-maven-plugin/1.4.11/plugin-info.html) |
4747

48-
##### Prerequisities / limitations
48+
##### Prerequisites / limitations
4949

5050
Plugin is compatible with two Maven Scala compiler plugins:
5151

@@ -61,20 +61,20 @@ This can be set as project property.
6161
```xml
6262
<project>
6363
<properties>
64-
<scoverage.plugin.version>1.4.11</scoverage.plugin.version>
64+
<scoverage.plugin.version>2.0.0</scoverage.plugin.version>
6565
</properties>
6666
</project>
6767
```
6868

6969

7070
##### Scala version configuration
7171

72-
Plugin supports Scala 2.10.x, 2.11.x, 2.12.x and 2.13.x versions by automatically loading and configuring scalac-scoverage-plugin_2.10, scalac-scoverage-plugin_2.11, scalac-scoverage-plugin_2.12 or scalac-scoverage-plugin_2.13 Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining `scalaVersion` plugin configuration parameter or `scala.version` project property. Without this setting, coverage will not be calculated.
72+
Plugin supports Scala 2.12.x and 2.13.x versions by automatically loading and configuring matching `scalac-scoverage-plugin` Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining `scalaVersion` plugin configuration parameter or `scala.version` project property. Without this setting, coverage will not be calculated.
7373

7474
```xml
7575
<project>
7676
<properties>
77-
<scala.version>2.13.8</scala.version>
77+
<scala.version>2.13.12</scala.version>
7878
</properties>
7979
</project>
8080
```
@@ -90,7 +90,7 @@ or
9090
<artifactId>scoverage-maven-plugin</artifactId>
9191
<version>${scoverage.plugin.version}</version>
9292
<configuration>
93-
<scalaVersion>2.13.8</scalaVersion>
93+
<scalaVersion>2.13.12</scalaVersion>
9494
<!-- other parameters -->
9595
</configuration>
9696
</plugin>
@@ -113,6 +113,8 @@ The first method is better because once the property is defined it's value can b
113113
</project>
114114
```
115115

116+
For Scala 2.10 and 2.11 support please use Scoverage Maven plugin `1.4.11`.
117+
116118
##### Scalac SCoverage plugin version configuration
117119

118120
Maven SCoverage plugin uses by default the latest version of the [scalac-scoverage-plugin](https://github.com/scoverage/scalac-scoverage-plugin) available on its release day.
@@ -122,7 +124,7 @@ It can be configured by defining `scalacPluginVersion` plugin configuration para
122124
```xml
123125
<project>
124126
<properties>
125-
<scoverage.scalacPluginVersion>1.4.11</scoverage.scalacPluginVersion>
127+
<scoverage.scalacPluginVersion>2.0.11</scoverage.scalacPluginVersion>
126128
</properties>
127129
</project>
128130
```
@@ -138,7 +140,7 @@ or
138140
<artifactId>scoverage-maven-plugin</artifactId>
139141
<version>${scoverage.plugin.version}</version>
140142
<configuration>
141-
<scalacPluginVersion>1.4.11</scalacPluginVersion>
143+
<scalacPluginVersion>2.0.11</scalacPluginVersion>
142144
<!-- other parameters -->
143145
</configuration>
144146
</plugin>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ under the License.
2828
<modelVersion>4.0.0</modelVersion>
2929
<groupId>org.scoverage</groupId>
3030
<artifactId>scoverage-maven-plugin</artifactId>
31-
<version>1.4.12-SNAPSHOT</version>
31+
<version>2.0.0-SNAPSHOT</version>
3232
<packaging>maven-plugin</packaging>
3333

3434
<name>SCoverage Maven Plugin</name>

src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java

+19-73
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public class SCoveragePreCompileMojo
134134
*
135135
* @since 1.0.0
136136
*/
137-
@Parameter( property = "scoverage.scalacPluginVersion", defaultValue = "" )
137+
@Parameter( property = "scoverage.scalacPluginVersion", defaultValue = "2.0.11" )
138138
private String scalacPluginVersion;
139139

140140
/**
@@ -230,15 +230,7 @@ public void execute() throws MojoExecutionException
230230
String resolvedScalaVersion = resolveScalaVersion();
231231
if ( resolvedScalaVersion != null )
232232
{
233-
if ( "2.10".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWith( "2.10." ) )
234-
{
235-
scalaBinaryVersion = "2.10";
236-
}
237-
else if ( "2.11".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWith( "2.11." ) )
238-
{
239-
scalaBinaryVersion = "2.11";
240-
}
241-
else if ( "2.12".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWith( "2.12." ) )
233+
if ( "2.12".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWith( "2.12." ) )
242234
{
243235
scalaBinaryVersion = "2.12";
244236
}
@@ -426,79 +418,33 @@ private void setProperty( Properties projectProperties, String propertyName, Str
426418
}
427419
}
428420

421+
private ArtifactVersion getScalacPluginVersion() {
422+
if ( scalacPluginVersion == null || scalacPluginVersion.isEmpty()) {
423+
throw new IllegalStateException("scalacPluginVersion is unset.");
424+
} else if ( scalacPluginVersion.startsWith("1.") ) {
425+
throw new IllegalStateException( String.format( "Unsupported scalacPluginVersion \"%s\". Please use scalacPluginVersion 2.0.0+ or use older version of scoverage-maven-plugin", scalacPluginVersion ) );
426+
} else {
427+
return new DefaultArtifactVersion(scalacPluginVersion);
428+
}
429+
}
430+
429431
private List<Artifact> getScalaScoveragePluginArtifacts(String resolvedScalaVersion, String scalaMainVersion )
430432
throws ArtifactNotFoundException, ArtifactResolutionException
431433
{
432-
String resolvedScalacPluginVersion = scalacPluginVersion;
433-
if ( resolvedScalacPluginVersion == null || "".equals( resolvedScalacPluginVersion ) )
434-
{
435-
for ( Artifact artifact : pluginArtifacts )
436-
{
437-
if ( "org.scoverage".equals( artifact.getGroupId() )
438-
&& artifact.getArtifactId().startsWith( "scalac-scoverage-plugin_" ) )
439-
{
440-
resolvedScalacPluginVersion = artifact.getVersion();
441-
break;
442-
}
443-
}
444-
}
445-
446-
// There are 3 cases depending on the version of scalac-scoverage-plugin
447-
// * Version 2.0.0 onwards - 3 artifacts, plugin using resolvedScalaVersion
448-
// * Version 1.4.2 - 1 artifact, plugin using resolvedScalaVersion falling back to scalaMainVersion
449-
// * Version 1.4.1 older - 1 artifact, plugin using scalaMainVersion
450-
//
451-
final ArtifactVersion pluginArtifactVersion = new DefaultArtifactVersion(resolvedScalacPluginVersion);
452-
if(pluginArtifactVersion.getMajorVersion() >= 2) {
453-
List<Artifact> resolvedArtifacts = new ArrayList<>();
454-
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-plugin_" + resolvedScalaVersion, resolvedScalacPluginVersion));
455-
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-domain_" + scalaMainVersion, resolvedScalacPluginVersion));
456-
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-serializer_" + scalaMainVersion, resolvedScalacPluginVersion));
457-
return resolvedArtifacts;
458-
} else if (pluginArtifactVersion.getMajorVersion() == 1 && pluginArtifactVersion.getMinorVersion() == 4 && pluginArtifactVersion.getIncrementalVersion() == 2)
459-
{
460-
try
461-
{
462-
return Collections.singletonList(
463-
getResolvedArtifact("org.scoverage", "scalac-scoverage-plugin_" + resolvedScalaVersion, resolvedScalacPluginVersion )
464-
);
465-
}
466-
catch ( ArtifactNotFoundException | ArtifactResolutionException e2 )
467-
{
468-
getLog().warn( String.format( "Artifact \"org.scoverage:scalac-scoverage-plugin_%s:%s\" not found, " +
469-
"falling back to \"org.scoverage:scalac-scoverage-plugin_%s:%s\"",
470-
resolvedScalaVersion, resolvedScalacPluginVersion, scalaMainVersion, resolvedScalacPluginVersion ) );
471-
return Collections.singletonList(
472-
getResolvedArtifact("org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion, resolvedScalacPluginVersion )
473-
);
474-
}
475-
} else {
476-
return Collections.singletonList(
477-
getResolvedArtifact("org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion, resolvedScalacPluginVersion )
478-
);
479-
}
434+
String resolvedScalacPluginVersion = getScalacPluginVersion().toString();
435+
List<Artifact> resolvedArtifacts = new ArrayList<>();
436+
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-plugin_" + resolvedScalaVersion, resolvedScalacPluginVersion));
437+
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-domain_" + scalaMainVersion, resolvedScalacPluginVersion));
438+
resolvedArtifacts.add(getResolvedArtifact("org.scoverage", "scalac-scoverage-serializer_" + scalaMainVersion, resolvedScalacPluginVersion));
439+
return resolvedArtifacts;
480440
}
481441

482442
private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion )
483443
throws ArtifactNotFoundException, ArtifactResolutionException
484444
{
485-
String resolvedScalacRuntimeVersion = scalacPluginVersion;
486-
if ( resolvedScalacRuntimeVersion == null || "".equals( resolvedScalacRuntimeVersion ) )
487-
{
488-
for ( Artifact artifact : pluginArtifacts )
489-
{
490-
if ( "org.scoverage".equals( artifact.getGroupId() )
491-
&& artifact.getArtifactId().startsWith( "scalac-scoverage-plugin_" ) )
492-
{
493-
resolvedScalacRuntimeVersion = artifact.getVersion();
494-
break;
495-
}
496-
}
497-
}
498-
499445
return getResolvedArtifact(
500446
"org.scoverage", "scalac-scoverage-runtime_" + scalaMainVersion,
501-
resolvedScalacRuntimeVersion );
447+
getScalacPluginVersion().toString() );
502448
}
503449

504450
/**

0 commit comments

Comments
 (0)