Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ under the License.
</distributionManagement>

<properties>
<mavenFilteringVersion>3.2.0</mavenFilteringVersion>
<mavenFilteringVersion>3.3.0-SNAPSHOT</mavenFilteringVersion>
<mavenVersion>3.1.0</mavenVersion>
<javaVersion>7</javaVersion>
<project.build.outputTimestamp>2020-08-05T15:25:21Z</project.build.outputTimestamp>
Expand All @@ -79,6 +79,10 @@ under the License.
<contributor>
<name>Graham Leggett</name>
</contributor>
<contributor>
<name>Imad BELMOUJAHID</name>
<email>BELMOUJAHID.I@Gmail.Com</email>
</contributor>
</contributors>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/**
* Copy resources for the main source code to the main output directory. Always uses the project.build.resources element
* to specify the resources to copy.
*
* @author <a href="mailto:BELMOUJAHID.I@Gmail.Com>Imad BELMOUJAHID</a> @ImadBL
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author Andreas Hoheneder
Expand Down Expand Up @@ -208,6 +208,14 @@ public class ResourcesMojo
@Parameter
protected LinkedHashSet<String> delimiters;

/**
* This parameter is used in particular for filters properties files with format json.
* if this parameter is not empty, we select all the parameters who are the nodes start with this parameter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If

* This helps us to add a ROOT node FOR EACH environment in a same JSON file
*/
@Parameter
protected String rootNode;

/**
* Use default delimiters in addition to custom delimiters, if any.
*
Expand Down Expand Up @@ -349,6 +357,9 @@ public void execute()
// Handle MRESOURCES-171
mavenResourcesExecution.setPropertiesEncoding( propertiesEncoding );

// Set rootNode for new feature with json file ### MRESOURCES-284 ###
mavenResourcesExecution.setRootNode( rootNode );

if ( nonFilteredFileExtensions != null )
{
mavenResourcesExecution.setNonFilteredFileExtensions( nonFilteredFileExtensions );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import org.apache.maven.shared.filtering.PropertyUtils;

/**
* @author <a href="mailto:BELMOUJAHID.I@Gmail.Com>Imad BELMOUJAHID</a> @ImadBL
*/
public class BasicPropertyUtilsTest
extends AbstractPropertyUtilsTest
{
Expand Down Expand Up @@ -58,41 +61,44 @@ protected File getValidationFile()

/**
* load property test case can be adjusted by modifying the basic.properties and basic_validation properties
* I added a null for this parameter (rootNode) because it is only used with json file @ImadBL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be an API doc comment

*
* @throws Exception
*/
public void testBasicLoadProperty_FF()
throws Exception
{
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, false, false );
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, false, false, null );

assertNotNull( prop );
assertTrue( validateProperties( prop ) );
}

/**
* load property test case can be adjusted by modifying the basic.properties and basic_validation properties
* I added a null for this parameter (rootNode) because it is only used with json file @ImadBL
*
* @throws Exception
*/
public void testBasicLoadProperty_TF()
throws Exception
{
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false );
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false, null );

assertNotNull( prop );
assertTrue( validateProperties( prop ) );
}

/**
* load property test case can be adjusted by modifying the basic.properties and basic_validation properties
* I added a null for this parameter (rootNode) because it is only used with json file @ImadBL
*
* @throws Exception
*/
public void testBasicLoadProperty_TT()
throws Exception
{
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true, null );

validationProp.putAll( System.getProperties() );
assertNotNull( prop );
Expand All @@ -101,13 +107,14 @@ public void testBasicLoadProperty_TT()

/**
* load property test case can be adjusted by modifying the basic.properties and basic_validation properties
* I added a null for this parameter (rootNode) because it is only used with json file @ImadBL
*
* @throws Exception
*/
public void testNonExistentProperty()
throws Exception
{
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true, null );

validationProp.putAll( System.getProperties() );
assertNotNull( prop );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@
import org.apache.maven.shared.filtering.PropertyUtils;
import org.junit.Test;

/**
* @author <a href="mailto:BELMOUJAHID.I@Gmail.Com>Imad BELMOUJAHID</a> @ImadBL
*/
public class PropertyUtilsExceptionTest
{

/**
* load property test case can be adjusted by modifying the basic.properties and basic_validation properties
* I added a null for this parameter (rootNode) because it is only used with json file @ImadBL
*
* @throws Exception
*/
@Test( expected = FileNotFoundException.class )
public void loadPropertyFileShouldFailWithFileNotFoundException()
throws Exception
{
PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), true, true );
PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), true, true, null );
}
}