Skip to content

Commit

Permalink
Fix scalaCompatVersion check, closes #732
Browse files Browse the repository at this point in the history
  • Loading branch information
jozic authored and davidB committed Feb 25, 2024
1 parent 49e3fae commit f4910bc
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/it/test_scalaCompatVersion/invoker.properties
@@ -0,0 +1 @@
invoker.goals=clean compile -e
69 changes: 69 additions & 0 deletions src/it/test_scalaCompatVersion/pom.xml
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>it.scala-maven-plugin</groupId>
<artifactId>test_scalaCompatVersion</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test for Compatible Scala versions and error message output!</name>
<description>Test for Compatible Scala versions and error message output!</description>

<properties>
<scala.version.major>2.12</scala.version.major>
<scala.compat.version>${scala.version.major}</scala.compat.version>
<scala.version.minor>14</scala.version.minor>
<scala.version>${scala.version.major}.${scala.version.minor}</scala.version>
<spark.version>3.2.1</spark.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.compat.version}</artifactId>
<version>${spark.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>

<pluginManagement>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
@@ -0,0 +1,6 @@
class ScalaClass {

def abstractJavaMethod() : Unit = {
Console.println("Test")
}
}
21 changes: 21 additions & 0 deletions src/it/test_scalaCompatVersion/validate.groovy
@@ -0,0 +1,21 @@
try {

def echoString = "[WARNING] Multiple versions of scala libraries detected!"
def logFile = new File(basedir, "build.log")
//Look for echo string
def found = false;
logFile.eachLine({ line ->
if(line.contains(echoString)) {
found = true;
}
});

assert !found


return true

} catch(Throwable e) {
e.printStackTrace()
return false
}
Expand Up @@ -45,7 +45,7 @@ public boolean visit(DependencyNode node) {
try {
if (_scalaContext.hasInDistro(artifact) && artifact.getVersion() != null) {
VersionNumber originalVersion = new VersionNumber(artifact.getVersion());
if (_scalaContext.version().compareTo(originalVersion)
if (_scalaContext.versionCompat().compareTo(originalVersion)
!= 0) { // _version can be a VersionNumberMask
_failed = true;
}
Expand Down

0 comments on commit f4910bc

Please sign in to comment.