Attach source directory with build-helper-maven - eclipse

I tried to attach a source directory generated by jaxb or cxf in using the build-helper-maven plugin. Unfortunately, even though I got a success in the mvn generate-sources, my eclipse didn't add the target directory as a source folder.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated/cxf</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Log :
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # coucou-services ---
[INFO] Deleting D:\004_Development\coucou\Workspace\coucou-bom\coucou-services\target
[INFO]
[INFO] --- cxf-codegen-plugin:2.4.6:wsdl2java (generate-sources) # coucou-services ---
[INFO]
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (add-source) # coucou-services ---
[INFO] Source directory: D:\004_Development\coucou\Workspace\coucou-bom\coucou-services\target\generated\cxf added.
[INFO]
[INFO] -
Do you have any idea ?
Best regards

Eclipse's M2 plugin will interpret better the declarations within the build section. Try this:
<build>
<sourceDirectory>${project.build.directory}/generated/cxf</sourceDirectory>
</build>

Related

gwt-plugin compile-error with JDK-17: Unable to make private final sun.util.calendar.BaseCalendar$Date java.util.Date.getCalendarDate() accessible

I try to upgrade my large java-application from jdk-11 to jdk-17. On jdk-11 all is ok.
We use the following gwt-plugin (version 1.0.1) to compile:
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<moduleName>xxxxxxxxxxxxx</moduleName>
<jvmArgs>
<jvmArg>-showversion</jvmArg>
<jvmArg>-Xmx2048M</jvmArg>
</jvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
but the compile complains with:
[INFO] --- gwt-maven-plugin:1.0.1:compile (default-cli) # xxxxxxx ---
[WARNING] openjdk version "17.0.2" 2022-01-18 LTS
[WARNING] OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
[WARNING] OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)
[INFO] Compiling module xxxxxxxx
...
[INFO] java.lang.reflect.InaccessibleObjectException: Unable to make private final sun.util.calendar.BaseCalendar$Date java.util.Date.getCalendarDate() accessible: module java.base does not "opens java.util" to unnamed module #145f66e3
[INFO] at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
[INFO] at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
[INFO] at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
[INFO] at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
[INFO] at org.hibernate.validator.util.privilegedactions.SetAccessibility.run(SetAccessibility.java:39)
[INFO] at org.hibernate.validator.util.ReflectionHelper.setAccessibility(ReflectionHelper.java:354)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.addMethodMetaConstraint(BeanMetaDataImpl.java:474)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.initMethodConstraints(BeanMetaDataImpl.java:654)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.initClass(BeanMetaDataImpl.java:546)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.createMetaData(BeanMetaDataImpl.java:540)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.<init>(BeanMetaDataImpl.java:209)
[INFO] at org.hibernate.validator.metadata.BeanMetaDataImpl.<init>(BeanMetaDataImpl.java:163)
[INFO] at org.hibernate.validator.engine.ValidatorImpl.getBeanMetaData(ValidatorImpl.java:1211)
[INFO] at org.hibernate.validator.engine.ValidatorImpl.getConstraintsForClass(ValidatorImpl.java:251)
[INFO] at com.google.gwt.validation.rebind.BeanHelperCache.doCreateHelper(BeanHelperCache.java:113)
If I add the add-opens parameter like this:
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<moduleName>xxxxxxxxxxxxx</moduleName>
<jvmArgs>
<jvmArg>-showversion</jvmArg>
<jvmArg>-Xmx2048M</jvmArg>
<jvmArg>--add-opens java.base/java.util=ALL-UNNAMED</jvmArg>
</jvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
then, I get the following error:
[INFO] --- gwt-maven-plugin:1.0.1:compile (default-cli) # xxxxxx ---
[WARNING] Unrecognized option: --add-opens java.base/java.util=ALL-UNNAMED
[WARNING] Error: Could not create the Java Virtual Machine.
[WARNING] Error: A fatal exception has occurred. Program will exit.
Above the log stated, that I use a jdk-17.
How do I need to set the add-opens parameter ?
Do you see any other workaround?
The comment from Stuart solved my issue. Thanks a lot.
The following configuration worked for me:
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<moduleName>xxxxxxxx</moduleName>
<jvmArgs>
<jvmArg>-showversion</jvmArg>
<jvmArg>-Xmx2048M</jvmArg>
<jvmArg>--add-opens</jvmArg>
<jvmArg>java.base/java.util=ALL-UNNAMED</jvmArg>
</jvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

Maven pom.xml for MATLAB compiler project

I have a Tomcat servlet project that requires a MATLAB jar generated by mcc. I have implemented a mojo plugin (mcc-maven-plugin) that generates the jar. It simply takes the specifications from a pom and creates a MATLAB command of the form:
cd '/home/jeffemandel/webpropofolmm/matlab/src/main/matlab';mcc -W 'java:webpropofol_java,loadServlet' -d '/home/jeffemandel/webpropofolmm/matlab/target' class{loadServlet:loadServlet.m} class{locServlet:locServlet.m} class{testStruct:testStruct.m}
This generates the file /home/jeffemandel/webpropofolmm/matlab/target/webpropofol_java.jar
Note that target must exist for mcc to work.
I need this file in my main project, but it is resource-intensive to generate the jar every time I make a minor tweak to the UI (which has a small amount of Java and a lot of HTML, css, and javascript). My confusion point is how to generate a jar that doesn't depend on any Java code. Here is my pom.xml:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jeffmandel.webpropofol</groupId>
<artifactId>optimaltiva</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javabuilder</groupId>
<artifactId>javabuilder</artifactId>
<version>9.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jeffmandel</groupId>
<artifactId>mcc-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mcc</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<packageName>webpropofol_java</packageName>
<className>loadServlet</className>
<classes>
<loadServlet>loadServlet.m</loadServlet>
<locServlet>locServlet.m</locServlet>
<testStruct>testStruct.m</testStruct>
</classes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<groupId>org.jeffmandel.webpropofol</groupId>
<artifactId>optimaltiva</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${project.build.directory}/webpropofol_java.jar</file>
<generatePom>true</generatePom>
</configuration>
<executions>
<execution>
<id>install-jar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn compile, this is what I get:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< org.jeffmandel.webpropofol:optimaltiva >---------------
[INFO] Building optimaltiva 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # optimaltiva ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jeffemandel/webpropofolmm/matlab/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # optimaltiva ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-antrun-plugin:1.4:run (default) # optimaltiva ---
project.artifactId
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- mcc-maven-plugin:0.0.1-SNAPSHOT:mcc (default) # optimaltiva ---
[INFO] cd '/home/jeffemandel/webpropofolmm/matlab/src/main/matlab';mcc -W 'java:webpropofol_java,loadServlet' -d '/home/jeffemandel/webpropofolmm/matlab/target' class{loadServlet:loadServlet.m} class{locServlet:locServlet.m} class{testStruct:testStruct.m}
[INFO] Loading source files for package webpropofol_java...
Constructing Javadoc information...
Standard Doclet version 1.8.0_221
Building tree for all the packages and classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/loadServlet.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/loadServletRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/locServlet.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/locServletRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/testStruct.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/testStructRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/Webpropofol_javaMCRFactory.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-frame.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-summary.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-tree.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/constant-values.html...
Building index for all the packages and classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/overview-tree.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/index-all.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/deprecated-list.html...
Building index for all classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/allclasses-frame.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/allclasses-noframe.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/index.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/help-doc.html...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.215 s
[INFO] Finished at: 2020-12-12T22:26:54-05:00
[INFO] -----
The problem is that every time I run mvn compile it generates the jar, rather than seeing that the source files haven't changed so don't regenerate the jar. My ultimate goal is to have one project that contains the matlab and servlet.
I did some more reading and figured out that it was the responsibility of the mojo plugin to figure out whether recompilation was needed. MATLAB needs to rebuild the entire jar even if only a single file changes, so I added the following code to my mojo plugin:
import org.apache.commons.io.filefilter.AgeFileFilter;
import java.io.FileFilter;
File myJar = new File(outputDirectory + File.separator + packageName + ".jar");
AgeFileFilter myFilter = new AgeFileFilter(myJar, false);
File source = new File(sourceDirectory);
File[] files = source.listFiles((FileFilter) myFilter);
if (files.length==0) {
getLog().info("Project up to date");
} else {
...
}
This does the trick.

Custom unit test folder/path doesn't see custom src folder/path in Maven project when using terminal

I have a custom structure in my project of
Development -
- src
- test
and running tests works fine through eclipse but when I use the terminal on my mac to run the test (mvn test), the src classes are not found (fails during maven compile plugin). I figure it has to be an issue with my pom not guiding the plugins to the right folders. If I comment out this line,
<outputDirectory>Development/build</outputDirectory>
it works fine because the .class files r now being placed in the target folder. Instead of looking at the target folder for the.class files, I need maven to look at the
Development/build
directory if I'm not mistaken. Right?
I would like to continue to use my custom file structure and correct my pom so that it compiles and runs unit test through my mac's terminals.
<build>
<sourceDirectory>Development/src/main</sourceDirectory>
<testSourceDirectory>Development/src/test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<outputDirectory>Development/build</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>Development/build</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>Development/build</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>Development/src/assembly/assembly.xml</descriptor>
</descriptors>
<tarLongFileMode>posix</tarLongFileMode>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
This is the console output
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # weatherdetails ---
[INFO] Deleting /Users/username/git/weatherdetails/target
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (auto-clean) # weatherdetails ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # weatherdetails ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/username/git/weatherdetails/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # weatherdetails ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2503 source files to /Users/username/git/weatherdetails/Development/build
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # weatherdetails ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/username/git/weatherdetails/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # weatherdetails ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/username/git/weatherdetails/Development/build
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/username/git/weatherdetails/Development/src/test/com/wfc/schedulers/WeeklySchedulerTest.java:[12,26] cannot find symbol
symbol: class WeeklyScheduler
location: package com.wfc.schedulers
Any suggestions on what's not configured correctly?
I was able to get this work shortly after making this post but wanted to see if someone had a different answer. While formatting this post to meet the stackoverflow standards, I noticed the compiler plugin was writing the classes to /Users/username/git/weatherdetails/Development/build. i said wait thats wrong. it should write them to /Users/username/git/weatherdetails/Development/build/classes and /Users/username/git/weatherdetails/Development/build/test-classes. i googled how to change the target directory in the pom and ran into this tag
<directory>Development/build</directory>
I added it to the build and removed the
<outputDirectory>Development/build</outputDirectory>
tag from the compiler plugin because i added it there thinking that it was creating the custom target folder in the path. Ran it and it worked. So now my build looks like this
<build>
<sourceDirectory>Development/src/main</sourceDirectory>
<testSourceDirectory>Development/src/test</testSourceDirectory>
<!-- if you put just Development, it will erase everything in the development folder -->
<directory>Development/build</directory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>Development/build</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>Development/build</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors> <descriptor>Development/src/assembly/assembly.xml</descriptor>
</descriptors>
<tarLongFileMode>posix</tarLongFileMode>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
Hope this helps someone!

Errors when using maven plugin for Weblogic deployment

I have been trying to deploy application to Weblogic 10.3.6 using maven
I have created weblogic plugin for maven as mentioned in this article.
I have added the following to pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
<configuration>
<goalPrefix>weblogic</goalPrefix>
</configuration>
</plugin>
<plugin>
<groupId>weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.6.0</version>
<configuration>
<adminurl>t3://localdomain:7001</adminurl>
<user>weblogic</user>
<password>password</password>
<name>wldemo</name>
<remote>true</remote>
<upload>true</upload>
<targets>AdminServer</targets>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<source>target/EmployeesApp-1.0-SNAPSHOT.war</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I did mvn com.oracle.weblogic:weblogic-maven-plugin:deploy I am getting the following errors, how can I resolve these errors?
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:10.3.6.
0:deploy (default-cli) on project EmployeesApp: The parameters 'source' for goal
com.oracle.weblogic:weblogic-maven-plugin:10.3.6.0:deploy are missing or invali
d
You have specified the source parameter in the execution configuration, so in order to make it taken into account you should invoke this particular execution. It can be done using the phase key you specified, so e.g.:
mvn integration-test
Maven will go through the whole lifecycle and on the pre-integration-test test phase (which precedes the integration-test one) it will run the execution of weblogic-maven-plugin you configured.

Maven is not finding scala tests

I have a scala test class but when I attempt to run using the Maven goal 'test'
the tests are not being run. I receive the Maven message "There are no tests to run." even though the tests are located in the scala test class. Do I need to add extra configuration ?
Here is my package setup :
Here is the output of the Maven "test" goal when run against the pom file :
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building scala.maven.test 0.0.1-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.4.3:resources
(default-resources) # scala.maven.test --- [WARNING] Using platform
encoding (Cp1252 actually) to copy filtered resources, i.e. build is
platform dependent! [INFO] Copying 0 resource [INFO] [INFO] ---
maven-scala-plugin:2.9.1:add-source (scala-compile-first) #
scala.maven.test --- [INFO] Add Source directory:
C:\workspaces\29112012\scala.maven.test\src\main\scala [INFO] Add Test
Source directory:
C:\workspaces\29112012\scala.maven.test\src\test\scala [INFO] [INFO]
--- maven-scala-plugin:2.9.1:compile (scala-compile-first) # scala.maven.test --- [ERROR]
C:\workspaces\29112012\scala.maven.test\src\main\java [ERROR]
C:\workspaces\29112012\scala.maven.test\src\main\scala [ERROR]
C:\workspaces\29112012\scala.maven.test\src\test\scala [INFO]
Compiling 2 source files to
C:\workspaces\29112012\scala.maven.test\target\classes [INFO] [INFO]
--- maven-compiler-plugin:2.0.2:compile (default-compile) # scala.maven.test --- [INFO] Nothing to compile - all classes are up to
date [INFO] [INFO] --- maven-compiler-plugin:2.0.2:compile (default)
# scala.maven.test --- [INFO] Nothing to compile - all classes are up
to date [INFO] [INFO] --- maven-resources-plugin:2.4.3:testResources
(default-testResources) # scala.maven.test --- [WARNING] Using
platform encoding (Cp1252 actually) to copy filtered resources, i.e.
build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO]
--- maven-scala-plugin:2.9.1:testCompile (scala-test-compile) # scala.maven.test --- [ERROR]
C:\workspaces\29112012\scala.maven.test\src\test\java [ERROR]
C:\workspaces\29112012\scala.maven.test\src\test\java..\scala [INFO]
Compiling 1 source files to
C:\workspaces\29112012\scala.maven.test\target\test-classes [INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile
(default-testCompile) # scala.maven.test --- [INFO] Nothing to compile
- all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.7.1:test (default-test) # scala.maven.test ---
[INFO] Surefire report directory:
C:\workspaces\29112012\scala.maven.test\target\surefire-reports
------------------------------------------------------- T E S T S
------------------------------------------------------- There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO]
------------------------------------------------------------------------ [INFO] Total time: 11.354s [INFO] Finished at: Fri Nov 30 16:57:05 GMT
2012 [INFO] Final Memory: 7M/17M [INFO]
Here is my pom.xml :
<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>scala.maven.test</groupId>
<artifactId>scala.maven.test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.9.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.scala-tools
</groupId>
<artifactId>
maven-scala-plugin
</artifactId>
<versionRange>
[2.9.1,)
</versionRange>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.0-1</artifactId>
<version>2.0.M5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
Even though this is a very late reply, but I wrote it hoping that someone might get benefitted from it in case their scala unit test are not getting discovered. One of the major and silent culprit is the absolute path to the test classes. If there is a space in the name of any directory on the path, scalatest won't pick it up. Rename such directories for successful running of unit tests.
What's your test class name? Maven can be pretty picky and by default I think it requires the class name to end in 'Test'.
See my previos post:
Maven won't run tests