I am using IntelliJ IDE. My project is maven project. What is bothering me is that when for example choose "Install" phase from Maven Toolbar and click "Run Maven Build",
the clean phase is not executed:
"C:\Program Files\Java\jdk-9.0.1\bin\java" -Dmaven.multiModuleProjectDirectory=A:\custom_software_projects\IdeaProjects\power_management "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\lib\idea_rt.jar=53577:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.3.2 install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building power_server 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # power_server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # power_server ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # power_server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory A:\custom_software_projects\IdeaProjects\power_management\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # power_server ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # power_server ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # power_server ---
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default) # power_server ---
[INFO] Building jar: A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO]
[INFO] --- maven-dependency-plugin:3.0.2:unpack-dependencies (unpack-sigar) # power_server ---
[INFO] log4j:log4j:jar:1.2.17 already exists in destination.
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # power_server ---
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT.jar to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT.jar
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\pom.xml to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT.pom
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO]
[INFO] --- maven-antrun-plugin:1.4:run (Copying jar-with-dependecnies and fixing LF in .sh scripts) # power_server ---
project.artifactId
[INFO] Executing tasks
[copy] Copying 1 file to A:\custom_programs\power_server
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.291 s
[INFO] Finished at: 2018-02-10T21:42:17+02:00
[INFO] Final Memory: 17M/56M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
So, as you see the first step taken is maven-resources-plugin:2.6:resources. From what I understood from maven docs is that when we specify a phase all previous phases are executed up to the chosen one. Per maven doc:
This command executes each default life cycle phase in order (validate, compile, package, etc.), before executing install. You only need to call the last build phase to be executed, in this case, install
Why is it skipping the clean and validate phases?
Edit:
I also have the clean phase in the Run Configuration section, but the result is the same:
Maven has 3 different builtin lifecycles
There are three built-in build lifecycles: default, clean and site.
install is part of the default lifecycle and there is no reason for clean to execute when you do install.
As to validate it has no built in binding as you can see here which means that it's not going to execute:
Furthermore, a build phase can also have zero or more goals bound to it. If a build phase has no goals bound to it, that build phase will not execute.
The default lifecycle does not include clean in it. Check the docs
Quote:
For example, the default lifecycle comprises of the following phases
(for a complete list of the lifecycle phases, refer to the Lifecycle
Reference):
validate - validate the project is correct and all necessary
information is available
compile - compile the source code of the
project
test - test the compiled source code using a suitable unit
testing framework. These tests should not require the code be packaged
or deployed
package - take the compiled code and package it in its
distributable format, such as a JAR.
verify - run any checks on
results of integration tests to ensure quality criteria are met
install - install the package into the local repository, for use as a
dependency in other projects locally
deploy - done in the build
environment, copies the final package to the remote repository for
sharing with other developers and projects.
Also, the validate phase is not associated with the default lifecycle of packaging .jar files.
Check the Default Lifecycle Bindings for JAR files at the bottom of the docs
Related
Title is pretty self explanatory, I've downloaded the non-modular maven sample code for JavaFX from OpenJFX (from here) and I can't run it.
It compiles without any error but when I try to run it I get this error
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.openjfx:hellofx >-------------------------
[INFO] Building hellofx 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> javafx-maven-plugin:0.0.6:run (default-cli) > process-classes # hellofx >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # hellofx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # hellofx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< javafx-maven-plugin:0.0.6:run (default-cli) < process-classes # hellofx <<<
[INFO]
[INFO]
[INFO] --- javafx-maven-plugin:0.0.6:run (default-cli) # hellofx ---
[INFO] Toolchain in javafx-maven-plugin null
[ERROR] Command execution failed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.691 s
[INFO] Finished at: 2022-12-07T08:56:47+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.6:run (default-cli) on project hellofx: Error: Command execution failed. Cannot run program "java" (in directory "/home/johan/Desktop/hellofx"): error=2, No such file or directory -> [Help 1]
Any idea is appreciated as I don't even understand the Cannot run program Java part.
I ran the javafx:compile then the javafx:run in Maven.
Ensure your JAVA_HOME environmental variable is set correctly. This will allow the javafx-maven-plugin to find the correct java command needed to run your application.
Follow this guide, choosing the relevant section for your OS:
Set JAVA_HOME on Windows 7, 8, 10, Mac OS X, Linux
Also, use the current version of the maven JavaFX plugin, 0.0.8, though that is not your core issue.
I have a project where its structure is multi-module then IntelliJ testing with coverage doesn't work, and maven clean install also fails in the install phase where it runs tests. When the project is a single module project everything works just fine.
The project with single module can be found here, multi-module version here.
The error output says the following. Yes, it is a compilation error which I don't understand. Why mvn clean test works (stuff needed to be on the path) and why mvn clean install doesn't. The debug output in both cases says that all the stuff is added tot he path.
I know my approach to split the app to small pieces (interfaces, implementations, tests, and when it comes then exceptions) might be overengineered. However shovel everything into a single module is just a mess for me.
[INFO] Building repositories.tests 1.0.0-SNAPSHOT
[13/16] [INFO] --------------------------------[ jar
]--------------------------------- [INFO] [INFO] ---
maven-clean-plugin:3.2.0:clean (default-clean) # repositories.tests
--- [INFO] Deleting /Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/target
[INFO] [INFO] --- maven-resources-plugin:3.2.0:resources
(default-resources) # repositories.tests --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to
copy filtered properties files. [INFO] skip non existing
resourceDirectory
/Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/main/resources
[INFO] skip non existing resourceDirectory
/Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/main/resources
[INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile
(default-compile) # repositories.tests --- [INFO] No sources to
compile [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources
(default-testResources) # repositories.tests --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to
copy filtered properties files. [INFO] skip non existing
resourceDirectory
/Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/test/resources
[INFO] [INFO] --- maven-compiler-plugin:3.10.1:testCompile
(default-testCompile) # repositories.tests --- [INFO] Changes detected
recompiling the module! [INFO] Compiling 2 source files to /Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] /Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/test/java/com/encyclopediagalactica/sourceformats/repositories/sourceformat/SaveTests.java:[5,47]
cannot find symbol symbol: class SourceFormatServiceApplication
location: package com.encyclopediagalactica.sourceformats [ERROR]
/Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/test/java/com/encyclopediagalactica/sourceformats/repositories/sourceformat/FindAllTests.java:[16,54]
cannot find symbol symbol: class SourceFormatServiceApplication
location: package com.encyclopediagalactica.sourceformats [ERROR]
/Users/andrascsanyi/DEV/github.com/EncyclopediaGalactica/EG/repositories.tests/src/test/java/com/encyclopediagalactica/sourceformats/repositories/sourceformat/SaveTests.java:[15,33]
cannot find symbol symbol: class SourceFormatServiceApplication
[INFO] 3 errors [INFO]
------------------------------------------------------------- [INFO] ------------------------------------------------------------------------
Apologies if this is an obvious issue but my primary background isn't Java and it seems like I am doing something wrong. When I make changes to my source code I run mvn package to update this and produce a .jar.
Currently this command takes an average of 25 seconds each time, the device compiling it has 8 cores with 16 GB of RAM, so I can't see it being the performance of the machine.
What can I change to speed up my build times?
I've tried using multiple threads with mvn package, it doesn't seem to make any difference.
Here is the output log
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.eu.habbo:Habbo:jar:2.4.0
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.google.code.gson:gson:jar -> duplicate declaration of version 2.8.6 # line 173, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -------------------------< com.eu.habbo:Habbo >-------------------------
[INFO] Building Habbo 2.4.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Habbo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # Habbo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1799 source files to C:\Users\ash\Documents\roleplay-emulator\target\classes
[WARNING] /C:/Users/ash/Documents/roleplay-emulator/src/main/java/com/eu/habbo/Emulator.java:[22,52] com.sun.org.apache.xpath.internal.operations.Bool is internal proprietary API and may be removed in a future release
[INFO] /C:/Users/ash/Documents/roleplay-emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java: Some input files use or override a deprecated API.
[INFO] /C:/Users/ash/Documents/roleplay-emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java: Recompile with -Xlint:deprecation for details.
[INFO] /C:/Users/ash/Documents/roleplay-emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java: Some input files use unchecked or unsafe operations.
[INFO] /C:/Users/ash/Documents/roleplay-emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Habbo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\ash\Documents\roleplay-emulator\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # Habbo ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Habbo ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # Habbo ---
[INFO] Building jar: C:\Users\ash\Documents\roleplay-emulator\target\Habbo-2.4.0.jar
[INFO]
[INFO] --- maven-assembly-plugin:3.3.0:single (make-assembly) # Habbo ---
[INFO] Building jar: C:\Users\ash\Documents\roleplay-emulator\target\Habbo-2.4.0-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.837 s
[INFO] Finished at: 2020-10-26T06:15:39Z
[INFO] ------------------------------------------------------------------------
C:\Users\ash\Documents\roleplay-emulator>
The bottleneck seems to be in these lines here,
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1799 source files to C:\Users\ash\Documents\roleplay-emulator\target\classes
This is a normal amount of time.
I does not bother me a lot because why I work, Eclipse compiles the files in the background and I can see compile errors immediately. Also running JUnit tests through Eclipse works fine.
I only run Maven when I need the complete artifact.
I am migrating an existing project to boot. I created a brand new project using start.spring.io and copied over the source code, etc. Everything compiles, but when I do a 'mvn test' it compiles the classes but then only executes the default 'ApplicationTests' (created by start.spring.io).
Here's an excerpt from the maven output:
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # pendview ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\dev\pendview2\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # pendview ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to C:\dev\pendview2\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) # pendview ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
What's even stranger is that if I pass '-Dtest=TestAuthController' then it does run that specific unit test:
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # pendview ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to C:\dev\pendview2\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) # pendview ---
[INFO] Surefire report directory: C:\dev\pendview2\target\surefire-reports
(skipped output of AuthControllerTest for brevity)
-------------------------------------------------------
T E S T S
-------------------------------------------------------Results :
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
What am I doing wrong? Does spring boot setup a surefire config that I'm not conforming to?
Any help would be greatly appreciated!
-Trey
Spring Boot configures the Surefire plugin to run all test classes that have a name ending with Test or Tests but not starting with Abstract. You can see this configuration in the spring-boot-starter-parent pom. If your test class is named TestAuthController then it doesn't match this configuration. Renaming it to AuthControllerTest or AuthControllerTests should fix your problem.
Seems for me there is some issue with Maven surefire plugin, when it doesn't detect tests, if your test class name doesn't end with Tests suffix. :-)
Try this command in your console/terminal:
mvn clean install
But first navigate to directory of your tests.
If you wish to skip tests use this command:
mvn clean install -Dmaven.test.skip
It seems Andy's answer should be updated for Spring Boot 2.X. I can't see surefire config anywhere now. Probably there were too many complains about this convention.
Short summary: GWT compilation is running fine as part of a Bamboo plan, but the generated nocache.js contains the (re)compile message.
I'm running into a little trouble lately while changing the way the application is compiled and deployed.
Configuration:
- GWT 2.4.0
- Maven GWT plugin
- Bamboo
Running a GWT compilation on my machine everything is performing normally, can run both in dev mode and js mode.
Running a maven compilation (through eclipse - maven - run as - package) performs fine, nocache.js looks fine.
Running a command-line maven compilation on an XP machine or with a Solaris+Bamboo yields a wrong nocache.js, even though the generated htmls look ok. In fact, the *.cache.html are identical to the ones on my machine.
So the module.nocache.js on my machine contains the correct references to the uniquely named html files while the nocache.js on the affected machines(?) does not contain any such references.
GWT compiler launch options are identical on all machines. Target and war folders were cleaned on all machines.
A summary of the plan:
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # myproject ---
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # myproject ---
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # myproject ---
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # myproject ---
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # myproject ---
[INFO] --- gwt-maven-plugin:2.4.0:compile (default) # myproject ---
[INFO] Compilation succeeded -- 639,969s
[INFO] --- maven-war-plugin:2.2:war (default-war) # myproject ---
[INFO] Packaging webapp
[INFO] Assembling webapp [myproject] in [.....\myproject\target\myproject-2.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [....\myproject\war]
[INFO] Webapp assembled in [14125 msecs]
[INFO] Building war: .....\myproject\target\myproject-2.0-SNAPSHOT.war
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (attach-sources) # myproject ---
[INFO] --- gwt-maven-plugin:2.4.0:test (default) # myproject ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # myproject ---
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # myproject ---
Locally, in Eclipse, I've closed all projects except the one I'm compiling so all the dependencies are retrieved via maven. Eclipse is signalling a lot of error but I'm running from eclipse the maven goals clean and install and the result is again fine.
The resulting nocache.js files have the same time as the compilation time, they are not retrieved or left-over.
I'm stumped, somehow on the Bamboo machine the Maven GWT compile plugin has decided by its own to compile for development, I assume.
L.E.
Additional info, Bamboo build log. It seems to be using the standard linker and it looks the same as on the local machine:
build 06-Aug-2012 20:18:35 [INFO] Permutation 0 (strong name F96236D63A05E1D33308D4FE26EDA9F9) has an initial download size of 4937614 and total script size of 4937614
build 06-Aug-2012 20:18:35 [INFO] Invoking Linker RPC policy file manifest
build 06-Aug-2012 20:18:35 [INFO] Invoking Linker Standard
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker RPC log linker
build 06-Aug-2012 20:18:36 [INFO] Emitting RPC log files
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Export CompilationResult symbol maps
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Emit compile report artifacts
build 06-Aug-2012 20:18:36 [INFO] Permutation 1 (strong name B836CC45CC0786F0D04CEA25F7204F39) has an initial download size of 5220544 and total script size of 5220544
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker RPC policy file manifest
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Standard
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker RPC log linker
build 06-Aug-2012 20:18:36 [INFO] Emitting RPC log files
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Export CompilationResult symbol maps
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Emit compile report artifacts
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker RPC policy file manifest
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Standard
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker RPC log linker
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Export CompilationResult symbol maps
build 06-Aug-2012 20:18:36 [INFO] Invoking Linker Emit compile report artifacts
build 06-Aug-2012 20:18:36 [INFO] Linking Public artifacts into ....-SNAPSHOT
build 06-Aug-2012 20:18:36 [INFO] Linking Deploy artifacts into ....-SNAPSHOT/WEB-INF/deploy
Solved it, it was a nocache.js file that was commited some time ago by mistake. Because of it, the new nocache.js never got generated or did not overwrite it.
Not exactly sure on the details of how this happened but I will not investigate further, I'm adding this only for future reference.