Adapted assembly and Wagon plugin to automate distribution upload.

Predefined necessary properties. Declared Wagon plugin to upload static resources and schemas. Declared additional ant run execution to upload distribution ZIP to S3. Disable standard deploy plugin. Updated read me accordingly.
This commit is contained in:
Oliver Gierke
2013-01-29 19:11:47 +01:00
parent 420ab36741
commit c7ed02121f
3 changed files with 166 additions and 9 deletions

View File

@@ -4,7 +4,9 @@ This repository contains common infrastructure to be used by Spring Data modules
The parent project can be eased for either a single-module Maven project or a multi-module one. Each of the setups requires a slightly different setup of the project.
## General setup
## Project setup
### General setup
The parent project configures the following aspects of the project build:
@@ -37,7 +39,9 @@ The following dependencies are pre-configured.
- Test dependencies: JUnit / Hamcrest / Mockito
- Dependency versions for commonly used dependencies
## Single project setup
The projects need to define a property `${schema.key}` to define the abbreviated key to be used for schema upload, e.g. `jpa` for `spring-data-jpa`.
### Single project setup
If the client project is a project consisting of a single project only all that needs to be done is declaring the parent project:
@@ -49,25 +53,35 @@ If the client project is a project consisting of a single project only all that
</parent>
```
Be sure to adapt the version number to the latest release version. The second and already last step of the setup is to activate the assembly plugin in the build section:
Be sure to adapt the version number to the latest release version. The second and already last step of the setup is to activate the assembly and wagon plugin in the build section:
```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
</plugin>
```
As an example have a look at the build of [Spring Data JPA](http://github.com/SpringSource/spring-data-jpa).
## Multi project setup
### Multi project setup
A multi module setup requires slightly more setup and some structure being set up.
- The root `pom.xml` needs to configure the `project.type` property to `multi`.
- Docbook documentation sources need to be in the root project.
- The assembly needs to be build in a dedicated sub-module (e.g. `distribution`), declare the assembly plugin (see single project setup) in that submodule and reconfigure the `project.root` property in that module to `${basedir}/..`.
- Configure `${dist.id}` to the basic artifact id (e.g. `spring-data-mongodb`) as this will serve as file name for distribution artifacts, static resources etc.
As an example have a look at the build of [Spring Data MongoDB](http://github.com/SpringSource/spring-data-mongodb).
## Build configuration
- Configure "Artifactory Maven 3" task
- Goals to execute `clean (dependency:tree) install`
- Configure "Alternative Maven Tasks and Options" to `clean (dependency:tree) install -Pdistribute`
- A nightly build can then use `clean (dependency:tree) deploy -Pdistribute` to publish

View File

@@ -85,7 +85,23 @@
<project.type>single</project.type>
<project.root>${basedir}</project.root>
<source.level>1.5</source.level>
<dist.name>${project.artifactId}</dist.name>
<dist.id>${project.artifactId}</dist.id>
<dist.name>${project.name}</dist.name>
<dist.releaseType>snapshot</dist.releaseType>
<dist.bucketName>dist.springframework.org</dist.bucketName>
<dist.assemblyName>${dist.id}-${project.version}</dist.assemblyName>
<dist.fileName>${dist.assemblyName}.zip</dist.fileName>
<dist.filePath>${project.build.directory}/${dist.assemblyName}-distribution.zip</dist.filePath>
<dist.version>${project.version}</dist.version>
<!-- Additional properties required to be set by child projects -->
<!-- dist.key: the distribution key (e.g. DATACMNS) -->
<!-- schema.key: the key to be used for schema folder (e.g. jpa for spring-data-jpa) -->
<!-- Additional properties required to be set in settings.xml -->
<!-- dist.accessKey -->
<!-- dist.secretKey -->
<aspectj>1.7.1</aspectj>
<cdi>1.0</cdi>
@@ -221,7 +237,7 @@
<include name="**/*.pdf" />
</fileset>
</copy>
<move file="${project.basedir}/target/site/reference/pdf/index.pdf" tofile="${project.basedir}/target/site/reference/pdf/${dist.name}-reference.pdf" />
<move file="${project.basedir}/target/site/reference/pdf/index.pdf" tofile="${project.basedir}/target/site/reference/pdf/${dist.dist}-reference.pdf" />
</postProcess>
</configuration>
</execution>
@@ -318,6 +334,18 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.springframework.build</groupId>
<artifactId>org.springframework.build.aws.ant</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jets3t</groupId>
<artifactId>com.springsource.org.jets3t</artifactId>
<version>0.8.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-resources</phase>
@@ -335,8 +363,24 @@
<goal>run</goal>
</goals>
</execution>
<execution>
<id>upload-distribution</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="${shared.resources}/ant/upload-dist.xml">
<target name="upload-distribution"/>
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
@@ -359,12 +403,74 @@
<configuration>
<descriptors>
<descriptor>${shared.resources}/assemblies/distribution-${project.type}.xml</descriptor>
<descriptor>${shared.resources}/assemblies/site.xml</descriptor>
</descriptors>
</descriptors>
<finalName>${dist.assemblyName}</finalName>
</configuration>
</execution>
<execution>
<id>static</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${shared.resources}/assemblies/static-resources.xml</descriptor>
</descriptors>
<finalName>static-resources</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<configuration>
<fromDir>${project.build.directory}</fromDir>
</configuration>
<executions>
<!-- Upload namespace XSDs -->
<execution>
<id>upload-schema</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}/schemas</fromDir>
<includes>*.xsd</includes>
<serverId>static-dot-s2</serverId>
<url>scp://static.springsource.org</url>
<toDir>/var/www/domains/springsource.org/www/htdocs/autorepo/schema/${dist.id}/${project.version}/${schema.key}</toDir>
<optimize>true</optimize>
</configuration>
</execution>
<!-- Distribute static resources -->
<execution>
<id>upload-static-resources</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}/static-resources</fromDir>
<includes>**</includes>
<serverId>static-dot-s2</serverId>
<url>scp://static.springsource.org</url>
<toDir>/var/www/domains/springsource.org/www/htdocs/autorepo/docs/${dist.id}/${project.version}</toDir>
<optimize>true</optimize>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
@@ -446,6 +552,15 @@
</dependencies>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.3</version>
</extension>
</extensions>
<plugins>
<plugin>
@@ -509,6 +624,15 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<project name="upload-dist-tasks">
<taskdef resource="org/springframework/build/aws/ant/antlib.xml" />
<target name="upload-distribution">
<checksum file="${dist.filePath}" algorithm="sha1"/>
<s3 accessKey="${dist.accessKey}" secretKey="${dist.secretKey}">
<upload bucketName="${dist.bucketName}" file="${dist.filePath}"
toFile="${dist.releaseType}/${dist.key}/${dist.fileName}" publicRead="true">
<metadata name="project.name" value="${dist.name}"/>
<metadata name="release.type" value="${dist.releaseType}"/>
<metadata name="bundle.version" value="${dist.version}"/>
<metadata name="package.file.name" value="${dist.fileName}"/>
</upload>
<upload bucketName="${dist.bucketName}" file="${dist.filePath}.sha1"
toFile="${dist.releaseType}/${dist.key}/${dist.fileName}.sha1" publicRead="true">
</upload>
</s3>
</target>
</project>