parent-github
Used in:
components
- OverviewOverview
- VersionsVersions
- DependentsDependents
- DependenciesDependencies
<dependency>
<groupId>com.github.htfv</groupId>
<artifactId>parent-github</artifactId>
<version>8</version>
</dependency><!--
Copyright 2013 htfv (Aliaksei Lahachou)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>
<parent>
<groupId>com.github.htfv</groupId>
<artifactId>parent</artifactId>
<version>8</version>
</parent>
<artifactId>parent-github</artifactId>
<packaging>pom</packaging>
<name>Parent POM for GitHub hosted projects</name>
<description>Parent POM for projects under com.github.htfv hosted on GitHub.</description>
<properties>
<!-- We are going to use Ant script to deploy the site, because site
deployment to GitHub is currently not supported and
github-site-plugin is too slow. -->
<maven.site.deploy.skip>true</maven.site.deploy.skip>
<!-- The name of the branch to which the site should be pushed. -->
<github.site.deploy.branch>gh-pages</github.site.deploy.branch>
<!-- The name of the directory where the site repository should be
cloned. -->
<github.site.deploy.cloneDirectory>${project.rootdir}/target/site-deploy</github.site.deploy.cloneDirectory>
<!-- The message associated with the commit. -->
<github.site.deploy.commitMessage>Updated site for ${project.artifactId}:${project.version}.</github.site.deploy.commitMessage>
<!-- True to skip site deployment. -->
<github.site.deploy.skip>false</github.site.deploy.skip>
<!-- The pattern for the site URL. -->
<github.site.deploy.urlPattern>
(?x:
scm:git:
( # repository URL
(?: # repository URL with protocol
(?:(?:git)|(?:https?)|(?:ssh)):// # protocol
[^:]+ # user, server, path
)
|(?: # repository URL without protocol
.*?@ # user
.*?: # server
[^:]* # path
)
)
(?: # site directory
: # separator
(.*) # directory
)?
)
</github.site.deploy.urlPattern>
<!-- The name of the directory where the site is generated. -->
<github.site.directory>${project.reporting.outputDirectory}</github.site.directory>
<!-- Path to the root project. -->
<project.rootdir>${project.basedir}</project.rootdir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<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>
<executions>
<execution>
<id>github-site-deploy</id>
<configuration>
<skip>${github.site.deploy.skip}</skip>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<if>
<matches pattern="${github.site.deploy.urlPattern}" string="${project.distributionManagement.site.url}" />
<then>
<!-- Parse site URL. -->
<propertyregex input="${project.distributionManagement.site.url}" property="github.site.deploy.url" regexp="${github.site.deploy.urlPattern}" select="\1" />
<propertyregex input="${project.distributionManagement.site.url}" property="github.site.deploy.directory" regexp="${github.site.deploy.urlPattern}" select="\2" />
<echo message="Repository URL: ${github.site.deploy.url}" />
<echo message="Branch name: ${github.site.deploy.branch}" />
<echo message="Directory: ${github.site.deploy.directory}" />
<!-- Define git macros. -->
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<element name="args" implicit="true" optional="true" />
<sequential>
<exec dir="@{dir}" executable="git" failonerror="@{failonerror}">
<arg value="@{command}" />
<args />
</exec>
</sequential>
</macrodef>
<macrodef name="git-add">
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<element name="args" implicit="true" optional="true" />
<sequential>
<echo message="git add" />
<git command="add" dir="@{dir}" failonerror="@{failonerror}">
<args />
</git>
</sequential>
</macrodef>
<macrodef name="git-clone">
<attribute name="dest" default="" />
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<attribute name="uri" />
<element name="args" implicit="true" optional="true" />
<sequential>
<echo message="git clone @{uri}" />
<git command="clone" dir="@{dir}" failonerror="@{failonerror}">
<args />
<arg value="@{uri}" />
<arg value="@{dest}" />
</git>
</sequential>
</macrodef>
<macrodef name="git-commit">
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<element name="args" implicit="true" optional="true" />
<sequential>
<echo message="git commit" />
<git command="commit" dir="@{dir}" failonerror="@{failonerror}">
<args />
</git>
</sequential>
</macrodef>
<macrodef name="git-config">
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<attribute name="name" default="" />
<attribute name="value" default="" />
<element name="args" implicit="true" optional="true" />
<sequential>
<echo message="git config @{name} @{value}" />
<git command="config" dir="@{dir}" failonerror="@{failonerror}">
<args />
<arg value="@{name}" />
<arg value="@{value}" />
</git>
</sequential>
</macrodef>
<macrodef name="git-push">
<attribute name="dir" default="${project.rootdir}" />
<attribute name="failonerror" default="true" />
<attribute name="uri" default="" />
<attribute name="refspec" default="" />
<element name="args" implicit="true" optional="true" />
<sequential>
<echo message="git push @{uri} @{refspec}" />
<git command="push" dir="@{dir}" failonerror="@{failonerror}">
<args />
<arg value="@{uri}" />
<arg value="@{refspec}" />
</git>
</sequential>
</macrodef>
<!-- Check to see if the remote repository is already cloned. -->
<if>
<available file="${github.site.deploy.cloneDirectory}/.git" />
<then>
<!-- Should we pull? -->
</then>
<else>
<!-- Clone remote repository. -->
<git-clone dest="${github.site.deploy.cloneDirectory}" uri="${github.site.deploy.url}">
<arg value="-b" />
<arg value="${github.site.deploy.branch}" />
<!-- Limit history depth for faster cloning. -->
<arg value="--depth" />
<arg value="1" />
</git-clone>
<!-- Disable automatic line ending fixes. -->
<git-config dir="${github.site.deploy.cloneDirectory}" name="core.autocrlf" value="false" />
</else>
</if>
<!-- Copy site files. -->
<mkdir dir="${github.site.deploy.cloneDirectory}/${github.site.deploy.directory}" />
<copy overwrite="true" todir="${github.site.deploy.cloneDirectory}/${github.site.deploy.directory}">
<fileset dir="${github.site.directory}" />
</copy>
<!-- Add all changes to index. -->
<git-add dir="${github.site.deploy.cloneDirectory}">
<arg value="-A" />
</git-add>
<!-- Commit the changes. Don't fail on error, because git fails if
there is nothing to commit. -->
<git-commit dir="${github.site.deploy.cloneDirectory}" failonerror="false">
<arg value="-m" />
<arg value="${github.site.deploy.commitMessage}" />
</git-commit>
<!-- Push the changes to the remote repository. -->
<git-push dir="${github.site.deploy.cloneDirectory}" refspec="${github.site.deploy.branch}" uri="${github.site.deploy.url}" />
</then>
<else>
<echo message="project.distributionManagement.site.url is not set or has invalid format." />
</else>
</if>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
<inherited>true</inherited>
<phase>site-deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>