Skip to content

Instantly share code, notes, and snippets.

@boly38
Last active December 27, 2015 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boly38/7316378 to your computer and use it in GitHub Desktop.
Save boly38/7316378 to your computer and use it in GitHub Desktop.
a maven profile called "stats" used to log some maven lifecycle steps

"stats" maven profile

this profile simply append step datetime in a file called stats.log

Installation

  • add stats profile to your pom.xml

Usage

  • launch maven goal
  • check stats.log file

Example

>mvn -Pstats -DskipTests clean package
>mvn -Pstats -DskipTests clean package
>cat stats.log
05-10:30:22 validate
05-10:30:22 initialize
05-10:30:22 generate-sources
05-10:30:22 process-sources
05-10:30:22 generate-resources
05-10:30:28 process-resources
05-10:30:46 compile
05-10:30:46 process-classes
05-10:30:49 prepare-package
05-10:31:01 package


05-10:32:36 validate
05-10:32:36 initialize
05-10:32:36 generate-sources
05-10:32:36 process-sources
05-10:32:36 generate-resources
05-10:32:36 process-resources
05-10:32:38 compile
05-10:32:38 process-classes
05-10:32:39 prepare-package
05-10:32:41 package

Resources

<profile>
<id>stats</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>log_validate</id>
<phase>validate</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${line.separator}${line.separator}${stepTstamp} validate${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_initialize</id>
<phase>initialize</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} initialize${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_generate_sources</id>
<phase>generate-sources</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} generate-sources${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_process_sources</id>
<phase>process-sources</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} process-sources${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_generate_resources</id>
<phase>generate-resources</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} generate-resources${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_process_resources</id>
<phase>process-resources</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} process-resources${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_compile</id>
<phase>compile</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} compile${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_process_classes</id>
<phase>process-classes</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} process-classes${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_prepare_package</id>
<phase>prepare-package</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} prepare-package${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_package</id>
<phase>package</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} package${line.separator}"/>
</tasks>
</configuration>
</execution>
<execution>
<id>log_install</id>
<phase>install</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<tstamp><format property="stepTstamp" pattern="dd-HH:mm:ss" locale="en,US" /></tstamp>
<echo file="stats.log" append="true"
message="${stepTstamp} install${line.separator}"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment