How to prevent building if integration test was failed? - java

I've got the following test:
public class AppITCase
{
#Test
public void failTest() {
fail();
}
}
It just fails. But if I run mvn clean test-compile failsafe:integration-test, I will see this:
Results :
Failed tests:
AppITCase.failTest:16
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[WARNING] File encoding has not been set, using platform encoding Cp1251, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.853 s
[INFO] Finished at: 2017-01-14T01:32:16+04:00
[INFO] Final Memory: 11M/141M
Important lines:
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS [INFO]
What? Why maven accepted this build, if it had test failures? How to solve this?
UPD
If I run mvn verify
[INFO] Scanning for projects...
[INFO]
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # vsjws-samples ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # vsjws-samples ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.333 s
[INFO] Finished at: 2017-01-14T01:41:23+04:00
[INFO] Final Memory: 15M/200M
[INFO] ------------------------------------------------------------------------

Related

Eclipse Leshan LwM2M Build Failure

I am currently getting myself into the LwM2M topic and I tried the leshan project from eclipse.
I followed the README.md on https://github.com/eclipse/leshan. The standalone demos are working fine, but when I try to build the project with "mvn clean install" I get the following log/error:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] leshan [pom]
[INFO] leshan - core [bundle]
[INFO] leshan - core californium [bundle]
[INFO] leshan - server core [bundle]
[INFO] leshan - server californium [bundle]
[INFO] leshan - server redis [bundle]
[INFO] leshan - client core [bundle]
[INFO] leshan - client californium [bundle]
[INFO] leshan - integration tests [jar]
[INFO] leshan - server demo [jar]
[INFO] leshan - client demo [jar]
[INFO] leshan - bootstrap server demo [jar]
[INFO]
[INFO] ---------------------< org.eclipse.leshan:leshan >----------------------
[INFO] Building leshan 2.0.0-SNAPSHOT [1/12]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # leshan ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # leshan ---
[INFO]
[INFO] >>> maven-source-plugin:3.2.1:jar (attach-sources) > generate-sources # leshan >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # leshan ---
[INFO]
[INFO] <<< maven-source-plugin:3.2.1:jar (attach-sources) < generate-sources # leshan <<<
[INFO]
[INFO]
[INFO] --- maven-source-plugin:3.2.1:jar (attach-sources) # leshan ---
[INFO]
[INFO] --- revapi-maven-plugin:0.11.2:check (default) # leshan ---
[INFO] Comparing [org.eclipse.leshan:leshan:pom:1.0.0] against [org.eclipse.leshan:leshan:pom:2.0.0-SNAPSHOT] (including their transitive dependencies).
[INFO] API checks completed without failures.
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # leshan ---
[INFO] Installing C:\Users\Jonas\Desktop\leshan\leshan\pom.xml to C:\Users\Jonas\.m2\repository\org\eclipse\leshan\leshan\2.0.0-SNAPSHOT\leshan-2.0.0-SNAPSHOT.pom
[INFO]
[INFO] -------------------< org.eclipse.leshan:leshan-core >-------------------
[INFO] Building leshan - core 2.0.0-SNAPSHOT [2/12]
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # leshan-core ---
[INFO] Deleting C:\Users\Jonas\Desktop\leshan\leshan\leshan-core\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # leshan-core ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # leshan-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # leshan-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 162 source files to C:\Users\Jonas\Desktop\leshan\leshan\leshan-core\target\classes
[INFO]
[INFO] --- animal-sniffer-maven-plugin:1.18:check (default) # leshan-core ---
[INFO] Checking unresolved references to net.sf.androidscents.signature:android-api-level-19:4.4.2_r4
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # leshan-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Jonas\Desktop\leshan\leshan\leshan-core\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # leshan-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 17 source files to C:\Users\Jonas\Desktop\leshan\leshan\leshan-core\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) # leshan-core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.eclipse.leshan.core.util.X509CertUtilTest
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.152 s - in org.eclipse.leshan.core.util.X509CertUtilTest
[INFO] Running org.eclipse.leshan.core.json.JsonSerializerTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in org.eclipse.leshan.core.json.JsonSerializerTest
[INFO] Running org.eclipse.leshan.core.node.codec.LwM2mNodeDecoderTest
[INFO] Tests run: 50, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.084 s - in org.eclipse.leshan.core.node.codec.LwM2mNodeDecoderTest
[INFO] Running org.eclipse.leshan.senml.SenMLJsonSerDesTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 s - in org.eclipse.leshan.senml.SenMLJsonSerDesTest
[INFO] Running org.eclipse.leshan.core.LinkObjectTest
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 s - in org.eclipse.leshan.core.LinkObjectTest
[INFO] Running org.eclipse.leshan.core.datatype.NumberUtilTest
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 s - in org.eclipse.leshan.core.datatype.NumberUtilTest
[INFO] Running org.eclipse.leshan.core.node.LwM2MResourceTest
[INFO] Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in org.eclipse.leshan.core.node.LwM2MResourceTest
[INFO] Running org.eclipse.leshan.core.attributes.AttributeSetTest
[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 s - in org.eclipse.leshan.core.attributes.AttributeSetTest
[INFO] Running org.eclipse.leshan.core.json.JsonDeserializerTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 s - in org.eclipse.leshan.core.json.JsonDeserializerTest
[INFO] Running org.eclipse.leshan.core.node.codec.LwM2mNodeEncoderTest
[INFO] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.056 s - in org.eclipse.leshan.core.node.codec.LwM2mNodeEncoderTest
[INFO] Running org.eclipse.leshan.core.tlv.TlvEncoderTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.233 s - in org.eclipse.leshan.core.tlv.TlvEncoderTest
[INFO] Running org.eclipse.leshan.core.attributes.AttributeTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 s - in org.eclipse.leshan.core.attributes.AttributeTest
[INFO] Running org.eclipse.leshan.core.tlv.TlvDecoderTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.23 s - in org.eclipse.leshan.core.tlv.TlvDecoderTest
[INFO] Running org.eclipse.leshan.senml.SenMLCborSerializerTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 s - in org.eclipse.leshan.senml.SenMLCborSerializerTest
[INFO] Running org.eclipse.leshan.core.model.ValidateModelsTest
SLF4J: A number (64) of logging calls during the initialization phase have been intercepted and are
SLF4J: now being replayed. These are subject to the filtering rules of the underlying logging system.
SLF4J: See also http://www.slf4j.org/codes.html#replay
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.722 s - in org.eclipse.leshan.core.model.ValidateModelsTest
[INFO] Running org.eclipse.leshan.core.VersionTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in org.eclipse.leshan.core.VersionTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 144, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-bundle-plugin:4.0.0:bundle (default-bundle) # leshan-core ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for leshan 2.0.0-SNAPSHOT:
[INFO]
[INFO] leshan ............................................. SUCCESS [ 2.751 s]
[INFO] leshan - core ...................................... FAILURE [ 11.822 s]
[INFO] leshan - core californium .......................... SKIPPED
[INFO] leshan - server core ............................... SKIPPED
[INFO] leshan - server californium ........................ SKIPPED
[INFO] leshan - server redis .............................. SKIPPED
[INFO] leshan - client core ............................... SKIPPED
[INFO] leshan - client californium ........................ SKIPPED
[INFO] leshan - integration tests ......................... SKIPPED
[INFO] leshan - server demo ............................... SKIPPED
[INFO] leshan - client demo ............................... SKIPPED
[INFO] leshan - bootstrap server demo ..................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.145 s
[INFO] Finished at: 2020-11-11T14:33:16+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:4.0.0:bundle (default-bundle) on project leshan-core: Execution default-bundle of goal org.apache.felix:maven-bundle-plugin:4.0.0:bundle failed.: ConcurrentModificationException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :leshan-core
The steps I did were:
cd desktop/leshan //The folder were i wanted to install it
git clone https://github.com/eclipse/leshan.git
mvn clean install
Fix attempts:
Read online much stuff about it but I didnt found anything specific. People suggested deleting the repository in User/.m2 but it didnt work for me.
And to be honest I have no clue whats going on, I am new to this. I would appreciate any help.
mvn -v:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3\bin\..
Java version: 15.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-15.0.1
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Thanks in advance!
Jonas
I continued researching on my own and Java 15 is the problem.
If anyone has the same problem as i had just switch to Java 11 and run the build as described. It worked fine for me.
If you have any other problems I suggest that you also post your questions, concerning leshan lwm2m, on https://github.com/eclipse/leshan/issues.
Jonas
EDIT:
You can also do it with Java 15. You have to change the pom.xml document.
Change in line 456 the version from 4.0.0 to 5.1.1 .
This was a build issue which is now fixed using a most recent version of maven-bundle-plugin.
(See https://github.com/eclipse/leshan/issues/927 for more details)
This was fixed :
in master branch (since commit 70e218d8)
in 1.x branch (since commit 04c93a0b)

My test doesn't output in console I'm using Maven

I'm new to Maven and Im facing this kind of of weird stuff Im using Intellij.
class HelloWorldTest {
public void testHello() {
System.out.println("Test - hello! ");
}
public void testWorld() {
System.out.println("Test - World!");
}
}
When I run package on Default Lifecycle It show's output below Test run: 0. The test isn't running and output in console. I'm Following tutorial Apache Maven Beginner to Guru on udemy.
[INFO] ------------------< guru.springframework:hello-world >------------------
[INFO] Building hello-world 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (auto-clean) # hello-world ---
[INFO] Deleting /home/jericho/Documents/spring-projects/hello-world/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # hello-world ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # hello-world ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/jericho/Documents/spring-projects/hello-world/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # hello-world ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jericho/Documents/spring-projects/hello-world/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # hello-world ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/jericho/Documents/spring-projects/hello-world/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # hello-world ---
[INFO] Surefire report directory: /home/jericho/Documents/spring-projects/hello-world/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
**Tests run: 0, Failures: 0, Errors: 0, Skipped: 0**
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # hello-world ---
[INFO] Building jar: /home/jericho/Documents/spring-projects/hello-world/target/hello-world-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.044 s
[INFO] Finished at: 2020-10-10T16:57:23+08:00
[INFO] ------------------------------------------------------------------------
Your test didn’t run:
Results :
**Tests run: 0, Failures: 0, Errors: 0, Skipped: 0**
You need to annotate your test class with #Test. And you should consult the JUnit manual

Testing a single package skips parametrized tests in TestNG

Overall description
I have a simple Maven project with a parameterized TestNG test. The parameter is specified through a suite XML file. When I run tests for the whole project, the suite XML file is read, parameter is used and the parameterized test is executed. However, when I attempt to test a single package only, then the suite XML file is not used apparently and the test is skipped with a complaint such as "Parameter '...' is required by #Test on method ... but has not been marked #Optional or defined". The question is how to run individual tests and test packages with parameters.
For more details see below.
Testing the whole project
This works as expected. Two test methods are executed. One test method is parameterless, other is parameterized and the parameter value is taken from the suite XML file. This is a equivalent of Run\Test project in NetBeans.
C:\Users\Andrew\Documents\NetBeansProjects\TestNGDemo>"c:\Program Files\NetBeans 8.2\java\maven\bin\mvn" test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestNGDemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # TestNGDemo ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # TestNGDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # TestNGDemo ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Andrew\Documents\NetBeansProjects\TestNGDemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # TestNGDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) # TestNGDemo ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
testGetChangedString
getTrue
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.844 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.702s
[INFO] Finished at: Wed Jun 06 23:42:20 ACST 2018
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
C:\Users\Andrew\Documents\NetBeansProjects\TestNGDemo>
Testing a single package
In this case only one test method runs, the parameterless one. The parameterized test method is skipped. This is a equivalent of right-clicking a package in NetBeans and selecting "Test package".
C:\Users\Andrew\Documents\NetBeansProjects\TestNGDemo>"c:\Program Files\NetBeans 8.2\java\maven\bin\mvn" test -Dtest=com.endersoft.testngdemo.**.*
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestNGDemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # TestNGDemo ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # TestNGDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # TestNGDemo ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Andrew\Documents\NetBeansProjects\TestNGDemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # TestNGDemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) # TestNGDemo ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.endersoft.testngdemo.SimpleClassNGTest
getTrue
[WARNING] Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 2.422 s - in com.endersoft.testngdemo.SimpleClassNGTest
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 2, Failures: 0, Errors: 0, Skipped: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.268s
[INFO] Finished at: Wed Jun 06 23:47:28 ACST 2018
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
Project source
The zipped project source can be downloaded from here (very small)
You need separate XML files for separate package. When running TestNG with package as parameter, TestNG is not automatically aware about the XML file, like it doesn't exist.
So you have multiple options, specify the parameters in properties file, or hardcode them, or create separate XML files for every package that you can then pass as parameter.

Spring Roo 2.0.0M2 sample script home page & tomcat issues

I'm testing the sample script at Spring Roo 2.0.0M2 released. The script generates well, but when issueing mvn tomcat:run it breaks.
In the end there is no local website.
How to solve this to get the project running?
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building foo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile # foo >>>
[INFO]
[INFO] --- apt-maven-plugin:1.1.3:process (default) # foo ---
[INFO]
[INFO] --- aspectj-maven-plugin:1.8:compile (default) # foo ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] incorrect classpath: D:\Tools\maven_repo\org\springframework\roo\org.springframework.roo.annotations\2.0.0.M2\org.springframework.roo.annotations-2.0.0.M2.pom
<unknown source file>:<no line information>
[INFO]
[INFO] --- aspectj-maven-plugin:1.8:test-compile (default) # foo ---
[WARNING] No sources found skipping aspectJ compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # foo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 62 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # foo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) < compile # foo <<<
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) # foo ---
[INFO] Skipping non-war project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.312 s
[INFO] Finished at: 2016-05-27T12:54:41+02:00
[INFO] Final Memory: 43M/602M
[INFO] ------------------------------------------------------------------------
Remember that Spring Roo 2.x generates Spring Boot applications. It includes some starters on your pom.xml file that provides you an embedded tomcat server. Also, your generated project includes the spring-boot-maven-plugin that allows you to run your application executing the following maven command:
mvn clean compile spring-boot:run
For more information about Spring Boot project read the official documentation
Hope this helps,

Java Runtime.getRuntime().exec looses/changes some parameters

( -Dexec.mainClass=maven.MainClass becomes maven.MainClass. )
When executing Java class using maven from within Java (Eclipse plugin actualy)
-Dexec.mainClass=maven.MainClass becomes maven.MainClass
package maven;
public class MainClass {
public static void main(String[] args) {
System.out.println("app is running!");
}
}
from Eclipse using
Process p = DebugPlugin.exec(cmds, workingPath, envp);
RuntimeProcess process = (RuntimeProcess)DebugPlugin.newProcess(launch, p, MavenConstants.PROCESS_MESSAGE);
that p= Runtime.getRuntime().exec(cmdLine, envp); just calls Java
p= Runtime.getRuntime().exec(cmdLine, envp);
And array of strings that concatenated looks like string below, somehow looses -Dexec.mainClass= part.
D:\Code\springsource\3.0\apache-maven-3.0.3\bin\mvn.bat compile exec:java -Dexec.mainClass=maven.MainClass
output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building org.example.maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.672s
[INFO] Finished at: Fri Jan 24 23:59:50 CST 2014
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "maven.MainClass". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
but from cmd shell using mvn or full filename is OK
D:\Progs\Enide-Monster-08-kepler-win32\runtime-EclipseApplication\org.example.maven>mvn compile exec:java -Dexec.mainClass=maven.MainClass
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building org.example.maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # org.example.maven ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # org.example.maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven ---
app is running!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.342s
[INFO] Finished at: Fri Jan 24 23:56:41 CST 2014
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
D:\Progs\Enide-Monster-08-kepler-win32\runtime-EclipseApplication\org.example.maven>D:\Code\springsource\3.0\apache-maven-3.0.3\bin\mvn.bat compile exec:java -Dexec.mainClass=maven
.MainClass
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building org.example.maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # org.example.maven ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # org.example.maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # org.example.maven ---
app is running!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.435s
[INFO] Finished at: Fri Jan 24 23:57:46 CST 2014
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
Found that cmdLine.add("-Dmaven.test.skip=true"); also becomes just true with similar error.
I notices no mention in JavaDoc of this behavior for Runtime.getRuntime().exec(
Solved by putting all option in one string.
cmdLine.add(mavenPath);
cmdLine.add(mavenOptions+" compile exec:java -Dexec.mainClass="+packageClass);

Categories