diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java new file mode 100644 index 0000000..fb06bc0 --- /dev/null +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java @@ -0,0 +1,40 @@ +package com.inteligr8.maven.aps.modeling.goal; + +import java.io.IOException; + +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.AppDefinitionPublishRepresentation; + +@Mojo( name = "publish-app", threadSafe = true ) +@Component( role = org.apache.maven.plugin.Mojo.class ) +public class PublishAppGoal extends ApsAppAccessibleGoal { + + @Parameter( property = "aps-model.publish.comment", required = true, defaultValue = "Automated by 'aps-model-maven-plugin'" ) + protected String comment; + + @Override + public void executeEnabled() throws MojoExecutionException, MojoFailureException { + Long appId = this.findAppId(false); + + try { + this.publishApp(appId); + } catch (IOException ie) { + throw new MojoExecutionException("The APS App could not be published", ie); + } + } + + private void publishApp(Long appId) throws IOException, MojoExecutionException { + ApsPublicRestApiJerseyImpl api = this.getApsApi(); + + AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation(); + appDefPublish.setComment(this.comment); + api.getAppDefinitionsApi().publish(appId, appDefPublish); + } + +}