From 3bced985d64dc26fb1d703a97c61ef577f2a8821 Mon Sep 17 00:00:00 2001 From: Francesco Corti Date: Mon, 4 Jun 2018 10:07:50 +0200 Subject: [PATCH 1/6] Typo in description. Suggested from the Community. (thank you Digicat and Yreg) --- archetypes/alfresco-allinone-archetype/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archetypes/alfresco-allinone-archetype/pom.xml b/archetypes/alfresco-allinone-archetype/pom.xml index bf051d62..896f58e4 100644 --- a/archetypes/alfresco-allinone-archetype/pom.xml +++ b/archetypes/alfresco-allinone-archetype/pom.xml @@ -6,7 +6,7 @@ alfresco-allinone-archetype maven-archetype Alfresco SDK - All-in-One Archetype - Sample multi-module project for All-in-One development on the Alfresco plaftorm. Includes modules for Platform/Repository JAR and Share JAR + Sample multi-module project for All-in-One development on the Alfresco platform. Includes modules for Platform/Repository JAR and Share JAR org.alfresco.maven From dced89eda6a2e9738edb54b7fb4e7f0625ebfa65 Mon Sep 17 00:00:00 2001 From: Gregory Melahn Date: Thu, 13 Sep 2018 16:16:19 -0400 Subject: [PATCH 2/6] Updated the readme to bring it up-to-date. See Issue #396 --- README.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9f192f04..9ffbbfa6 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,12 @@ This is the home of the Alfresco SDK. The Alfresco SDK is used by developers to build extensions for the Alfresco Digital Business Platform. It is based on [Apache Maven](http://maven.apache.org/), compatible with major IDEs and enables Rapid Application Development (RAD) and Test Driven Development (TDD). ## License -This project is released under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). If you are an Enterprise customer check the [Support](#alfresco-enterprise-customers-and-partners-support) section. +This project is released under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) license. +If you are an Enterprise customer check the [Support](#alfresco-enterprise-customers-and-partners-support) section. ## News -- 2017-06-23: Alfresco SDK 3.0.1 released, [containing a critial bugfix](https://github.com/Alfresco/alfresco-sdk/issues/461) +- 2017-06-23: Alfresco SDK 3.0.1 released, [containing a critical bugfix](https://github.com/Alfresco/alfresco-sdk/issues/461) - 2017-04-01: Alfresco SDK 3.0.0 released - 2017-03-27: After years of hard work, countless iterations and gathering feedback, SDK 3.0 has finally been merged into the master branch, ready for release in the coming days - 2016-02-20: SDK 2.2.0 released to Maven Central. Docs for [Community](http://docs.alfresco.com/community/concepts/alfresco-sdk-intro.html), [Enterprise](http://docs.alfresco.com/5.1/concepts/alfresco-sdk-intro.html), [Release notes](https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-sdk-aggregator/latest/github-report.html) @@ -20,16 +21,15 @@ This project is released under the [Apache License, Version 2.0](http://www.apac ## User Getting Started ### Latest Documentation -To get started with Alfresco SDK 2.2.0 (latest) visit the offical Alfresco Documentation for: - -- [Alfresco Community 5.1 and above](http://docs.alfresco.com/community/concepts/alfresco-sdk-intro.html) -- [Alfresco Enterprise 5.1 and above](http://docs.alfresco.com/5.1/concepts/alfresco-sdk-intro.html) - -#### Previous versions Documentation -- Documentation for [Alfresco SDK 2.1](http://docs.alfresco.com/sdk2.1/concepts/alfresco-sdk-intro.html) (compatible with Alfresco 5.0.d Community and 5.0.1 Enterprise) -- Documentation for [Alfresco SDK 2.0](http://docs.alfresco.com/sdk2.0/concepts/alfresco-sdk-intro.html) (compatible with Alfresco 5.0.c Community and 5.0.0 Enterprise) -- Documentation for [Alfresco SDK 1.1.1](http://docs.alfresco.com/4.2/concepts/dev-extensions-maven-sdk-intro.html) (compatible with Alfresco 4.2) +To get started with **Alfresco SDK 3.0.x** (latest) visit the [Alfresco Documentation](https://docs.alfresco.com/5.2/concepts/sdk-intro.html) +#### Documentation about Previous Versions +| SDK Version | Alfresco Enterprise Version | Alfresco Community Version | Documentation | +| ------------- |:-------------:| :-----:|:-----| +| SDK 2.2 | Alfresco 5.1.x | Alfresco 5.1.x | https://docs.alfresco.com/5.1/concepts/alfresco-sdk-intro.html | +| SDK 2.1 | Alfresco 5.0.1 | Alfresco 5.0.d | https://docs.alfresco.com/sdk2.1/concepts/alfresco-sdk-intro.html | +| SDK 2.0 | Alfresco 5.0.0 | Alfresco 5.0.c | https://docs.alfresco.com/sdk2.0/concepts/alfresco-sdk-intro.html | +| SDK 1.1.1 | Alfresco 4.2.x | Alfresco 4.2.x | https://docs.alfresco.com/4.2/concepts/dev-extensions-maven-sdk-intro.html | @@ -37,19 +37,22 @@ To get started with Alfresco SDK 2.2.0 (latest) visit the offical Alfresco Docum Report issues (and contribute!) [here](https://github.com/Alfresco/alfresco-sdk/issues?milestone=1&state=open) or join us on the [IRC Channel](http://chat.alfresco.com/). ## Alfresco Enterprise Customers and Partners Support -If you are an Alfresco Customer please check the [SDK Support status](http://www.alfresco.com/services/subscription/technical-support/product-support-status) for the version you are using and the [Compatibily Matrix](http://docs.alfresco.com/community/concepts/alfresco-sdk-compatibility.html) for the SDK / Alfresco compatibility. If your version is in Limited or Full Support, you can raise issues via the [Support Portal](http://support.alfresco.com). +If you are an Alfresco Customer +please check the [SDK Support status](http://www.alfresco.com/services/subscription/technical-support/product-support-status) +for the version you are using. If your version is in Limited or Full Support and you need help, visit the [Support Portal](http://support.alfresco.com). ## Maven repositories - As of version 2.0-beta-1, The Alfresco SDK is released in [Maven Central](http://search.maven.org/#search|ga|1|alfresco-sdk). Previous versions are available in the [Alfresco Artifacts Repository](https://artifacts.alfresco.com/). - Alfresco (Community and Enterprise) artifacts are hosted in the [Alfresco Artifacts Repository](https://artifacts.alfresco.com/). - Alfresco Community artifacts (JARs, WARs, AMPs, poms) and SDK artifacts are publicly available. -*NOTE:* For Enterprise and Premiere licensed software access you need to get credential via the Alfresco Enterprise Support. See [Maven Alfresco Enterprise setup](http://docs.alfresco.com/5.0/concepts/alfresco-sdk-using-enterprise-edition.html). +*NOTE:* By default the Alfresco SDK will use Community Edition releases but it can be configured to use Enterprise Edition releases. Enterprise and Premier customers can use the SDK with +Enterprise Edition releases by following the process described in [Working with Enterprise](https://docs.alfresco.com/5.2/concepts/sdk-using-enterprise.html) ### Alfresco Artifacts Repository #### Alfresco Releases -You can use the following snippet in your pom.xml to access releases on Alfresco Artifact repository: +You can use the following snippet in your pom.xml to access releases from the Alfresco Artifact repository: ```xml From 376815c746b0586ff7079fd20b96405610bd01b1 Mon Sep 17 00:00:00 2001 From: Jose Luis Osorno Date: Fri, 18 Jan 2019 12:29:32 +0100 Subject: [PATCH 3/6] MNT-19097 - Ensure unmount war files Ensure the unmount of the war files in the alfresco maven plugin to avoid the exception thrown by the FsSyncShutdownHook. --- plugins/alfresco-maven-plugin/pom.xml | 5 +++++ .../java/org/alfresco/maven/plugin/AbstractRunMojo.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/alfresco-maven-plugin/pom.xml b/plugins/alfresco-maven-plugin/pom.xml index 1c42bc4c..ed027a15 100644 --- a/plugins/alfresco-maven-plugin/pom.xml +++ b/plugins/alfresco-maven-plugin/pom.xml @@ -140,6 +140,11 @@ zt-zip 1.11 + + de.schlichtherle.truezip + truezip-kernel + 7.7.9 + diff --git a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java index 187cc9e4..43f70ab1 100644 --- a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java +++ b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java @@ -17,6 +17,8 @@ */ package org.alfresco.maven.plugin; +import de.schlichtherle.truezip.file.TVFS; +import de.schlichtherle.truezip.fs.FsSyncException; import org.alfresco.maven.plugin.config.ModuleDependency; import org.alfresco.maven.plugin.config.TomcatDependency; import org.alfresco.maven.plugin.config.TomcatWebapp; @@ -1177,6 +1179,13 @@ public abstract class AbstractRunMojo extends AbstractMojo { execEnv ); } + + // Force the unmount of all the files mounted with TrueZIP to avoid an exception in the FsSyncShutdownHook + try { + TVFS.umount(); + } catch (final FsSyncException e) { + getLog().error(e); + } } /** From 2871883c7d985861b49acb07263d493619b95818 Mon Sep 17 00:00:00 2001 From: Jose Luis Osorno Date: Fri, 18 Jan 2019 15:50:38 +0100 Subject: [PATCH 4/6] 499 - Maven Plugin - Add the ability to set Tomcat version Add a new parameter to the Alfresco Maven Plugin in order to be able to set the Tomcat version to be executed when running Tomcat through the Tomcat Maven Plugin. The parameter "tomcatVersion" (or the Maven property "maven.alfresco.tomcat.version") allows to modify the default Tomcat version used by the Tomcat Maven Plugin. The default version currently is 7.0.47 (set by the Tomcat Maven Plugin v2.2). If the version of Tomcat is not set via the plugin parameter or the maven property, then the default one is used. --- .../maven/plugin/AbstractRunMojo.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java index 92171f62..2eff576c 100644 --- a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java +++ b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java @@ -17,9 +17,11 @@ */ package org.alfresco.maven.plugin; +import com.google.common.collect.ImmutableSet; import org.alfresco.maven.plugin.config.ModuleDependency; import org.alfresco.maven.plugin.config.TomcatDependency; import org.alfresco.maven.plugin.config.TomcatWebapp; +import org.alfresco.util.Pair; import org.apache.commons.lang.StringUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -40,6 +42,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import static org.twdata.maven.mojoexecutor.MojoExecutor.*; @@ -67,6 +70,29 @@ public abstract class AbstractRunMojo extends AbstractMojo { public static final String ALFRESCO_ENTERPRISE_EDITION = "enterprise"; public static final String ALFRESCO_COMMUNITY_EDITION = "community"; + private static final String TOMCAT_GROUP_ID = "org.apache.tomcat"; + private static final String TOMCAT_EMBED_GROUP_ID = "org.apache.tomcat.embed"; + private static final Set> TOMCAT_DEPENDENCIES = new ImmutableSet.Builder>() + .add(new Pair(TOMCAT_EMBED_GROUP_ID,"tomcat-embed-core")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-util")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-coyote")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-api")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-jdbc")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-dbcp")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-servlet-api")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-jsp-api")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-jasper")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-jasper-el")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-el-api")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-catalina")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-tribes")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-catalina-ha")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-annotations-api")) + .add(new Pair(TOMCAT_GROUP_ID,"tomcat-juli")) + .add(new Pair(TOMCAT_EMBED_GROUP_ID,"tomcat-embed-logging-juli")) + .add(new Pair(TOMCAT_EMBED_GROUP_ID,"tomcat-embed-logging-log4j")) + .build(); + @Component protected MavenProject project; @@ -351,6 +377,13 @@ public abstract class AbstractRunMojo extends AbstractMojo { @Parameter(property = "solr.home", defaultValue = "${project.basedir}/${alfresco.data.location}/solr") protected String solrHome; + /** + * Tomcat version to be used in the Maven Tomcat Plugin. If this parameter is not set, then the + * default Tomcat version will be used (it depends on the version of the Tomcat Maven Plugin). + */ + @Parameter(property = "maven.alfresco.tomcat.version") + protected String tomcatVersion; + /** * Maven GAV properties for customized alfresco.war, share.war, activiti-app.war * Used by the Maven Tomcat 7 Plugin @@ -1341,6 +1374,11 @@ public abstract class AbstractRunMojo extends AbstractMojo { dependency("org.postgresql", "postgresql", "9.4-1201-jdbc41")); } + // If a custom version of Tomcat is required add the corresponding dependencies + if(StringUtils.isNotBlank(tomcatVersion)) { + addTomcatDependencies(tomcatPluginDependencies); + } + if (enablePlatform) { webapps2Deploy.add(createWebAppElement( runnerAlfrescoGroupId, runnerAlfrescoPlatformWarArtifactId, runnerAlfrescoPlatformVersion, @@ -1788,4 +1826,16 @@ public abstract class AbstractRunMojo extends AbstractMojo { private String getWarName(String baseWarName) { return baseWarName + "-war"; } + + /** + * Add all the required maven dependencies to execute a specific version of Tomcat set by the property tomcatVersion to the list of + * dependencies of the Tomcat Maven Plugin. + * + * @param tomcatPluginDependencies current list of dependencies of the Tomcat Maven Plugin + */ + private void addTomcatDependencies(List tomcatPluginDependencies) { + for(Pair tomcatDependency : TOMCAT_DEPENDENCIES) { + tomcatPluginDependencies.add(dependency(tomcatDependency.getFirst(),tomcatDependency.getSecond(),tomcatVersion)); + } + } } From e3ae54be9ba88827dbb3daf3f6ccf5a80486b70c Mon Sep 17 00:00:00 2001 From: Jose Luis Osorno Date: Mon, 21 Jan 2019 08:28:41 +0100 Subject: [PATCH 5/6] 498 - Archetypes - Add module-specific log4j.properties to AMPs Add module-specific log4j.properties files to the archetypes and modify the assembly files to include them in the AMPs. This way, it is possible to add custom log configuration for each developed module. --- .../src/main/assembly/amp.xml | 5 +++++ .../alfresco/module/__artifactId__/log4j.properties | 1 + .../__rootArtifactId__-share-jar/src/main/assembly/amp.xml | 5 +++++ .../module/__rootArtifactId__-share-jar/log4j.properties | 1 + .../resources/archetype-resources/src/main/assembly/amp.xml | 5 +++++ .../alfresco/module/__artifactId__/log4j.properties | 1 + .../resources/archetype-resources/src/main/assembly/amp.xml | 5 +++++ .../alfresco/module/__artifactId__/log4j.properties | 1 + 8 files changed, 24 insertions(+) create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/resources/alfresco/module/__artifactId__/log4j.properties create mode 100644 archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/resources/alfresco/module/__rootArtifactId__-share-jar/log4j.properties create mode 100644 archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties create mode 100644 archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/assembly/amp.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/assembly/amp.xml index e41c098c..447a6458 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/assembly/amp.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/assembly/amp.xml @@ -35,6 +35,11 @@ src/main/assembly/file-mapping.properties false + + + src/main/resources/alfresco/module/${project.artifactId}/log4j.properties + false + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/resources/alfresco/module/__artifactId__/log4j.properties b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/resources/alfresco/module/__artifactId__/log4j.properties new file mode 100644 index 00000000..29523b48 --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-platform-jar/src/main/resources/alfresco/module/__artifactId__/log4j.properties @@ -0,0 +1 @@ +# Add here module-specific custom log4j.properties configuration \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/assembly/amp.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/assembly/amp.xml index 512c9071..b8bef443 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/assembly/amp.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/assembly/amp.xml @@ -35,6 +35,11 @@ src/main/assembly/file-mapping.properties false + + + src/main/resources/alfresco/module/${project.artifactId}/log4j.properties + false + diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/resources/alfresco/module/__rootArtifactId__-share-jar/log4j.properties b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/resources/alfresco/module/__rootArtifactId__-share-jar/log4j.properties new file mode 100644 index 00000000..29523b48 --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/__rootArtifactId__-share-jar/src/main/resources/alfresco/module/__rootArtifactId__-share-jar/log4j.properties @@ -0,0 +1 @@ +# Add here module-specific custom log4j.properties configuration \ No newline at end of file diff --git a/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml b/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml index ba989675..494331a5 100644 --- a/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml +++ b/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml @@ -35,6 +35,11 @@ src/main/assembly/file-mapping.properties false + + + src/main/resources/alfresco/module/${project.artifactId}/log4j.properties + false + diff --git a/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties b/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties new file mode 100644 index 00000000..29523b48 --- /dev/null +++ b/archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties @@ -0,0 +1 @@ +# Add here module-specific custom log4j.properties configuration \ No newline at end of file diff --git a/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml b/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml index 9f17de85..54556778 100644 --- a/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml +++ b/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/assembly/amp.xml @@ -35,6 +35,11 @@ src/main/assembly/file-mapping.properties false + + + src/main/resources/alfresco/module/${project.artifactId}/log4j.properties + false + diff --git a/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties b/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties new file mode 100644 index 00000000..29523b48 --- /dev/null +++ b/archetypes/alfresco-share-jar-archetype/src/main/resources/archetype-resources/src/main/resources/alfresco/module/__artifactId__/log4j.properties @@ -0,0 +1 @@ +# Add here module-specific custom log4j.properties configuration \ No newline at end of file From 9d1c2feaf2cb728664986d63592c94f7eb9db3a9 Mon Sep 17 00:00:00 2001 From: Jose Luis Osorno Date: Mon, 21 Jan 2019 15:16:46 +0100 Subject: [PATCH 6/6] 469 - Maven Plugin - AMP files order Modify the Alfresco Maven Plugin in order to take into account the order in which the AMP modules were defined as the same order of the AMPs to be applied to the war files. --- .../maven/plugin/AbstractRunMojo.java | 67 +++++++++++++++---- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java index f80c79f8..9216a4d9 100644 --- a/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java +++ b/plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/AbstractRunMojo.java @@ -95,6 +95,8 @@ public abstract class AbstractRunMojo extends AbstractMojo { .add(new Pair(TOMCAT_EMBED_GROUP_ID,"tomcat-embed-logging-log4j")) .build(); + private static final String AMP_LOCATION_PATTERN = "%s/%s-%s.amp"; + @Component protected MavenProject project; @@ -1227,18 +1229,7 @@ public abstract class AbstractRunMojo extends AbstractMojo { ); // Then apply all these amps to the unpacked war - // Call the Alfresco Maven Plugin Install Mojo directly, so we don't have to keep SDK version info here - String ampsLocation = project.getBuild().getDirectory() + "/" + ampsModuleDir; - String warLocation = project.getBuild().getDirectory() + "/" + getWarName(warName); - InstallMojo installMojo = new InstallMojo(); - installMojo.setAmpLocation(new File(ampsLocation)); - installMojo.setWarLocation(new File(warLocation)); - installMojo.setForce(true); - try { - installMojo.execute(); - } catch (MojoFailureException e) { - e.printStackTrace(); - } + applyAMPs(warName, modules); } // Then copy all JAR dependencies to the unpacked war /target/-war/WEB-INF/lib @@ -1847,4 +1838,56 @@ public abstract class AbstractRunMojo extends AbstractMojo { tomcatPluginDependencies.add(dependency(tomcatDependency.getFirst(),tomcatDependency.getSecond(),tomcatVersion)); } } + + /** + * Apply a list of AMPs to a specific war file. + * + * @param warName the name of the war file to apply the AMPs to + * @param modules the list of proposed modules to be applied to the war file. Only the AMP files will be applied + * @throws MojoExecutionException when any problem appears applying the AMPs to the war + */ + private void applyAMPs(String warName, List modules) throws MojoExecutionException { + final String ampsModuleDir = "modules/" + warName + "/amps"; + final String ampsLocation = project.getBuild().getDirectory() + "/" + ampsModuleDir; + final String warLocation = project.getBuild().getDirectory() + "/" + getWarName(warName); + + // Apply one AMP module each time to preserve the order applying the AMPs to the war + for(ModuleDependency module : modules) { + if(module.isAmp()) { + applyAMP(ampsLocation, warLocation, module); + } + } + } + + /** + * Apply an AMP to a specific war file. + * + * @param ampsLocation the location of the folder where the AMP is located + * @param warLocation the location of the war file to apply the AMP to + * @param ampModule the module that represents the AMP to apply + * @throws MojoExecutionException when any problem appears applying the AMP to the war + */ + private void applyAMP(String ampsLocation, String warLocation, ModuleDependency ampModule) throws MojoExecutionException { + // Call the Alfresco Maven Plugin Install Mojo directly, so we don't have to keep SDK version info here + InstallMojo installMojo = new InstallMojo(); + installMojo.setAmpLocation(new File(getAMPLocation(ampsLocation, ampModule))); + installMojo.setWarLocation(new File(warLocation)); + installMojo.setForce(true); + try { + installMojo.execute(); + } catch (MojoFailureException e) { + getLog().error(e); + } + } + + /** + * Build the location of an AMP file. + * + * @param ampsLocation the location of the folder where the AMPs are located + * @param ampModule the {@link ModuleDependency} of the AMP to build its location + * @return the location of the AMP file + */ + private String getAMPLocation(String ampsLocation, ModuleDependency ampModule) { + return String.format(AMP_LOCATION_PATTERN, ampsLocation, ampModule.getArtifactId(), ampModule.getVersion()); + } }