maven-build-utils

Build utility plugins and extensions for Maven 3

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.lkoskela
ArtifactId

ArtifactId

maven-build-utils
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

jar
Description

Description

maven-build-utils
Build utility plugins and extensions for Maven 3
Project URL

Project URL

https://github.com/lkoskela/maven-build-utils
Source Code Management

Source Code Management

https://github.com/lkoskela/maven-build-utils

Download maven-build-utils

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lkoskela/maven-build-utils/ -->
<dependency>
    <groupId>com.github.lkoskela</groupId>
    <artifactId>maven-build-utils</artifactId>
    <version>1.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.lkoskela/maven-build-utils/
implementation 'com.github.lkoskela:maven-build-utils:1.4'
// https://jarcasting.com/artifacts/com.github.lkoskela/maven-build-utils/
implementation ("com.github.lkoskela:maven-build-utils:1.4")
'com.github.lkoskela:maven-build-utils:jar:1.4'
<dependency org="com.github.lkoskela" name="maven-build-utils" rev="1.4">
  <artifact name="maven-build-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.lkoskela', module='maven-build-utils', version='1.4')
)
libraryDependencies += "com.github.lkoskela" % "maven-build-utils" % "1.4"
[com.github.lkoskela/maven-build-utils "1.4"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.0.3
org.apache.maven : maven-core jar 3.0.3
org.hamcrest : hamcrest-all jar 1.1
com.googlecode.lambdaj : lambdaj jar 2.3.3
org.apache.commons : commons-lang3 jar 3.1

test (2)

Group / Artifact Type Version
junit : junit jar 4.10
org.mockito : mockito-all jar 1.9.0

Project Modules

There are no modules declared in this project.

DESCRIPTION

maven-build-utils is a collection of build-related utilities in the form of plugins and extensions for Maven 3.x. Currently, the provided features are:

  • Summary of durations for each goal within a phase
  • Summary of durations for each build phase within a project
  • Summary of durations for each module in a multi-module project

That's it (for now).

USAGE

In order to start using maven-build-utils there are three things you need to add to your project's POM:

<project>
    ...
    <build>
        <extensions>
            <extension>
                <groupId>com.github.lkoskela</groupId>
                <artifactId>maven-build-utils</artifactId>
                <version>1.5-SNAPSHOT</version>
            </extension>
        </extensions>
    </build>
    ...
    <properties>
        <maven-build-utils.activationProfiles>perfstats</maven-build-utils.activationProfiles>
    </properties>
    ...
    <profiles>
        <profile>
            <id>perfstats</id>
            <properties>
            	<maven-build-utils.activate-timeline>true</maven-build-utils.activate-timeline>
            </properties>
        </profile>
    </profiles>
    ...
</project>

The first bit to add is the build extension itself. The second bit to add is the name(s) of the activation profiles that maven-build-utils should run with. If you'll want to bind maven-build-utils to more than one profile, separate them with commas. The third bit is the actual profile, which obviously has to exist for any of this to make sense.

Running your build with these things in your POM, nothing should've changed. It is only when you run Maven with the particular activation profile(s) configured for maven-build-utils that you should see any difference in build output. When you want maven-build-utils to produce the statistics for the build, invoke the configured profile with the -P flag, e.g.:

mvn test -P perfstats

With the right profile activated while running any kind of goals and phases, your build output should conclude with a summary that looks a bit like this (for a multi-module project):

[INFO] ------------------------- BUILD STEP DURATIONS -------------------------
[INFO] PROJECT                                                    DURATION     
[INFO] | PHASE                                                       PERCENTAGE
[INFO] | | GOAL                                                          |    |
[INFO] | | |                                                             |    |
[INFO] 
[INFO] *parent                                                        0,9s   5%
[INFO]   generate-resources                                           0,9s 100%
[INFO]     maven-remote-resources-plugin:process                      0,9s 100%
[INFO] 
[INFO] *module1                                                       6,0s  37%
[INFO]   generate-sources                                             1,7s  28%
[INFO]     modello-maven-plugin:java                                  1,2s  71%
[INFO]     modello-maven-plugin:xpp3-reader                           0,2s  12%
[INFO]     modello-maven-plugin:xpp3-extended-reader                  0,1s   7%
[INFO]     modello-maven-plugin:xpp3-writer                           0,2s   8%
[INFO]   generate-resources                                           0,1s   0%
[INFO]     maven-remote-resources-plugin:process                      0,1s 100%
[INFO]   process-resources                                            0,4s   6%
[INFO]     maven-resources-plugin:resources                           0,4s 100%
[INFO]   compile                                                      3,8s  63%
[INFO]     maven-compiler-plugin:compile                              3,8s 100%
[INFO] 
[INFO] *module2                                                       0,9s   5%
[INFO]   generate-sources                                             0,1s  16%
[INFO]     modello-maven-plugin:java                                  0,1s  55%
[INFO]     modello-maven-plugin:xpp3-reader                           0,0s  25%
[INFO]     modello-maven-plugin:xpp3-writer                           0,0s  19%
[INFO]   generate-resources                                           0,0s   5%
[INFO]     maven-remote-resources-plugin:process                      0,0s 100%
[INFO]   process-resources                                            0,0s   1%
[INFO]     maven-resources-plugin:resources                           0,0s 100%
[INFO]   compile                                                      0,7s  77%
[INFO]     maven-compiler-plugin:compile                              0,7s 100%
[INFO]
[INFO] ...

As you can see, the summary lists the total duration of each build lifecycle phase that was executed (generate-sources, generate-resources, etc.) as well as the durations of each goal executed as part of those phases.

The percentages are included for easier overview of where the hotspots are:

  • The listed percentage for a project represents that project's contribution to the whole build's execution (mostly useful in a multi-module project).
  • The listed percentage for a phase represents that phase's contribution to the project's execution.
  • The listed percentage for a goal represents that goal's contribution to the phase's execution.

If you'd like to produce this output by default without passing the specific profile on the command line, you can activate the profile by default in your POM like so:

<profiles>
    <profile>
        <id>perfstats</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
</profiles>

TIMELINE

If you have activated the timeline build with the property "maven-build-utils.activate-timeline", an HTML page is generated picturing a view of your build.

open target/timeline.html

CONFIGURATION

The report is written to the console by default. If you'd prefer to direct it to a file, you can do that with a system property like so:

mvn -Dduration.output=file ...

This will direct the output to "target/durations.log" under the execution directory. If you would prefer a different destination for the log file, you can override it with another system property:

mvn -Dduration.output=file -Dduration.output.file=/tmp/perf.log ...

Good luck!

LICENSE

This code is licensed under the Apache License Version 2.0, January 2004. The full license text is available at apache.org

Versions

Version
1.4
1.3
1.2
1.1