diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 87d50cf5..d1faa76d 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -143,6 +143,12 @@ **/dev-log4j.properties + + src/test/resources + + *hotswap-agent.properties + + src/test/resources @@ -150,6 +156,7 @@ **/dev-log4j.properties + *hotswap-agent.properties diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/integration-tests/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/integration-tests/pom.xml index a0a4a1ea..2231fb97 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/integration-tests/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/integration-tests/pom.xml @@ -30,8 +30,24 @@ + + + src/test/resources + true + + + + + org.zeroturnaround + jrebel-maven-plugin + ${jrebel.version} + + ${project.build.testOutputDirectory} + + + org.apache.maven.plugins @@ -46,34 +62,6 @@ - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.1 - false - - - - copy-and-filter-test-resources - validate - - copy-resources - - - ${project.build.testOutputDirectory} - - - src/test/resources - true - - - - - - - diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml index 80cbae5d..16755fcb 100644 --- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml @@ -237,34 +237,14 @@ + + + src/test/resources + true + + + - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.1 - false - - - - copy-and-filter-test-resources - validate - - copy-resources - - - ${project.build.testOutputDirectory} - - - src/test/resources - true - - - - - - - - - ${alfresco.groupId} - aikau - ${aikau.version} - @@ -361,10 +334,8 @@ all - + ${project.build.outputDirectory} + ${project.build.testOutputDirectory} diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/platform-hotswap-agent.properties b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/platform-hotswap-agent.properties new file mode 100644 index 00000000..bda7d2f7 --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/platform-hotswap-agent.properties @@ -0,0 +1,48 @@ +# Enable hotswap so that changes in this module will be automatically reloaded +# Watch for changed class files on watchResources path and reload class definition in the running application. +autoHotswap=true +#autoHotswap.port=8000 + +# Add a directory prior to application classpath (load classes and resources). +# +# This may be useful for example in multi module maven project to load class changes from upstream project +# classes. Set extraClasspath to upstream project compiler output and .class file will have precedence to +# classes from built JAR file. +# i.e. monitor /target/classes +# should work with extraClasspath=${project.build.outputDirectory} +# If not try +extraClasspath=${project.basedir}/${artifactId}-platform-jar/target/classes;${project.basedir}/${artifactId}-platform-jar/target/test-classes;${project.basedir}/integration-tests/target/classes;${project.basedir}/integration-tests/target/test-classes + +# Comma separated list of disabled plugins +# Use plugin name - e.g. +# Hotswapper, AnonymousClassPatch, WatchResources, Hibernate, Spring, Jersey2, Jetty, Tomcat, +# ZK, Logback, JSF, Seam, ELResolver, OsgiEquinox, Proxy, WebObjects, Weld, JBossModules, Resteasy, Gae +disabledPlugins=Hibernate,Spring + +# Add a directory prior to webapp path (load webapp resources). +# +# Load web application resources (such as HTML, JSP, CSS, ...) from this directory prior to default processing. +# Use this setting to set to serve resources from source directory directly (e.g. src/main/webapp). +extraWebappContext=${project.basedir}/${artifactId}-platform-jar/target/classes/META-INF/resources; + +# Load static web resources from different directory. +# +# This setting is dependent on application server plugin(Jetty, Tomcat, JBoss, ...) +webappDir=${project.basedir}/${artifactId}-platform-jar/target/classes/META-INF/resources; + +# Watch for changes in a directory (resources only). +# +# Similar to extraClasspath this property adds classpath when searching for resources (not classes). +# While extra classpath just modifies the classloader, this setting does nothing until the resource +# is really changed. +# +# Sometimes it is not possible to point extraClasspath to your i.e. src/main/resources, because there are multiple +# replacements of resources in a building step (maven filtering resource option). +# This setting will leave i.e. src/target/classes as default source for resources, but after the resource is modified +# in src/main/resources, the new changed resource is served instead. +# watchResources= + +LOGGER.org.hotswap.agent=DEBUG +#LOGGER.org.hotswap.agent.plugin=TRACE +#LOGGER.org.hotswap.agent.watch=TRACE +#LOGGER.org.hotswap.agent.command=TRACE \ No newline at end of file diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/share-hotswap-agent.properties b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/share-hotswap-agent.properties new file mode 100644 index 00000000..caa0f30f --- /dev/null +++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/src/test/resources/share-hotswap-agent.properties @@ -0,0 +1,49 @@ +# Enable hotswap so that changes in this module will be automatically reloaded +# Watch for changed class files on watchResources path and reload class definition in the running application. +autoHotswap=true +#autoHotswap.port=8000 + +# Add a directory prior to application classpath (load classes and resources). +# +# This may be useful for example in multi module maven project to load class changes from upstream project +# classes. Set extraClasspath to upstream project compiler output and .class file will have precedence to +# classes from built JAR file. +# i.e. monitor /target/classes +# should work with extraClasspath=${project.build.outputDirectory} +# If not try +extraClasspath=${project.basedir}/${artifactId}-share-jar/target/classes;${project.basedir}/${artifactId}-share-jar/target/test-classes + + +# Comma separated list of disabled plugins +# Use plugin name - e.g. +# Hotswapper, AnonymousClassPatch, WatchResources, Hibernate, Spring, Jersey2, Jetty, Tomcat, +# ZK, Logback, JSF, Seam, ELResolver, OsgiEquinox, Proxy, WebObjects, Weld, JBossModules, Resteasy, Gae +disabledPlugins=Hibernate,Spring + +# Add a directory prior to webapp path (load webapp resources). +# +# Load web application resources (such as HTML, JSP, CSS, ...) from this directory prior to default processing. +# Use this setting to set to serve resources from source directory directly (e.g. src/main/webapp). +extraWebappContext=${project.basedir}/${artifactId}-share-jar/target/classes/META-INF/resources; + +# Load static web resources from different directory. +# +# This setting is dependent on application server plugin(Jetty, Tomcat, JBoss, ...) +webappDir=${project.basedir}/${artifactId}-share-jar/target/classes/META-INF/resources; + +# Watch for changes in a directory (resources only). +# +# Similar to extraClasspath this property adds classpath when searching for resources (not classes). +# While extra classpath just modifies the classloader, this setting does nothing until the resource +# is really changed. +# +# Sometimes it is not possible to point extraClasspath to your i.e. src/main/resources, because there are multiple +# replacements of resources in a building step (maven filtering resource option). +# This setting will leave i.e. src/target/classes as default source for resources, but after the resource is modified +# in src/main/resources, the new changed resource is served instead. +# watchResources= + +LOGGER.org.hotswap.agent=DEBUG +#LOGGER.org.hotswap.agent.plugin=TRACE +#LOGGER.org.hotswap.agent.watch=TRACE +#LOGGER.org.hotswap.agent.command=TRACE \ No newline at end of file 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 f54f54f6..2bd2ba29 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 @@ -21,7 +21,6 @@ import org.alfresco.maven.plugin.config.ModuleDependency; import org.alfresco.maven.plugin.config.TomcatDependency; import org.alfresco.maven.plugin.config.TomcatWebapp; import org.apache.commons.lang.StringUtils; -import org.apache.commons.net.telnet.TelnetClient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -38,10 +37,6 @@ import org.codehaus.plexus.util.FileUtils; import org.zeroturnaround.zip.ZipUtil; import java.io.File; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -81,6 +76,9 @@ public abstract class AbstractRunMojo extends AbstractMojo { @Component protected BuildPluginManager pluginManager; + @Parameter(property = "reactorProjects", required = true, readonly = true) + protected List reactorProjects; + /** * The following properties that start with 'maven.' are used to control the * Alfresco Maven plugin itself. @@ -148,6 +146,13 @@ public abstract class AbstractRunMojo extends AbstractMojo { @Parameter(property = "maven.alfresco.enablePlatform", defaultValue = "true") protected boolean enablePlatform; + /** + * Enable or disable generation of Hotswap Agent configuration + */ + @Parameter(property = "maven.alfresco.copyHotswapAgentConfig", defaultValue = "true") + protected boolean copyHotswapAgentConfig; + + /** * Switch to enable/disable the Share (share.war) when running embedded Tomcat. */ @@ -821,6 +826,40 @@ public abstract class AbstractRunMojo extends AbstractMojo { ); } + + /** + * Copy and Build hotswap-agent.properties + * + * @throws MojoExecutionException + */ + protected void copyHotswapAgentProperties(String warPrefix) throws MojoExecutionException { + if ( copyHotswapAgentConfig == false ) { + return; + } + + final String warOutputDir = getWarOutputDir(warPrefix) + "/WEB-INF/classes/"; + + + getLog().info("Copying " + warPrefix + "-hotswap-agent.properties to " + warOutputDir); + + executeMojo( + plugin( + groupId("com.coderplus.maven.plugins"), + artifactId("copy-rename-maven-plugin"), + version("1.0") + ), + goal("rename"), + configuration( + element(name("sourceFile"), project.getBuild().getTestOutputDirectory() + "/" + warPrefix + "-hotswap-agent.properties"), + element(name("destinationFile"), warOutputDir + "hotswap-agent.properties") + ), + execEnv + ); + + + + } + /** * Build the customized Platform webapp (i.e. the Repository, alfresco.war) * that should be deployed by Tomcat by applying all AMPs and JARs from @@ -832,6 +871,7 @@ public abstract class AbstractRunMojo extends AbstractMojo { commentOutSecureCommsInPlatformWebXml(); copyAlfrescoLicense(); + copyHotswapAgentProperties(PLATFORM_WAR_PREFIX_NAME); String platformWarArtifactId = packageAndInstallCustomWar(PLATFORM_WAR_PREFIX_NAME); @@ -852,6 +892,8 @@ public abstract class AbstractRunMojo extends AbstractMojo { copyShareLog4jConfig(); copyShareConfigCustom(); + copyHotswapAgentProperties(SHARE_WAR_PREFIX_NAME); + String shareWarArtifactId = packageAndInstallCustomWar(SHARE_WAR_PREFIX_NAME);