DEVPLAT-49 - Split clear-caches-refresh-ws profile into one for repo and one for share and make port number configurable

This commit is contained in:
Martin Bergljung
2015-04-28 15:21:44 +01:00
parent 4c0e340ab4
commit ed7e5e2ead
2 changed files with 95 additions and 28 deletions

View File

@@ -23,9 +23,6 @@
Allowed values: alfresco | share. In this case it's configured to use OOTB share --> Allowed values: alfresco | share. In this case it's configured to use OOTB share -->
<alfresco.client.war>share</alfresco.client.war> <alfresco.client.war>share</alfresco.client.war>
<!-- Since Alfresco Repository is already running on port 8080, we run Share on port 8081 -->
<maven.tomcat.port>8081</maven.tomcat.port>
<!-- Used in share-config-custom.xml. By default points to standard location of Alfresco Repository --> <!-- Used in share-config-custom.xml. By default points to standard location of Alfresco Repository -->
<alfresco.repo.url>http://localhost:8080/alfresco</alfresco.repo.url> <alfresco.repo.url>http://localhost:8080/alfresco</alfresco.repo.url>

View File

@@ -151,6 +151,10 @@
--> -->
<maven.alfresco.version>2.0.1-SNAPSHOT</maven.alfresco.version> <maven.alfresco.version>2.0.1-SNAPSHOT</maven.alfresco.version>
<!-- Setup the default Embedded Tomcat port for use by the tomcat7-maven-plugin so
it can be accessed from the Groovy scripts and other places -->
<maven.tomcat.port>8080</maven.tomcat.port>
<!-- Sets the H2 Database version to use. <!-- Sets the H2 Database version to use.
Note. Upgrading to 1.4.186 did not work, on second start (after initial db creation etc) it will not connect... --> Note. Upgrading to 1.4.186 did not work, on second start (after initial db creation etc) it will not connect... -->
<h2.version>1.4.185</h2.version> <h2.version>1.4.185</h2.version>
@@ -407,6 +411,25 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<!-- Important to execute the Groovy scripts in the compile phase,
otherwise the files will be copied after this and the web script
refresh will not be recognized.
See the refresh-share and refresh-repo profiles.
-->
<phase>compile</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
@@ -496,12 +519,73 @@
</profile> </profile>
<!-- <!--
Clear JS & CSS Dependency Caches for Share, Refresh Repo & Share Web Scripts. Refresh Spring Surf Web Scripts and clear JS & CSS Dependency Caches for Share.
You will have to activate this profile manually while you are compiling. You will have to activate this profile manually while you are compiling.
For example: $mvn compile -Pclear-caches-refresh-ws For example: $mvn compile -Prefresh-share
--> -->
<profile> <profile>
<id>clear-caches-refresh-ws</id> <id>refresh-share</id>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<configuration>
<properties>
<tomcatPort>${maven.tomcat.port}</tomcatPort>
</properties>
<!-- See pluginManagement for the rest of the configuration -->
<source>
<![CDATA[
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseException
import org.apache.http.conn.HttpHostConnectException
import static groovyx.net.http.ContentType.*
try {
def share = new RESTClient('http://localhost:' + project.properties.tomcatPort + '/share/')
// Clear Alfresco Share Dependency Caches for JS, CSS, Templates
def clearDependencyCachesPath = 'page/caches/dependency/clear'
share.auth.basic 'admin', 'admin'
def resp = share.post(path: clearDependencyCachesPath)
log.info "\nRequest: Alfresco Share Clear Dependency Caches. Response status: ${resp.status}"
// Refresh Share Web Scripts
refreshWebScriptsPath = 'page/index'
resp = share.post(path: refreshWebScriptsPath, body: [reset: 'on', submit: 'Refresh Web Scripts'], requestContentType: URLENC)
log.info "\nRequest: Alfresco Share Refresh Web Scripts. Response status: ${resp.status}"
} catch (HttpHostConnectException hcex) {
println "Embedded Tomcat is not running, skipping Share Webapp Refresh."
} catch (HttpResponseException ex) {
println "Unexpected response error: ${ex.statusCode}"
}
]]>
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!--
Refresh Repository Web Scripts.
You will have to activate this profile manually while you are compiling.
For example: $mvn compile -Prefresh-repo
-->
<profile>
<id>refresh-repo</id>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId> <groupId>org.codehaus.groovy.modules.http-builder</groupId>
@@ -517,42 +601,28 @@
<version>1.0</version> <version>1.0</version>
<executions> <executions>
<execution> <execution>
<!-- Important to do this in the compile phase, otherwise the files will be copied
after this and the web script refresh will not be recognized
-->
<phase>compile</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration> <configuration>
<properties>
<tomcatPort>${maven.tomcat.port}</tomcatPort>
</properties>
<!-- See pluginManagement for the rest of the configuration -->
<source> <source>
<![CDATA[ <![CDATA[
import groovyx.net.http.RESTClient import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseException import groovyx.net.http.HttpResponseException
import org.apache.http.conn.HttpHostConnectException
import static groovyx.net.http.ContentType.* import static groovyx.net.http.ContentType.*
try { try {
def alfresco = new RESTClient('http://localhost:8080/alfresco/') def alfresco = new RESTClient('http://localhost:' + project.properties.tomcatPort + '/alfresco/')
// Refresh Alfresco Repo Web Scripts // Refresh Alfresco Repo Web Scripts
def refreshWebScriptsPath = 's/index' def refreshWebScriptsPath = 's/index'
alfresco.auth.basic 'admin', 'admin' alfresco.auth.basic 'admin', 'admin'
def resp = alfresco.post(path: refreshWebScriptsPath, body: [reset: 'on', submit: 'Refresh Web Scripts'], requestContentType: URLENC) def resp = alfresco.post(path: refreshWebScriptsPath, body: [reset: 'on', submit: 'Refresh Web Scripts'], requestContentType: URLENC)
log.info "\nRequest: Alfresco Repo Refresh Web Scripts. Response status: ${resp.status}" log.info "\nRequest: Alfresco Repo Refresh Web Scripts. Response status: ${resp.status}"
} catch (HttpHostConnectException hcex) {
def share = new RESTClient('http://localhost:8080/share/') println "Embedded Tomcat is not running, skipping Repo Webapp Refresh."
// Clear Alfresco Share Dependency Caches for JS, CSS, Templates
def clearDependencyCachesPath = 'page/caches/dependency/clear'
share.auth.basic 'admin', 'admin'
resp = share.post(path: clearDependencyCachesPath)
log.info "\nRequest: Alfresco Share Clear Dependency Caches. Response status: ${resp.status}"
// Refresh Share Web Scripts
refreshWebScriptsPath = 'page/index'
share.auth.basic 'admin', 'admin'
resp = share.post(path: refreshWebScriptsPath, body: [reset: 'on', submit: 'Refresh Web Scripts'], requestContentType: URLENC)
log.info "\nRequest: Alfresco Share Refresh Web Scripts. Response status: ${resp.status}"
} catch (HttpResponseException ex) { } catch (HttpResponseException ex) {
println "Unexpected response error: ${ex.statusCode}" println "Unexpected response error: ${ex.statusCode}"
} }