Maven won't run scala tests - scala

I'm using maven scala test plugin as described here. I defined two test classes and put them under src/test/scala:
Tests are looking like the following:
class LoginTest extends FlatSpec with ShouldMatchers with WebBrowser with Eventually with IntegrationPatience {
...
}
My pom.xml contains the following dependencies / configuration:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I run mvn test I got the message:
[INFO] --- scalatest-maven-plugin:1.0:test (test) # selenium ---
Discovery starting.
Discovery completed in 30 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 91 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.
Calling tests from Intellij brings a message:
0 test class found in package '<default package>'

Had similar problems
mvn install discovers test, mvn test does not

I had to make 2 changes for this to work in my case:
Change the name of the filereport, remove space: <filereports>WDFTestSuite.txt</filereports>
Explicitly say not to skip tests: <skipTests>false</skipTests>
So the configuration block looks like this:
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDFTestSuite.txt</filereports>
<skipTests>false</skipTests>
</configuration>

Related

error: java.lang.NoSuchMethodError: 'scala.tools.nsc.reporters.Reporter scala.tools.nsc.Global.reporter()' in scoverage-maven-plugin

I am trying to get some reports with the code coverage information for my project. I found that scoverage-maven-plugin produce xml files covering the % of the different modules that the unit test cases have covered so far.
So I tried to add that plugin in my pom, but I am getting the following error:
[ERROR] error: java.lang.NoSuchMethodError: 'scala.tools.nsc.reporters.Reporter scala.tools.nsc.Global.reporter()'
[INFO] at scoverage.ScoverageInstrumentationComponent$$anon$1.run(plugin.scala:115)
[INFO] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1514)
[INFO] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1498)
[INFO] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
[INFO] at scala.tools.nsc.Global$Run.compile(Global.scala:1620)
[INFO] at scala.tools.nsc.Driver.doCompile(Driver.scala:47)
[INFO] at scala.tools.nsc.MainClass.doCompile(Main.scala:32)
[INFO] at scala.tools.nsc.Driver.process(Driver.scala:67)
[INFO] at scala.tools.nsc.Driver.main(Driver.scala:80)
[INFO] at scala.tools.nsc.Main.main(Main.scala)
[INFO] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
[INFO] at java.base/java.lang.reflect.Method.invoke(Method.java:577)
[INFO] at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
[INFO] at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
[INFO] java.lang.reflect.InvocationTargetException
[INFO] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
[INFO] at java.base/java.lang.reflect.Method.invoke(Method.java:577)
[INFO] at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
[INFO] at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
[ERROR] Caused by: java.lang.NoSuchMethodError: 'scala.tools.nsc.reporters.Reporter scala.tools.nsc.Global.reporter()'
[INFO] at scoverage.ScoverageInstrumentationComponent$$anon$1.run(plugin.scala:115)
[INFO] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1514)
[INFO] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1498)
[INFO] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
[INFO] at scala.tools.nsc.Global$Run.compile(Global.scala:1620)
[INFO] at scala.tools.nsc.Driver.doCompile(Driver.scala:47)
[INFO] at scala.tools.nsc.MainClass.doCompile(Main.scala:32)
[INFO] at scala.tools.nsc.Driver.process(Driver.scala:67)
[INFO] at scala.tools.nsc.Driver.main(Driver.scala:80)
[INFO] at scala.tools.nsc.Main.main(Main.scala)
[INFO] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
[INFO] ... 3 more
Not able to find from where I should get scala.tools.nsc.reporters.Reporter scala.tools.nsc.Global.reporter()
The full pom is:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroupid</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0</version>
<name>myproject</name>
<properties>
<app.build.version>1.0.0</app.build.version>
<encoding>UTF-8</encoding>
<scala.version>2.12.14</scala.version>
<scala.compat.version>2.12</scala.compat.version>
<scala.binary.version>2.12</scala.binary.version>
<spark.version>3.2.1</spark.version>
<scope.value>provided</scope.value>
<scoverage.plugin.version>1.3.0</scoverage.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>io.delta</groupId>
<artifactId>delta-core_2.12</artifactId>
<version>2.0.0</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>3.1.2</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql-kafka-0-10_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>${scope.value}</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.12</artifactId>
<version>3.2.14</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>myproject-${app.build.version}</finalName>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<highlighting>true</highlighting>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>report</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>Scaladoc</id>
<goals>
<goal>doc</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<args>
<arg>-no-link-warnings</arg>
</args>
</configuration>
</execution>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>doc-jar</goal>
</goals>
</execution>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
<jvmArgs>
<jvmArg>-Xss4m</jvmArg>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx4096m</jvmArg>
</jvmArgs>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
<htmlreporters>${project.build.directory}/html/scalatest</htmlreporters>
</configuration>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Edits after #Dmytro feedback:
I added in the pom the following dependencies:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scoverage</groupId>
<artifactId>scalac-scoverage-plugin_2.12</artifactId>
<version>1.4.1</version>
</dependency>
And changed the scope to
<scope.value>compile</scope.value>
But I am still getting the error: java.lang.NoSuchMethodError: 'scala.tools.nsc.reporters.Reporter scala.tools.nsc.Global.reporter()'
Could you try to add
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<!--<version>2.12.14</version>-->
<version>${scala.version}</version>
</dependency>
?
https://mvnrepository.com/artifact/org.scala-lang/scala-compiler
Does this change anything for you?
scoverage-maven-plugin 1.3.0 depends on scalac-scoverage-plugin 1.3.0
https://github.com/scoverage/scoverage-maven-plugin/blob/scoverage-maven-plugin-1.3.0/pom.xml#L93-L101
scalac-scoverage-plugin 1.3.0 depends on scala-compiler 2.12.0
https://index.scala-lang.org/scoverage/scalac-scoverage-plugin/artifacts/scalac-scoverage-plugin/1.3.0
https://github.com/scoverage/scalac-scoverage-plugin/blob/v1.3.0/build.sbt#L89
https://github.com/scoverage/scalac-scoverage-plugin/blob/v1.3.0/build.sbt#L15
scala-compiler is marked as provided in the dependencies of scalac-scoverage-plugin so should be added manually when needed.
The method scala.tools.nsc.Global.reporter() returns Reporter in scala-compiler 2.12.0 https://github.com/scala/scala/blob/v2.12.0/src/compiler/scala/tools/nsc/Global.scala#L1581 (it seems in 2.12.0 there is no scala.tools.nsc.Global.reporter(), it appears in 2.12.5). In 2.12.14 the signature is different, the method returns FilteringReporter https://github.com/scala/scala/blob/v2.12.14/src/compiler/scala/tools/nsc/Global.scala#L1748 https://github.com/scala/scala/blob/v2.12.14/src/compiler/scala/tools/nsc/Global.scala#L90 So the issue seems to be in the combination of versions scalac-scoverage-plugin 1.3.0 + scala-compiler 2.12.14.
Try to either upgrade scoverage-plugin or downgrade Scala version so that the signature of the method is the same (returning either Reporter both times or FilteringReporter both times). The signature changed in 2.12.12 -> 2.12.13 (Reporter -> FilteringReporter) https://github.com/scala/scala/blob/v2.12.12/src/compiler/scala/tools/nsc/Global.scala#L90 https://github.com/scala/scala/blob/v2.12.13/src/compiler/scala/tools/nsc/Global.scala#L90 If you're on scoverage-plugin 1.4.1 can you change Scala to 2.12.12?
Try then to downgrade the scala version:
<properties>
<scala.version>2.12.12</scala.version>
...
</properties>
in combination with
<dependency>
<groupId>org.scoverage</groupId>
<artifactId>scalac-scoverage-plugin_2.12</artifactId>
<version>1.4.1</version>
</dependency>

[karate/gatling]:Cannot find project Scala library 2.12.8 for module

I want to run galtling tests using karate tests already in place.
For this I created a first .scala file and defined my pom.xml with the dependencies and plugins needed. I also downloaded the scala library at version 2.12.8
I encounter the following error: Cannot find project Scala library 2.12.8 for module. The library is not found.
My IDE is intelliJ. Here is the library I placed in my project
The library is integrated into the project module like this:
Here's the run/debug config:
Here's the scala.file:
package karate.features.api
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.language.postfixOps
import scala.concurrent.duration._
class KarateGatling extends Simulation {
val corpoProtocol = karateProtocol("/v0/corporations/{id}" -> Nil)
val quotProtocol = karateProtocol("/v0/quotations/{id}" -> Nil)
val createCorpo = scenario("blah").exec(karateFeature("classpath:karate/features/api/api-blah-blah.feature"))
val createQuot = scenario("blah").exec(karateFeature("classpath:karate/features/api/api-v-blah.feature"))
setUp(
createCorpo.inject(rampUsers(20) during (10 seconds)).protocols(corpoProtocol),
createQuot.inject(rampUsers(10) during (5 seconds)).protocols(quotProtocol)
Here's the pom.xml:
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.5.6
com.crm.e2e
e2e-ui
0.0.1-SNAPSHOT
e2e-ui
Getting started with Karate
<properties>
<java.version>11</java.version>
<junit-jupiter.version>5.4.0</junit-jupiter.version>
<mockito.version>3.2.4</mockito.version>
<karate.version>1.2.0</karate.version>
<gatling.plugin.version>4.1.5</gatling.plugin.version>
<scala.maven.plugin.version>4.5.6</scala.maven.plugin.version>
<web-drivers.version>3.12.0</web-drivers.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${web-drivers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${web-drivers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-gatling</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<excludes>
<exclude>karate/**/*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling.plugin.version}</version>
<configuration>
<simulationsFolder>src/test/java</simulationsFolder>
<includes>
<include>karate.features.api.perfCreateCorpo</include>
</includes>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-Jbackend:GenBCode</arg>
<arg>-Jdelambdafy:method</arg>
<arg>-target:jvm-1.8</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:postfixOps</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
My environment:
IntelliJ 2022
plugins cucumber+, KarateLab (free trial), scala, cucumber for scala
ubuntu 20.04
How can I resolve the error please ?
I fixed a simillar Intellij Maven Sync error:
Cannot find project Scala library 2.12.14 for module
I added a configuration tag for Scala version to scala-maven-plugin in pom.xml
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.8.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>2.12.14</scalaVersion>
</configuration>
</plugin>

Exception While Using net.alchim31.maven:scala-maven-plugin

I have a scala-maven-spark project.
Here is my pom.xml file
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<scala.version>2.11.8</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api-scala_2.11</artifactId>
<version>11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<finalName>${project.artifactId}-${project.version}</finalName>
<relocations>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>shaded.com.google.protobuf</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>shaded.com.google.common</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn clean package I am getting the below error
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.3.3:compile (default) on project decisionengine-data-ingestion-maven: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
If I remove the net.alchim31.maven plugin the build completes successfully.
Error details
[ERROR] error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
[ERROR] at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
[ERROR] at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
[E
If you have scala source code you need
to add the scala-maven-plugin (please use a more recent version see https://search.maven.org/search?q=a:scala-maven-plugin, today 4.5.6 is the latest, why using 3.3.3 from 2018-06 ?) to compile your code
to have the scala-library as an explicit dependency
And remove
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
It's better to let the plugin detects the scala version from dependencies.

Cucumber tests execute fine on local machine, but fail while running in jenkins

I'm new to maven and eclipse. Working on a project ran into an issue while trying to integrate with jenkins.
Executing "clean test" or "clean install" goal, runs tests fine in the Eclipse on local machine, but using same goal in Jenkins fails the tests with:
Failure in before hook:StepDefinitionsMyProject.before(Scenario)
Message: cucumber.runtime.CucumberException: Failed to instantiate class com.myCompany.stepDefinitions.StepDefinitionsProject.
My files are located in src/main/java
The cukeRunnerTest is in src/test/java
Feature files are in src/test/resources
POM snippet..
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
</plugin>
</plugins>
</build>
Any thoughts on as to why this might be happenning?

M2E not adding Groovy source to .classpath on import existing maven project

Using Eclipse Indigo to import existing maven project, the resulting workspace project does not include src/main/groovy or src/test/groovy in the build path. I would also like to have the output dir for the groovy code set to target/test-classes.
This is my first question to this excellent group, so I hope I cover all of the bases.
Environment:
Eclipse Indigo
m2e - Maven Integration for Eclipse 1.2.0.20120903-1050 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e
m2e connector for build-helper-maven-plugin 0.15.0.201207090124 org.sonatype.m2e.buildhelper.feature.feature.group Sonatype, Inc.
APT M2E Connector 0.0.1.3 de.joe.m2e.apt.feature.feature.group null
Groovy-Eclipse Feature 2.5.2.xx-20110929-1800-e37 org.codehaus.groovy.eclipse.feature.feature.group Codehaus.org
Groovy-Eclipse M2E integration 2.7.1.xx-20120921-2000-e37RELEASE org.codehaus.groovy.m2eclipse.feature.group Codehaus.org
Tycho Project Configurators 0.6.0.201207302152 org.sonatype.tycho.m2e.feature.feature.group Sonatype, Inc.
My pom.xml for the project is:
<?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>
<parent>
<groupId>com.jha.yhs</groupId>
<artifactId>fraud.server.parent</artifactId>
<version>201203.8.0-SNAPSHOT</version>
</parent>
<artifactId>ach-wire</artifactId>
<dependencies>
<dependency>
<groupId>com.jha.yhs</groupId>
<artifactId>aspects</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jha.yhs</groupId>
<artifactId>database</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r09</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.5-groovy-1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.155</version>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.4.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
</plugin>
</plugins>
</build>
</project>
Now this pom.xml is a child (in a subdirectory) of another pom.xml which contains:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<encoding>windows-1252</encoding>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m -XX:-HeapDumpOnOutOfMemoryError</argLine>
<includes>
<include>**/UnitTests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.6</version>
</dependency>
</dependencies>
<configuration>
<providerSelection>1.7</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
please note, I can add the groovy source folders using:
- the GUI's build path
- by editing the .classpath file
- run mvn eclipse:eclipse from the command line and the groovy source dir's get added to .classpath but not the output directories.
However, looking at: this and this using build-helper should solve the problem. I have tried putting the build-helper reference into the project pom.xml with no change in behavior. I have also tried using the maven-eclipse plugin to set the additional source folders as described here and
We have four of these sub projects that use groovy and I would love to not have to add the groovy folders and output folders for main and test for each of them whenever we pull new code from SVN. It seems that M2E's import maven project just doesn't work correctly. Neither does maven->updateProject for that matter. What am I missing from this?
As a work around, it seems that m2e 1.2 does not overwrite the .classpath and .project files like m2e 1.0 liked to do, so I can always manually configure the .classpath and .project files and put them into source control.
I am using Groovy in webapp developing with Maven. But I am using groovy-eclipse-compiler. First, I configure Maven compiler plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>${groovy-eclipse-compiler.version}</version>
</dependency>
</dependencies>
</plugin>
Then, I configure source directories:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
After that, I am able to use Groovy with Eclipse + m2e (actually, I am using Springsource Tool Suite with Groovy plugin). I have Groovy syntax and autocompletion (far from ideal), also I can use Groovy classes from Java and vice versa.