Maven: 'mvn package' taking 30 seconds for one file change? - java

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.

Related

cygwin introduces spaces in the console output when running a maven build for a java project in windows 10

Check the following output fragment from a cygwin64 terminal on windows 10 64bit while running a maven 3 build using java 1.8:
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\proj\t020-domain\src\ test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # t020-domain ---
m
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source f iles to C:\proj\t020-domain\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # t020-domain ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) # t020-domain ---
[INFO] Building jar: C:\proj\t020-domain\target\t020-domain-80.1-SNAPSHOT.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.4:prepare-agent-integration (default-prepare-agent-integration) #
36mt020-domain ---
[INFO] argLine set to -javaagent:C:\\Users\\VBO07\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.4\\org.jacoco.agent-0
.8.4-runtime.jar=destfile=C:\\proj\\t020-domain\\target\\jacoco-it.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.2:integration-test (default) # t020-domain ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.2:verify (default) # t020-domain ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.4:report (default- report) # t020-domain ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.4:report-integration (def ault-report-integration) # t020-domain
---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.4:check (default-check) # t020-domain ---
[INFO] Skipping JaCoCo execution due to mi ssing execution data file:C:\proj\t020-domain\target\jacoco.exec
You can see it clearly happening on the lines:
[INFO] skip non existing resourceDirectory C:\proj\t020-domain\src\ test\resources
and
[INFO] Compiling 2 source f iles to C:\proj\t020-domain\target\test-classes
and
[INFO] --- jacoco-maven-plugin:0.8.4:report (default- report) # t020-domain ---
and
[INFO] --- jacoco-maven-plugin:0.8.4:report-integration (def ault-report-integration) # t020-domain
and
[INFO] Skipping JaCoCo execution due to mi ssing execution data file:C:\proj\t020-domain\target\jacoco.exec
How can I fix this?
Thank you.
After posting this problem on cygwin's website, Marco Atzeri gave a solution that works for me: set in windows's environment variables:
CYGWIN="disable_pcon"
Then, obviously, restart cygwin.
EDIT:
The above solution has a big bad side-effect: if you need to run interactive commands with cmd /C, then the then above flag will kill the interactions (waiting for input for example will not work anymore). A better solution that does not have this problem was posted by Takashi Yano on cygwin as answer to my question: replace the jar jansi-1.17.1.jar in the lib folder of maven with jansi-2.1.1.jar. You can download the 2.1.1 version from https://mvnrepository.com/artifact/org.fusesource.jansi/jansi/2.1.1

openshift eclipse publish stuck

I tried to publish my java /spring boot app to openshift cloud platform via eclipse openshift plugin and it stucks at 'Preparing build for deployment'. For to be sure I waited for all day but there were no changes.
restarting the app and cleaning it did not worked
Is there any way to solve this, or any other way to deploy my spring boot app to openshift by using ssh connection etc...
here is console output:
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # site ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1406 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # site ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 13 source files to /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/target/classes
[WARNING] /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/src/main/java/org/site/models/AnasayfaDuzen.java: /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/src/main/java/org/site/models/AnasayfaDuzen.java uses or overrides a deprecated API.
[WARNING] /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/src/main/java/org/site/models/AnasayfaDuzen.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # site ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # site ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # site ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) # site ---
[INFO] Packaging webapp
[INFO] Assembling webapp [site] in [/var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/target/site]
[INFO] Processing war project
[INFO] Webapp assembled in [10915 msecs]
[INFO] Building war: /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/webapps/ROOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.1.RELEASE:repackage (default) # site ---
[INFO] Replacing main artifact webapps/ROOT.war to /var/lib/openshift/581b33a789f5cf45fd000026/app-root/runtime/repo/target/site.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.136s
[INFO] Finished at: Thu Dec 15 01:22:27 EST 2016
[INFO] Final Memory: 25M/170M
[INFO] ------------------------------------------------------------------------
Preparing build for deployment
thanks for any help
Have you tried checking your log files for further information about the problem that you are having?
You can check your log files by using the rhc tail command, or by sshing into your application and looking in the ~/app-root/logs directory.
You can learn more about checking your log files in our Developer Portal

Maven with Java play 2 framework: Server not starting

I have a java play 2 project that i'm trying to run using maven. I added the play2-maven-plugin to my pom.xml.
When I try to run the following command mvn clean compile play2:run, I get the following:
```
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my_project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # my_project ---
[INFO] Deleting /Users/sergenasr/my_project/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # my_project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # my_project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] >>> play2-maven-plugin:1.0.0-alpha5:run (default-cli) > process-classes # my_project >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # my_project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # my_project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< play2-maven-plugin:1.0.0-alpha5:run (default-cli) < process-classes # my_project <<<
[INFO]
[INFO] --- play2-maven-plugin:1.0.0-alpha5:run (default-cli) # my_project ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.640 s
[INFO] Finished at: 2016-11-01T22:07:17-07:00
[INFO] Final Memory: 11M/125M
[INFO] ------------------------------------------------------------------------
```
However, I don't see the server running.
Also, note that I can run the server normally using activator, then ~run. What am I doing wrong?
Use the latest 1.0.0-beta5 plugin version.
Read general plugin usage document.
Read plugin usage page for Play! Framework version used in your project (there are links on general usage page).

maven copy test resources into jar fails

I need some resources that are under:
src/main/resources/__files/
Now when creating my jar with maven those are not included.
This is my pomfile:
http://pastebin.com/xMtJDei2
when creating my app I get this:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wiremock 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # wiremock ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # wiremock ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/betauser/Documents/Development/wiremock/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # wiremock ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/betauser/Documents/Development/wiremock/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # wiremock ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # wiremock ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # wiremock ---
[INFO] Building jar: /Users/betauser/Documents/Development/wiremock/target/WiremockServer.jar
[INFO]
[INFO] --- maven-dependency-plugin:2.9:copy-dependencies (copy-dependencies) # wiremock ---
[INFO] Copying slf4j-api-1.7.6.jar to /Users/betauser/Documents/Development/wiremock/target/dependency-jars/slf4j-api-1.7.6.jar
[INFO] Copying wiremock-1.52-standalone.jar to /Users/betauser/Documents/Development/wiremock/target/dependency-jars/wiremock-1.52-standalone.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.229 s
[INFO] Finished at: 2014-12-11T14:40:16+01:00
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
and when I run my program and I ask the file I get:
java.io.FileNotFoundException: /Users/betauser/Documents/Development/wiremock/target/src/main/resources/__files/test-long.mp3 (No such file or directory)
I wonder about the output ".../target/src/main/resources/..." .
The directory structure "src/main/resources" can't exist below "target", if your artifact builds properly.
The files you create in /src/main/resources and below belong to the classpath of your application.
Open your artifact (jar) which was created during the build process. There you should find a directory entry named "__files".

building a scala-java-antlr project in maven results with ClassDefNotFoundError on runtime

I'm trying to port mustache.scala to scala 2.10, and make it built with maven with antlr3-maven-plugin instead of sbt. so far, i got this, and the code is compiled successfully. but at runtime, when i try to execute something simple like new Mustach("hello {{world}}!"), i get a java.lang.NoClassDefFoundError.
the weird thing, is that at first, i got the NoClassDefFoundError for Node class. i didn't understand why the java classes were'nt in the compiled jar, but i was eager to test if it worked. so i compiled just the two java classes with javac, and invoked the scala REPL as follows:
$scala -cp path/to/compiled/java/classes:path/to/jar-with-dependencies.jar
Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import org.monkey.mustache._
import org.monkey.mustache._
scala> new Mustache("hello {{world}}!")
java.lang.NoClassDefFoundError: org/monkey/mustache/MustacheLexer
at org.monkey.mustache.Mustache.<init>(Mustache.scala:21)
at org.monkey.mustache.Mustache.<init>(Mustache.scala:32)
at .<init>(<console>:11)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
...
so now i'm getting a NoClassDefFoundError on ANTLR output classes, so I see that not only the java files compile output was not packaged in the jar, but also ANTLR generated files. the scala code is depended on the java code as well as on the ANTLR generated code, so if the compilation succeeds, it must mean that at some point the java & ANTLR code was compiled succefully.
the relevant maven output is attached:
$ mvn clean install
.
. irrelevant output omitted...
.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mustache_2.10 1.0.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) # mustache_2.10 ---
[INFO] Deleting file set: /path/to/mustache.scala/target (included: [**], excluded: [])
[INFO]
[INFO] --- antlr3-maven-plugin:1.0:antlr (default) # mustache_2.10 ---
[INFO] Processing grammar /path/to/mustache.scala/src/main/antlr/org/monkey/mustache/Mustache.g
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # mustache_2.10 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /path/to/mustache.scala/src/main/resources
[INFO]
[INFO] --- scala-maven-plugin:3.1.3:compile (project-resources-execution) # mustache_2.10 ---
[INFO] /path/to/mustache.scala/src/main/java:-1: info: compiling
[INFO] /path/to/mustache.scala/target/generated-sources/antlr:-1: info: compiling
[INFO] /path/to/mustache.scala/src/main/scala:-1: info: compiling
[INFO] Compiling 8 source files to /path/to/mustache.scala/target/classes at 1371141939993
[INFO] prepare-compile in 0 s
[INFO] compile in 8 s
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # mustache_2.10 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default) # mustache_2.10 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- scala-maven-plugin:3.1.3:compile (compile) # mustache_2.10 ---
[INFO] /path/to/mustache.scala/src/main/java:-1: info: compiling
[INFO] /path/to/mustache.scala/target/generated-sources/antlr:-1: info: compiling
[INFO] /path/to/mustache.scala/src/main/scala:-1: info: compiling
[INFO] Compiling 8 source files to /path/to/mustache.scala/target/classes at 1371141948773
[INFO] prepare-compile in 0 s
[INFO] compile in 8 s
[INFO]
.
. irrelevant output omitted...
.
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # mustache_2.10 ---
[INFO] Building jar: /path/to/mustache.scala/target/mustache_2.10-1.0.5-SNAPSHOT.jar
[INFO]
[INFO] >>> maven-source-plugin:2.2.1:jar (attach-sources) # mustache_2.10 >>>
[INFO]
[INFO] --- antlr3-maven-plugin:1.0:antlr (default) # mustache_2.10 ---
[INFO] No grammars processed; generated files are up to date
[INFO]
[INFO] <<< maven-source-plugin:2.2.1:jar (attach-sources) # mustache_2.10 <<<
[INFO]
[INFO] --- maven-source-plugin:2.2.1:jar (attach-sources) # mustache_2.10 ---
[INFO] Building jar: /path/to/mustache.scala/target/mustache_2.10-1.0.5-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-install-plugin:2.3:install (default-install) # mustache_2.10 ---
[INFO] Installing /path/to/mustache.scala/target/mustache_2.10-1.0.5-SNAPSHOT.jar to /path/to/mustache_2.10/1.0.5-SNAPSHOT/mustache_2.10-1.0.5-SNAPSHOT.jar
[INFO] Installing /path/to/mustache.scala/pom.xml to /path/to/.m2/repository/org/monkey/mustache_2.10/1.0.5-SNAPSHOT/mustache_2.10-1.0.5-SNAPSHOT.pom
[INFO] Installing /path/to/mustache.scala/target/mustache_2.10-1.0.5-SNAPSHOT-sources.jar to /path/to/.m2/repository/org/monkey/mustache_2.10/1.0.5-SNAPSHOT/mustache_2.10-1.0.5-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.516s
[INFO] Finished at: Thu Jun 13 19:46:06 IDT 2013
[INFO] Final Memory: 16M/214M
[INFO] ------------------------------------------------------------------------
buttom line, how do i get the compiled output from java files to be packaged in the jar along with the compiled scala code?
The scala compiler read the source *.java (explicit in your log), but it doesn't compile them. To compile your *.scala it can used *.java OR *.class.
The classes generated into target/generated-sources/antlr don't exist into target/classes. The compilation is not done by maven-compiler-plugin. Wrong use of includes : it's a filter not a way to add sources dir. Try to remove it : you will have compilation error like
.../MustacheLexer.java:[168,17] cannot find symbol
[ERROR] symbol : variable type
Sorry I don't know/search how to fix it.

Categories

Resources