-
-
Save izebit/27070793ca954c47f81f3a16f7d392f1 to your computer and use it in GitHub Desktop.
speedy install based on git revision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>ru.izebit</groupId> | |
<artifactId>maven-example</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>pl.project13.maven</groupId> | |
<artifactId>git-commit-id-plugin</artifactId> | |
<version>2.2.4</version> | |
<executions> | |
<execution> | |
<id>get-the-git-information</id> | |
<goals> | |
<goal>revision</goal> | |
</goals> | |
<phase>validate</phase> | |
</execution> | |
</executions> | |
<configuration> | |
<prefix>git</prefix> | |
<validationProperties> | |
<!-- verify that the current repository is not dirty --> | |
<validationProperty> | |
<name>validating git dirty</name> | |
<value>${git.dirty}</value> | |
<shouldMatchTo>false</shouldMatchTo> | |
</validationProperty> | |
</validationProperties> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.8</version> | |
<executions> | |
<execution> | |
<configuration> | |
<exportAntProperties>true</exportAntProperties> | |
<target> | |
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/> | |
<echo>Git revision: ${git.commit.id}</echo> | |
<echo>Does repo contain any changes? ${git.dirty}</echo> | |
<propertyregex property="directory.name" | |
input="${project.groupId}" | |
regexp="[.]" | |
replace="/" | |
global="true"/> | |
<property name="artifact.path" | |
value="${settings.localRepository}/${directory.name}/${project.artifactId}/${project.version}"/> | |
<echo>Artifact path: ${artifact.path}</echo> | |
<condition property="skip.build" value="true" else="false"> | |
<and> | |
<isfalse value="${git.dirty}"/> | |
<resourceexists> | |
<file file="${artifact.path}/${project.build.finalName}.${project.packaging}"/> | |
</resourceexists> | |
<resourceexists> | |
<file file="${artifact.path}/${git.commit.id}"/> | |
</resourceexists> | |
</and> | |
</condition> | |
<if> | |
<equals arg1="${skip.build}" arg2="true"/> | |
<then> | |
<echo message="Skip build for ${project.artifactId}"/> | |
</then> | |
<else> | |
<echo message="Rebuild ${project.artifactId}"/> | |
<delete dir="${artifact.path}/" failonerror="false"/> | |
<mkdir dir="${artifact.path}"/> | |
<touch file="${artifact.path}/${git.commit.id}"/> | |
</else> | |
</if> | |
</target> | |
</configuration> | |
<phase>validate</phase> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
</executions> | |
<dependencies> | |
<dependency> | |
<groupId>ant-contrib</groupId> | |
<artifactId>ant-contrib</artifactId> | |
<version>1.0b3</version> | |
<exclusions> | |
<exclusion> | |
<groupId>ant</groupId> | |
<artifactId>ant</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
</dependencies> | |
</plugin> | |
<!--other plugins--> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<configuration> | |
<skipMain>${skip.build}</skipMain> | |
<skip>${skip.build}</skip> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-resources-plugin</artifactId> | |
<version>3.0.0</version> | |
<configuration> | |
<skip>${skip.build}</skip> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>2.4</version> | |
<configuration> | |
<skipIfEmpty>true</skipIfEmpty> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-install-plugin</artifactId> | |
<configuration> | |
<skip>${skip.build}</skip> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment