How to monitor & record build (compile/test) time? - java

I work on a large-ish Java project. We are using maven as our build tool, and I use Intellij (14) as my IDE.
Currently, if I build the whole project (c. 15 modules) it takes about 3 minutes. Due to the way that we use our code (even in development), I end up doing a full build quite often. On the basis that "what gets measured gets managed", I'd like to be able to monitor/record:
How many times an hour/day a build has been run?
How much time has been spent running builds?
If it were possible, to break this down by maven task - i.e. clean/compile/test/other plugins etc.
One approach might be to have the maven output dumped to files, and then have a process to read these/calculate the statistics I want. How should I approach this?
Just to be clear, I'm not asking for comments/advice on how to reduce our build-cycle runtime. We've already done a fair bit of work on this, and are continuing to work on it - indeed, I'm really looking for a way to monitor our effective progress on this.

This Maven Profile project could help you out.
Simply installing (copying) its latest version jar on your ${M2_HOME}/lib/ext and then executing the build as following
mvn clean install -Dmaven.profile
Would provide you the following sample output
com.sample:test:0.0.1-SNAPSHOT
clean 175ms
org.apache.maven.plugins:maven-clean-plugin:2.5 (default-clean) 175ms
process-resources 336ms
org.apache.maven.plugins:maven-resources-plugin:2.6 (default-resources) 335ms
compile 1s 2ms
org.apache.maven.plugins:maven-compiler-plugin:2.5.1 (default-compile) 1s 2ms
process-test-resources 9ms
org.apache.maven.plugins:maven-resources-plugin:2.6 (default-testResources) 9ms
test-compile 59ms
org.apache.maven.plugins:maven-compiler-plugin:2.5.1 (default-testCompile) 59ms
test 1s 83ms
org.apache.maven.plugins:maven-surefire-plugin:2.12.4 (default-test) 1s 83ms
package 352ms
org.apache.maven.plugins:maven-jar-plugin:2.4 (default-jar) 352ms
You would then need to have a further layer (script?) for data accumulation in order to get cross-builds statistics though. However, it already answers to your third question and it is probably a good start.

Related

Increase the speed of Maven release prepare and perform task?

I've found some ways to increase the speed of our standard maven builds such as only building modules that have changed and utilising parallel builds. For the task:
clean release:prepare release:perform
It takes a while and I'd like to speed up. It seems the parallel builds doesn't work I get an error. Any suggestions on how to speed up? I assume I could skip tests and they're already being done on the builds on the dev branch before it's merged with master?
The error I get when running parallel builds is:
[ERROR] NullPointerException
[ERROR] java.util.concurrent.ExecutionException: java.lang.NullPointerException
This seems to be the only error I get - not sure why?

Evosuite (maven) Unable to generate test / edit: tried eclipse plugin

I was testing evosuite (automation tool to generate junit test) using Maven plugin in Eclipse Luna, using JDK 1.8
I have followed the tutorial given in evosuite tutorial: http://www.evosuite.org/documentation/tutorial-part-2/
Able to generate test using the tutorial file provided by evosuite but when I tried it on one of the projects that I am working on, it couldn't generate test when I initiate mvn evosuite:generate in cmd.
understand that I first need to do a mvn compile and it actually generate all the .class files in the folder "target\classes", I actually checked that the physical files are indeed present in the folder "Classes". the folder structure is exactly the same as in the folder "src\main\java".
when I initiate "mvn evosuite:generate" ,
it actually started generating,
it is showing:
[INFO] Registered remote process from /127.0.0.1:58449
[INFO] Going to execute 139 jobs
[INFO] Estimated completion time: 278 minutes, by 2018-04-22T05:33:27.051
[INFO] Going to start job for: "Java file". Expected to end in 1158 seconds,
by 2018-04-22T01:14:45.848
and it continues until the very last java file,
showing this:
[INFO] * Updating database to "java file name"
then it came to this:
=== CTG run results ===
[INFO] Removed test suites: 0
[INFO] New test suites: 0
[INFO] Missing classes:
[INFO] "Java file name"
and ended with this statement
[INFO] WARN: failed to generate tests for 139 classes out of 139
[INFO] Stopping spawn process manager
[INFO] ---------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ---------------------------------------------------------------------
[INFO] Total time: 52:44 min
[INFO] Finished at: 2018-04-22T01:47:02+08:00
[INFO] ---------------------------------------------------------------------
I am wondering if i miss out any steps? Because using the same steps I am able to generate the test cases using the tutorial_maven provided by evosuite.
Or is this due to the complexity of the project and java files that evosuite is unable to process and generate the unit test?
Please advise! Thank you! i have tried many many different methods, mvn clean install repeatedly, but to no avail.
edit: tried eclipse plugin for evosuite as well: got the same error saying cannot find test.java file which is weird. Isn't the plugin supposed to generate the test file?

Is there any plugin or feature that determines which JARs are unused in an application or a project (in a given project life cycle)

A typical Java project has 30-40 jar files. Maven resolves dependencies. Sometimes some features are no longer needed. But no one touches the JARs with the fear of breaking the code or application.
For example: jersey (JAX-RS) implementation with JAXB has many workarounds, different Maven configurations.
Different developers sometimes employ different methods to do the same thing. All are correct. I agree they should discuss out. But the problem is that unused JARs make the build package heavy.
Isn't there a plugin which can map (use reflection) and check for one time (one project life cycle) and mark unwanted or unused JARs. This will use java reflection and may get slow but this is needed.
Any solutions?
Maven helps to find out unused dependencies with dependency plugin.
mvn dependency:analyze
its displays the unused dependencies as follow
[INFO] --- maven-dependency-plugin:2.8:analyze (default-cli) # mymaven ---
[WARNING] Unused declared dependencies found:
[WARNING] org.apache.commons:commons-lang3:jar:3.0:compile

Installing Maven Android SDK Deployer

Im trying to install this maven plugin, but i have several questions which i cant do trial & error because of my slow internet speed :
The documentation said :
For the default usage of the deployer install all platforms and add-on apis, ensure that all folder in the platforms folder have names like android-3, android-4 and so on.
Do i really need to download ALL of the platforms and extras, even i dont want to use it?
And then, it said :
If you find names using the platform version (e.g. 15) in the folder name reinstall that platform from the android tool.
This is my platforms folder :
It seems all of my platform's name is using the version, do i really need to re-install ALL of those installed platforms?
Do you have any other way how to make this maven plugin work more easily?
Or do you have any better idea? (different plugin maybe, or anything). Im very new to Maven.
Thanks very much for your help.
No need to reinstall, but make sure you have all the platform levels.When you run the SDK deployer POM, the build will go looking each and every one of the platform level folders and if you have one missing the build will fail. So make sure you have all even if you don't require them. That's why they insist on the folder naming.
This is how missing platform errors look like:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:32 min
[INFO] Finished at: 2014-05-29T18:11:29-06:00
[INFO] Final Memory: 19M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default) on project android-10: Properties file not found: $ANDROID_HOME/platforms/android-10/source.properties -> [Help 1]

Run JUnit tests in Maven without building and copying files [duplicate]

This question already has answers here:
How can I atomically run mvn tests (without rebuilding source code)?
(3 answers)
Closed 6 years ago.
I have a large Maven project which has several modules in it. When I want to run a JUnit test from one module I run 'mvn -Dtest=NameOfTest test' in the directory that contains all the modules. When I run this command Maven goes through each module and tries to compile it (though it's already compiled), which involves copying a bunch of files and adds to the total time of the test. It seems that the 'test' command for the Maven surefire plugin executes all the steps up to the test. I was wondering if there is a way to execute only the test step and not bother with all the attempted compilation and copying of files.
Here is some output from before the test starts:
[INFO]
[INFO] --- build-helper-maven-plugin:1.5:add-test-source (add-test-source) # module1 ---
[INFO] Test Source directory: <directory in module1 with some generated sources> added.
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # module1 ---
[debug] execute contextualize
[INFO] Copying 108 resources
[INFO] Copying 1113 resources
[INFO] Copying 1 resource
[INFO]
It repeats this for each of the other modules. All told it takes a minute or two before it actually starts the test. Does anyone know a way to get the test to run without bothering with all the compilation beforehand? Please let me know if there's any more information I should provide.
If what you would like to do is to run just the test phase of the lifecycle without running all of the previous phases you could also call the goal that is bound to the test phase:
mvn surefire:test
or if you want to run just one test
mvn -Dtest=NameOfTest surefire:test
What is wrong with simply running the test from within the module the test resides in? That way, Maven will not attempt to build the other modules which you are not interested in.

Categories