v1.3-SNAPSHOT pom
This commit is contained in:
parent
d5c31527a4
commit
b2fbe41fe1
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>aps-model-maven-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.3-SNAPSHOT</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>A Maven plugin for Alfresco Process Services model portability</name>
|
||||
|
@ -1,70 +0,0 @@
|
||||
<?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>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>aps-model-maven-plugin-deploy-app</artifactId>
|
||||
<version>@pom.version@</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Deploy App Plugin Tests</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>aps-model-maven-plugin</artifactId>
|
||||
<version>@pom.version@</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>download-unpack-app</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>download-app</goal>
|
||||
<goal>unpack-app</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<reformat>true</reformat>
|
||||
<normalize>true</normalize>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>translate-app</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>translate-app</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<finalDirectory>${project.build.directory}/aps-dev</finalDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pack-app</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>pack-app</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<unzipDirectory>${project.build.directory}/aps-dev</unzipDirectory>
|
||||
<zipDirectory>${project.build.directory}/aps-test</zipDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>deploy-app</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>deploy-app</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<zipDirectory>${project.build.directory}/aps-test</zipDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,98 +0,0 @@
|
||||
package com.inteligr8.maven.aps.modeling.goal;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
||||
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
||||
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
|
||||
|
||||
@Mojo( name = "deploy-app", threadSafe = true )
|
||||
@Component( role = org.apache.maven.plugin.Mojo.class )
|
||||
public class DeployAppGoal extends ApsAppAccessibleGoal {
|
||||
|
||||
@Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" )
|
||||
protected File zipDirectory;
|
||||
|
||||
@Parameter( property = "publish", required = true, defaultValue = "false" )
|
||||
protected boolean publish = false;
|
||||
|
||||
protected final int bufferSize = 128 * 1024;
|
||||
|
||||
@Override
|
||||
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
||||
File sourceFile = this.validateSourceDirectory();
|
||||
|
||||
Long appId = this.findAppId();
|
||||
|
||||
try {
|
||||
this.uploadApp(appId, sourceFile);
|
||||
} catch (IOException ie) {
|
||||
throw new MojoExecutionException("The APS App could not be uploaded", ie);
|
||||
}
|
||||
}
|
||||
|
||||
protected File validateSourceDirectory() {
|
||||
if (!this.zipDirectory.exists()) {
|
||||
throw new IllegalStateException("The 'zipDirectory' does not exist: " + this.zipDirectory);
|
||||
} else if (!this.zipDirectory.isDirectory()) {
|
||||
throw new IllegalStateException("The 'zipDirectory' is not a directory: " + this.zipDirectory);
|
||||
}
|
||||
|
||||
File sourceFile = new File(this.zipDirectory, this.apsAppName + ".zip");
|
||||
|
||||
if (!sourceFile.exists()) {
|
||||
throw new IllegalStateException("The App file does not exists in the 'zipDirectory': " + sourceFile);
|
||||
} else if (!sourceFile.isFile()) {
|
||||
throw new IllegalStateException("The App file is not a file: " + sourceFile);
|
||||
}
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
private void uploadApp(Long appId, File appZip) throws IOException, MojoExecutionException {
|
||||
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
||||
|
||||
FileInputStream fistream = new FileInputStream(appZip);
|
||||
BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize);
|
||||
try {
|
||||
FileMultipartJersey multipart = FileMultipartJersey.from(appZip.getName(), bistream);
|
||||
|
||||
if (appId == null) {
|
||||
if (this.publish) {
|
||||
this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName);
|
||||
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart);
|
||||
if (Boolean.TRUE.equals(appDefUpdate.getError()))
|
||||
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
|
||||
} else {
|
||||
this.getLog().info("Uploading new APS App: " + this.apsAppName);
|
||||
api.getAppDefinitionsJerseyApi().importApp(multipart, true);
|
||||
}
|
||||
} else {
|
||||
if (this.publish) {
|
||||
this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")");
|
||||
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart);
|
||||
if (Boolean.TRUE.equals(appDefUpdate.getError()))
|
||||
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
|
||||
} else {
|
||||
this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")");
|
||||
api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true);
|
||||
}
|
||||
}
|
||||
} catch (ParseException pe) {
|
||||
throw new MojoExecutionException("The app ZIP could not be wrapped in a multipart", pe);
|
||||
} finally {
|
||||
bistream.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user