Skip to content

Commit

Permalink
Update WriteActiveProfileProperties
Browse files Browse the repository at this point in the history
Closes #20 #59 #35
  • Loading branch information
mykelalvis authored and slachiewicz committed Jan 7, 2022
1 parent 5c58b39 commit e3c756a
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 1 deletion.
39 changes: 39 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,43 @@

</dependencies>

<profiles>
<profile>
<id>run-its</id>
<build>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<projectsDirectory>src/it</projectsDirectory>
<addTestClassPath>true</addTestClassPath>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<invokerPropertiesFile>invoke.properties</invokerPropertiesFile>
<preBuildHookScript>prepare</preBuildHookScript>
<postBuildHookScript>verify</postBuildHookScript>
<debug>true</debug>
<environmentVariables>
<testing.versionUnderTest>${project.version}</testing.versionUnderTest>
</environmentVariables>
<scriptVariables>
<resultsBase>${project.build.directory}/itresults</resultsBase>
</scriptVariables>
<settingsFile>src/it/settings.xml</settingsFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.debug = true
invoker.goals = generate-resources
invoker.buildResult = success
37 changes: 37 additions & 0 deletions src/it/WriteActiveProfilePropertiesToOutputFile/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>it-test-parent</artifactId>
<version>@project.version@</version>
<relativePath>../it-test-parent/pom.xml</relativePath>
</parent>
<!-- Build description -->
<artifactId>WriteActiveProfilePropertiesToOutputFile</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>

<!-- Build plugins and extensions -->
<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>write-active-profile-properties</goal>
</goals>
<configuration>
<outputFile>${project.build.directory}/itresults/WriteActiveProfilePropertiesToOutputFile</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
14 changes: 14 additions & 0 deletions src/it/WriteActiveProfilePropertiesToOutputFile/prepare.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import junit.framework.Assert;

File target = new File(basedir, "target/itresults");
if (!target.exists()) {
target.mkdirs();
Assert.assertTrue("Folder " + target.absolutePath + " must exist", target.exists());
}

File f = new File(target, "WriteActiveProfilePropertiesToOutputFile");
if (f.exists()) {
f.deleteDir();
}

Assert.assertFalse("File " + f.absolutePath + " must exist", f.exists());
10 changes: 10 additions & 0 deletions src/it/WriteActiveProfilePropertiesToOutputFile/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import junit.framework.Assert;

File target = new File(basedir, "target/itresults");

File f = new File(target, "WriteActiveProfilePropertiesToOutputFile");
def out = f.text
Assert.assertTrue("File " + f.absolutePath + " exists", f.exists());
Assert.assertNotSame("File is empty", 0, f.length());
Assert.assertTrue("Bob is a dog", out.contains("bob=dog"))
Assert.assertFalse("Bob is not a cat", out.contains("bob=cat"))
1 change: 1 addition & 0 deletions src/it/it-test-parent/invoke.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.skip = true
24 changes: 24 additions & 0 deletions src/it/it-test-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>@project.groupId@</groupId>
<artifactId>it-test-parent</artifactId>
<version>@project.version@</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<url>http://www.com/image.jpg</url>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
66 changes: 66 additions & 0 deletions src/it/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<servers>
<server>
<id>y</id>
<username>X</username>
</server>
</servers>
<profiles>
<profile>
<id>it-repo</id>
<properties>
<bob>dog</bob>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void execute()
{
validateOutputFile();
List<Profile> list = getProject().getActiveProfiles();
if ( getLog().isInfoEnabled() )
if ( getLog().isDebugEnabled() )
{
getLog().debug( list.size() + " profile(s) active" );
}
Expand Down

0 comments on commit e3c756a

Please sign in to comment.