Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Use groovy to install appserver
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jun 11, 2015
1 parent fa82eec commit bbecbd5
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 34 deletions.
51 changes: 51 additions & 0 deletions etc/scripts/extractAppserver.groovy
@@ -0,0 +1,51 @@
/*
* Copyright 2015, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

/**
* @author Sean Flanigan <a href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*/

import groovy.util.AntBuilder

// NB: project is a MavenProject
// http://maven.apache.org/ref/3-LATEST/maven-core/apidocs/org/apache/maven/project/MavenProject.html

String downloadDir = project.properties.get('download.dir') // ~/Downloads
String cargoExtractDir = project.properties.get('cargo.extract.dir') // target/cargo/installs
String url = project.properties.get('cargo.installation') // http://example.com/jbosseap6.zip

String filename = url.substring(url.lastIndexOf('/')+1)
String filePath = "${downloadDir}/${filename}"
String basename = filename.substring(0, filename.lastIndexOf('.'))
String extractDir = "${cargoExtractDir}/${basename}"

def ant = new AntBuilder()
ant.mkdir(dir: downloadDir)
ant.get(src: url, dest: filePath, skipexisting: "true")
ant.unzip(src: filePath, dest:"${extractDir}")

def files = new File(extractDir).listFiles()
if (files.length != 1) {
throw new Exception('zip should contain exactly one top-level dir; see ' + extractDir)
}
def topLevelDir = files[0].path

project.properties.put('appserver.home', topLevelDir)
17 changes: 12 additions & 5 deletions functional-test/pom.xml
Expand Up @@ -476,6 +476,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<id>extract-appserver</id>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -585,10 +595,6 @@
</deployables>
</configuration>
<executions>
<execution>
<id>cargo-install</id>
<phase>prepare-package</phase>
</execution>
<execution>
<id>cargo-start</id>
<phase>pre-integration-test</phase>
Expand Down Expand Up @@ -854,7 +860,7 @@
<configuration>
<target unless="skipFuncTests">
<fail message="'appserver' property must be set to run integration tests (or else use -DskipFuncTests)" unless="appserver" />
<fail message="'cargo.installation' property must be set to run integration tests (or else use -DskipFuncTests)" unless="cargo.installation" />
<fail message="'cargo.installation' property is null (set env var EAP6_URL or else use -DskipFuncTests)" unless="cargo.installation" />
</target>
</configuration>
</execution>
Expand Down Expand Up @@ -903,6 +909,7 @@
<configuration>
<container>
<type>installed</type>
<home>${appserver.home}</home>

<systemProperties>
<ehcache.disk.store.dir>${project.build.directory}/ehcache</ehcache.disk.store.dir>
Expand Down
61 changes: 37 additions & 24 deletions pom.xml
Expand Up @@ -56,11 +56,11 @@
<okapi.version>0.22</okapi.version>

<zanata.assets.version>7.0-SNAPSHOT</zanata.assets.version>
<zanata.api.version>3.7.0-SNAPSHOT</zanata.api.version>
<zanata.api.version>3.7.2</zanata.api.version>
<!-- This should always be the previous version of the used api version above (but only 3.0.1 or later will work) -->
<zanata.api.compat.version>3.4.1</zanata.api.compat.version>
<zanata.client.version>3.7.0-SNAPSHOT</zanata.client.version>
<zanata.common.version>3.6.1-SNAPSHOT</zanata.common.version>
<zanata.common.version>3.7.1</zanata.common.version>

<richfaces.version>4.5.4.Final</richfaces.version>

Expand Down Expand Up @@ -1181,6 +1181,33 @@

<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<!-- NB: This execution needs to be before antrun, because it
creates the wildfly directory for the unzip tasks. -->
<execution>
<id>extract-appserver</id>
<!-- submodules should use 'prepare-package' to activate this -->
<phase>none</phase>
<goals><goal>execute</goal></goals>
<configuration>
<scripts>
<!-- Extracts app server and sets appserver.home -->
<script>file:///${project.basedir}/../etc/scripts/extractAppserver.groovy</script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.zanata</groupId>
<artifactId>zanata-maven-plugin</artifactId>
Expand Down Expand Up @@ -1251,7 +1278,7 @@
<echo message="DISPLAY=${env.DISPLAY}" />
<echo message="WARNING: 'appserver' property must be set unless skippping integration tests"
unless:set="appserver" />
<echo message="WARNING: 'cargo.installation' property (and possibly cargo.basename) must be set unless skipping integration tests"
<echo message="WARNING: 'cargo.installation' property is null. You might need to set the env var EAP6_URL"
unless:set="cargo.installation" />
</target>
</configuration>
Expand All @@ -1277,32 +1304,12 @@
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<version>1.4.14</version>
<configuration combine.self="append">
<container>
<containerId>${cargo.container}</containerId>
<!--if install from url-->
<zipUrlInstaller>
<url>${cargo.installation}</url>
<downloadDir>${download.dir}</downloadDir>
<extractDir>${cargo.extract.dir}</extractDir>
</zipUrlInstaller>
</container>
</configuration>
<executions>
<!-- Download and extract app server under target/ -->
<!-- NB: This execution needs to be before antrun, because it
creates the wildfly directory for the unzip tasks. -->
<!-- TODO use antrun to download and extract appserver? -->
<execution>
<id>cargo-install</id>
<!-- submodules should use 'prepare-package' to activate this -->
<phase>none</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down Expand Up @@ -1391,6 +1398,11 @@
<providerSelection>2.0</providerSelection>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down Expand Up @@ -1487,6 +1499,7 @@
</activation>
<properties>
<cargo.container>jboss72x</cargo.container>
<cargo.installation>${env.EAP6_URL}</cargo.installation>
<!-- name of the top-level dir within the appserver zip -->
<appserver.dir.name>jboss-eap-6.4</appserver.dir.name>
<!-- where the appserver will be installed -->
Expand Down
9 changes: 4 additions & 5 deletions zanata-war/pom.xml
Expand Up @@ -56,7 +56,6 @@
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>default</id>
Expand Down Expand Up @@ -1012,18 +1011,18 @@
<configuration>
<target unless="skipArqTests">
<fail message="'appserver' property must be set to run integration tests (or else use -DskipArqTests)" unless="appserver" />
<fail message="'cargo.installation' property must be set to run integration tests (or else use -DskipArqTests)" unless="cargo.installation" />
<fail message="'cargo.installation' property is null (set env var EAP6_URL or else use -DskipArqTests)" unless="cargo.installation" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<id>cargo-install</id>
<id>extract-appserver</id>
<phase>prepare-package</phase>
</execution>
</executions>
Expand Down

0 comments on commit bbecbd5

Please sign in to comment.