Skip to content

Commit

Permalink
Improved Maven profile handling for prod/test
Browse files Browse the repository at this point in the history
  • Loading branch information
rijnb committed Jul 6, 2017
1 parent 96cb3b0 commit d77456d
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ sudo: false
jdk:
- oraclejdk8

install: mvn install -DskipTests -Dgpg.skip -Ptest
install: mvn install -DskipTests -Dgpg.skip

script:
- mvn verify -Dgpg.skip -Ptest
- mvn verify -Dgpg.skip

after_success:
- mvn coveralls:report -Dgpg.skip -Ptest
- mvn coveralls:report -Dgpg.skip

cache:
directories:
Expand Down
4 changes: 2 additions & 2 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@
<id>move-main-class</id>
<phase>compile</phase>
<configuration>
<tasks>
<target>
<copy todir="${project.basedir}/target/webapp/">
<fileset dir="${project.build.directory}/classes/">
<include name="com/mapcode/services/cli/*.class"/>
</fileset>
</copy>
</tasks>
</target>
</configuration>
<goals>
<goal>run</goal>
Expand Down
74 changes: 74 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,78 @@
</plugin>
</plugins>
</reporting>

<profiles>

<!-- Test profile. Uses example properties from external-resources-example. -->
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>
.
.
***********************************************************
** This is a TEST build.
** --------------------------------------------------------
** Do NOT install in production environment!
***********************************************************
.
.
</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- Default profile. Uses "real" properties from external-resources. -->
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>
.
.
***********************************************************
** This is a PRODUCTION build.
***********************************************************
.
.
</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
62 changes: 36 additions & 26 deletions resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,17 @@
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>

<resource>
<directory>src/main/external-resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>bundle</goal>
</goals>
<configuration>
<includes>
<include>src/main/external-resources/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<!-- Test profiles. -->
<profiles>

<!-- Test profile. Uses example properties from external-resources-example. -->
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
Expand All @@ -82,7 +62,6 @@

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<executions>
<execution>
Expand All @@ -100,5 +79,36 @@
</plugins>
</build>
</profile>

<!-- Default profile. Uses "real" properties from external-resources. -->
<profile>
<id>prod</id>
<build>
<resources>
<resource>
<directory>src/main/external-resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>bundle</goal>
</goals>
<configuration>
<includes>
<include>src/main/external-resources/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Example properties file which should be placed in the classpath.
# Set mapcode-secret.properties to true to trace REST calls to the MongoDB database.

MongoDBTrace.readEnabled = false
MongoDBTrace.writeEnabled = false
MongoDBTrace.servers = your-server:27017
MongoDBTrace.database = your-database
Expand Down

0 comments on commit d77456d

Please sign in to comment.