* Changing run scripts to execute maven package/verify instead of install (and to run unit tests during build).

* Changing artifacts collection for docker deployment in platform-docker module to use scopes (for integration tests) and adding comment how to deal with amps only or amps+jars extenstions.
This commit is contained in:
Piotr Anders
2019-02-07 17:11:16 +01:00
parent 2db3051599
commit 6e5445a271
7 changed files with 69 additions and 96 deletions

View File

@@ -22,6 +22,25 @@
<artifactId>${rootArtifactId}-platform</artifactId> <artifactId>${rootArtifactId}-platform</artifactId>
<version>${version}</version> <version>${version}</version>
</dependency> </dependency>
<dependency>
<groupId>${groupId}</groupId>
<artifactId>${rootArtifactId}-integration-tests</artifactId>
<version>${version}</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<!-- Add any additional AMPs or extension JARs here that you want to be deployed in Alfresco -->
<!-- IMPORTANT:
If using amp extensions only, add <includeTypes>amp</includeTypes> to the "collect-extensions" execution below.
If using both amp and jar extensions, you have to add:
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
to each amp dependency definition.
-->
</dependencies> </dependencies>
<build> <build>
@@ -30,66 +49,29 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<!-- Copy the dependencies required for execute integration tests --> <!-- Copy the repository extension and the dependencies required for execute integration tests -->
<execution> <execution>
<id>copy-test-dependencies</id> <id>collect-test-artifacts</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<!-- Test dependencies -->
<!-- We need these dependencies installed in ACS in order to execute the test remotely making use of the Alfresco RAD module -->
<artifactItem>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-rad</artifactId>
<version>${alfresco.sdk.version}</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>${groupId}</groupId>
<artifactId>${rootArtifactId}-integration-tests</artifactId>
<version>${version}</version>
<classifier>tests</classifier>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<!-- Copy the dependencies (JARs or AMPs) declared in this module -->
<execution>
<id>copy-third-party-dependencies</id>
<phase>pre-integration-test</phase> <phase>pre-integration-test</phase>
<goals> <goals>
<goal>copy-dependencies</goal> <goal>copy-dependencies</goal>
</goals> </goals>
<configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
<excludeScope>compile</excludeScope>
</configuration>
</execution>
<!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
<execution>
<id>collect-extensions</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory> <outputDirectory>${project.build.directory}/extensions</outputDirectory>
<includeScope>runtime</includeScope> <includeScope>runtime</includeScope>
<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@@ -17,7 +17,6 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- Add here any JAR or AMP dependency that needs to be deployed to ACS -->
</dependencies> </dependencies>
<build> <build>

View File

@@ -30,16 +30,17 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<!-- Copy the dependencies (JARs or AMPs) declared in this module --> <!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
<execution> <execution>
<id>copy-third-party-dependencies</id> <id>collect-extensions</id>
<phase>pre-integration-test</phase> <phase>package</phase>
<goals> <goals>
<goal>copy-dependencies</goal> <goal>copy-dependencies</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/extensions</outputDirectory> <outputDirectory>${project.build.directory}/extensions</outputDirectory>
<includeScope>runtime</includeScope> <includeScope>runtime</includeScope>
<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@@ -25,7 +25,6 @@
<artifactId>share</artifactId> <artifactId>share</artifactId>
<classifier>classes</classifier> <classifier>classes</classifier>
</dependency> </dependency>
<!-- Add here any JAR or AMP dependency that needs to be deployed to share -->
</dependencies> </dependencies>
<build> <build>

View File

@@ -56,6 +56,7 @@ IF %1==reload_acs (
IF %1==build_test ( IF %1==build_test (
CALL :down CALL :down
CALL :build CALL :build
CALL :prepare-test
CALL :start CALL :start
CALL :test CALL :test
CALL :tail_all CALL :tail_all
@@ -88,17 +89,17 @@ EXIT /B 0
) )
EXIT /B 0 EXIT /B 0
:build :build
call %MVN_EXEC% clean install -DskipTests call %MVN_EXEC% clean package
EXIT /B 0 EXIT /B 0
:build_share :build_share
docker-compose -f "%COMPOSE_FILE_PATH%" kill ${rootArtifactId}-share docker-compose -f "%COMPOSE_FILE_PATH%" kill ${rootArtifactId}-share
docker-compose -f "%COMPOSE_FILE_PATH%" rm -f ${rootArtifactId}-share docker-compose -f "%COMPOSE_FILE_PATH%" rm -f ${rootArtifactId}-share
call %MVN_EXEC% clean install -DskipTests -pl ${rootArtifactId}-share call %MVN_EXEC% clean package -pl ${rootArtifactId}-share,${rootArtifactId}-share-docker
EXIT /B 0 EXIT /B 0
:build_acs :build_acs
docker-compose -f "%COMPOSE_FILE_PATH%" kill ${rootArtifactId}-acs docker-compose -f "%COMPOSE_FILE_PATH%" kill ${rootArtifactId}-acs
docker-compose -f "%COMPOSE_FILE_PATH%" rm -f ${rootArtifactId}-acs docker-compose -f "%COMPOSE_FILE_PATH%" rm -f ${rootArtifactId}-acs
call %MVN_EXEC% clean install -DskipTests -pl ${rootArtifactId}-platform call %MVN_EXEC% clean package -pl ${rootArtifactId}-platform,${rootArtifactId}-platform-docker
EXIT /B 0 EXIT /B 0
:tail :tail
docker-compose -f "%COMPOSE_FILE_PATH%" logs -f docker-compose -f "%COMPOSE_FILE_PATH%" logs -f
@@ -106,8 +107,11 @@ EXIT /B 0
:tail_all :tail_all
docker-compose -f "%COMPOSE_FILE_PATH%" logs --tail="all" docker-compose -f "%COMPOSE_FILE_PATH%" logs --tail="all"
EXIT /B 0 EXIT /B 0
:prepare-test
call %MVN_EXEC% verify -DskipTests=true -pl ${rootArtifactId}-platform,${rootArtifactId}-integration-tests,${rootArtifactId}-platform-docker
EXIT /B 0
:test :test
call %MVN_EXEC% verify -pl ${rootArtifactId}-integration-tests call %MVN_EXEC% verify -pl ${rootArtifactId}-platform,${rootArtifactId}-integration-tests
EXIT /B 0 EXIT /B 0
:purge :purge
docker volume rm -f ${rootArtifactId}-acs-volume docker volume rm -f ${rootArtifactId}-acs-volume

View File

@@ -37,19 +37,19 @@ purge() {
} }
build() { build() {
${symbol_dollar}MVN_EXEC clean install -DskipTests=true ${symbol_dollar}MVN_EXEC clean package
} }
build_share() { build_share() {
docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH kill ${rootArtifactId}-share docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH kill ${rootArtifactId}-share
yes | docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH rm -f ${rootArtifactId}-share yes | docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH rm -f ${rootArtifactId}-share
${symbol_dollar}MVN_EXEC clean install -DskipTests=true -pl ${rootArtifactId}-share,${rootArtifactId}-share-docker ${symbol_dollar}MVN_EXEC clean package -pl ${rootArtifactId}-share,${rootArtifactId}-share-docker
} }
build_acs() { build_acs() {
docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH kill ${rootArtifactId}-acs docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH kill ${rootArtifactId}-acs
yes | docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH rm -f ${rootArtifactId}-acs yes | docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH rm -f ${rootArtifactId}-acs
${symbol_dollar}MVN_EXEC clean install -DskipTests=true -pl ${rootArtifactId}-platform,${rootArtifactId}-platform-docker ${symbol_dollar}MVN_EXEC clean package -pl ${rootArtifactId}-platform,${rootArtifactId}-platform-docker
} }
tail() { tail() {
@@ -60,8 +60,12 @@ tail_all() {
docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH logs --tail="all" docker-compose -f ${symbol_dollar}COMPOSE_FILE_PATH logs --tail="all"
} }
prepare_test() {
${symbol_dollar}MVN_EXEC verify -DskipTests=true -pl ${rootArtifactId}-platform,${rootArtifactId}-integration-tests,${rootArtifactId}-platform-docker
}
test() { test() {
${symbol_dollar}MVN_EXEC verify -pl ${rootArtifactId}-integration-tests ${symbol_dollar}MVN_EXEC verify -pl ${rootArtifactId}-platform,${rootArtifactId}-integration-tests
} }
case "${symbol_dollar}1" in case "${symbol_dollar}1" in
@@ -98,6 +102,7 @@ case "${symbol_dollar}1" in
build_test) build_test)
down down
build build
prepare_test
start start
test test
tail_all tail_all

View File

@@ -73,39 +73,22 @@ do is modify the `pom.xml` file of the corresponding docker module / project in
</dependencies> </dependencies>
``` ```
2. Modify the Maven Dependency Plugin in the file `PROJECT_ARTIFACT_ID-platform-docker/pom.xml` to set the platform JAR dependency type to `amp`: 2. Add the `<includeTypes>amp</includeTypes>` to the `collect-extensions` execution in maven-dependency-plugin plugin build configuration in the same file:
``` ```
<plugin> <!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
<groupId>org.apache.maven.plugins</groupId> <execution>
<artifactId>maven-dependency-plugin</artifactId> <id>collect-extensions</id>
<executions> <phase>package</phase>
<!-- Copy the repository extension and the dependencies required for execute integration tests --> <goals>
<execution> <goal>copy-dependencies</goal>
<id>copy-repo-extension</id> </goals>
<phase>pre-integration-test</phase> <configuration>
<goals> <outputDirectory>${project.build.directory}/extensions</outputDirectory>
<goal>copy</goal> <includeScope>runtime</includeScope>
</goals> <includeTypes>amp</includeTypes>
<configuration> </configuration>
<artifactItems> </execution>
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>sample-module-platform</artifactId>
<version>1.0-SNAPSHOT</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/extensions</outputDirectory>
<type>amp</type>
</artifactItem>
<!-- Test dependencies -->
...
</artifactItems>
</configuration>
</execution>
<!-- Copy other dependencies (JARs or AMPs) declared in the platform module -->
...
</executions>
</plugin>
``` ```
3. Repeat these steps for the share module in the file `PROJECT_ARTIFACT_ID-share-docker/pom.xml`. 3. Repeat these steps for the share module in the file `PROJECT_ARTIFACT_ID-share-docker/pom.xml`.