[MRESOURCES-208] Remove @Deprecated marked code
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1717096 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugin/resources/PropertyUtils.java b/src/main/java/org/apache/maven/plugin/resources/PropertyUtils.java
deleted file mode 100644
index c99253c..0000000
--- a/src/main/java/org/apache/maven/plugin/resources/PropertyUtils.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package org.apache.maven.plugin.resources;
-
-/*
- * 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.
- */
-
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * @deprecated use classes in the component maven-filtering
- * TODO remove the class ?
- * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
- * @author William Ferguson
- */
-public final class PropertyUtils
-{
- private PropertyUtils()
- {
- // prevent instantiation
- }
-
- /**
- * Reads a property file, resolving all internal variables, using the supplied base properties.
- * <p>
- * The properties are resolved iteratively, so if the value of property A refers to property B, then after
- * resolution the value of property B will contain the value of property B.
- * </p>
- *
- * @param propFile The property file to load.
- * @param baseProps Properties containing the initial values to subsitute into the properties file.
- * @return Properties object containing the properties in the file with their values fully resolved.
- * @throws IOException if profile does not exist, or cannot be read.
- */
- public static Properties loadPropertyFile( File propFile, Properties baseProps )
- throws IOException
- {
- if ( !propFile.exists() )
- {
- throw new FileNotFoundException( propFile.toString() );
- }
-
- final Properties fileProps = new Properties();
- final FileInputStream inStream = new FileInputStream( propFile );
- try
- {
- fileProps.load( inStream );
- }
- finally
- {
- IOUtil.close( inStream );
- }
-
- final Properties combinedProps = new Properties();
- combinedProps.putAll( baseProps );
- combinedProps.putAll( fileProps );
-
- // The algorithm iterates only over the fileProps which is all that is required to resolve
- // the properties defined within the file. This is slighlty different to current, however
- // I suspect that this was the actual original intent.
- //
- // The difference is that #loadPropertyFile(File, boolean, boolean) also resolves System properties
- // whose values contain expressions. I believe this is unexpected and is not validated by the test cases,
- // as can be verified by replacing the implementation of #loadPropertyFile(File, boolean, boolean)
- // with the commented variant I have provided that reuses this method.
-
- for ( Object o : fileProps.keySet() )
- {
- final String k = (String) o;
- final String propValue = getPropertyValue( k, combinedProps );
- fileProps.setProperty( k, propValue );
- }
-
- return fileProps;
- }
-
- /**
- * Reads a property file, resolving all internal variables.
- *
- * @param propfile The property file to load
- * @param fail wheter to throw an exception when the file cannot be loaded or to return null
- * @param useSystemProps wheter to incorporate System.getProperties settings into the returned Properties object.
- * @return the loaded and fully resolved Properties object
- */
- public static Properties loadPropertyFile( File propfile, boolean fail, boolean useSystemProps )
- throws IOException
- {
-
- final Properties baseProps = new Properties();
-
- if ( useSystemProps )
- {
- baseProps.putAll( System.getProperties() );
- }
-
- final Properties resolvedProps = new Properties();
- try
- {
- resolvedProps.putAll( loadPropertyFile( propfile, baseProps ) );
- }
- catch ( FileNotFoundException e )
- {
- if ( fail )
- {
- throw new FileNotFoundException( propfile.toString() );
- }
- }
-
- if ( useSystemProps )
- {
- resolvedProps.putAll( baseProps );
- }
-
- return resolvedProps;
- }
-
- /**
- * Retrieves a property value, replacing values like ${token}
- * using the Properties to look them up.
- * It will leave unresolved properties alone, trying for System
- * properties, and implements reparsing (in the case that
- * the value of a property contains a key), and will
- * not loop endlessly on a pair like
- * test = ${test}.
- */
- private static String getPropertyValue( String k, Properties p )
- {
- // This can also be done using InterpolationFilterReader,
- // but it requires reparsing the file over and over until
- // it doesn't change.
-
- String v = p.getProperty( k );
- String ret = "";
- int idx, idx2;
-
- while ( ( idx = v.indexOf( "${" ) ) >= 0 )
- {
- // append prefix to result
- ret += v.substring( 0, idx );
-
- // strip prefix from original
- v = v.substring( idx + 2 );
-
- // if no matching } then bail
- idx2 = v.indexOf( '}' );
- if ( idx2 < 0 )
- {
- break;
- }
-
- // strip out the key and resolve it
- // resolve the key/value for the ${statement}
- String nk = v.substring( 0, idx2 );
- v = v.substring( idx2 + 1 );
- String nv = p.getProperty( nk );
-
- // try global environment..
- if ( nv == null )
- {
- nv = System.getProperty( nk );
- }
-
- // if the key cannot be resolved,
- // leave it alone ( and don't parse again )
- // else prefix the original string with the
- // resolved property ( so it can be parsed further )
- // taking recursion into account.
- if ( nv == null || nv.equals( k ) )
- {
- ret += "${" + nk + "}";
- }
- else
- {
- v = nv + v;
- }
- }
- return ret + v;
- }
-}
diff --git a/src/main/java/org/apache/maven/plugin/resources/ReflectionProperties.java b/src/main/java/org/apache/maven/plugin/resources/ReflectionProperties.java
deleted file mode 100644
index 6876646..0000000
--- a/src/main/java/org/apache/maven/plugin/resources/ReflectionProperties.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.maven.plugin.resources;
-
-/*
- * 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.
- */
-
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-
-import java.util.Properties;
-
-/**
- * @deprecated use classes in the component maven-filtering
- * TODO remove the class ?
- * @author Andreas Hoheneder (ahoh_at_inode.at)
- *
- */
-public class ReflectionProperties
- extends Properties
-{
-
- private MavenProject project;
-
- private boolean escapedBackslashesInFilePath;
-
- public ReflectionProperties( MavenProject aProject, boolean escapedBackslashesInFilePath )
- {
- super();
-
- project = aProject;
-
- this.escapedBackslashesInFilePath = escapedBackslashesInFilePath;
- }
-
- public Object get( Object key )
- {
- Object value = null;
- try
- {
- value = ReflectionValueExtractor.evaluate( "" + key, project );
-
- if ( escapedBackslashesInFilePath && ( value instanceof String ) )
- {
- String val = (String) value;
-
- // Check if it's a windows path
- if ( val.indexOf( ":\\" ) == 1 )
- {
- value = StringUtils.replace( (String) value, "\\", "\\\\" );
- value = StringUtils.replace( (String) value, ":", "\\:" );
- }
- }
- }
- catch ( Exception e )
- {
- // TODO: remove the try-catch block when ReflectionValueExtractor.evaluate() throws no more exceptions
- }
- return value;
- }
-}
diff --git a/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java b/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java
deleted file mode 100644
index dbbd6ef..0000000
--- a/src/test/java/org/apache/maven/plugin/resources/AdvancePropertyUtilsTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.apache.maven.plugin.resources;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.util.Properties;
-
-public class AdvancePropertyUtilsTest
- extends AbstractPropertyUtilsTest
-{
- final static protected String propFileName = "/target/test-classes/unit/propertiesutils-test/advance.properties";
-
- final static protected String validationFileName =
- "/target/test-classes/unit/propertiesutils-test/advance_validation.properties";
-
- protected File getPropertyFile()
- {
-
- File propFile = new File( getBasedir(), propFileName );
-
- if ( !propFile.exists() )
- {
- propFile = null;
- }
-
- return propFile;
- }
-
- protected File getValidationFile()
- {
-
- File validationFile = new File( getBasedir(), validationFileName );
-
- if ( !validationFile.exists() )
- {
- validationFile = null;
- }
-
- return validationFile;
- }
-
- /**
- * load property test case can be adjusted by modifying the advance.properties and
- * advance_validation.properties
- *
- * @throws Exception
- */
- public void testAdvanceLoadProperty_FF()
- throws Exception
- {
- Properties prop;
- boolean throwsException = false;
-
- try
- {
- prop = PropertyUtils.loadPropertyFile( propertyFile, false, false );
- }
- catch ( Exception ex )
- {
- prop = null;
- throwsException = true;
- }
-
- assertFalse( throwsException );
- assertNotNull( prop );
- assertTrue( validateProperties( prop ) );
-
- }
-
- /**
- * load property test case can be adjusted by modifying the advance.properties and
- * advance_validation properties
- *
- * @throws Exception
- */
- public void testAdvanceLoadProperty_TF()
- throws Exception
- {
- Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false );
-
- assertNotNull( prop );
- assertTrue( validateProperties( prop ) );
- }
-
- /**
- * load property test case can be adjusted by modifying the advance.properties and
- * advance_validation properties
- *
- * @throws Exception
- */
- public void testAdvanceLoadProperty_TT()
- throws Exception
- {
- Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
-
- // add system properties to our
- // validation table
- validationProp.putAll( System.getProperties() );
- assertNotNull( prop );
- assertTrue( validateProperties( prop ) );
- }
-}
diff --git a/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java b/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java
index 018a861..2af43d0 100644
--- a/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java
+++ b/src/test/java/org/apache/maven/plugin/resources/BasicPropertyUtilsTest.java
@@ -22,6 +22,8 @@
import java.io.File;
import java.util.Properties;
+import org.apache.maven.shared.filtering.PropertyUtils;
+
public class BasicPropertyUtilsTest
extends AbstractPropertyUtilsTest
{
diff --git a/src/test/java/org/apache/maven/plugin/resources/EnhancedPropertyUtilsTest.java b/src/test/java/org/apache/maven/plugin/resources/EnhancedPropertyUtilsTest.java
deleted file mode 100644
index 664af66..0000000
--- a/src/test/java/org/apache/maven/plugin/resources/EnhancedPropertyUtilsTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.apache.maven.plugin.resources;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * Tests {@link PropertyUtils#loadPropertyFile(File, Properties)}.
- *
- * @author William Ferguson
- */
-public class EnhancedPropertyUtilsTest
- extends AbstractPropertyUtilsTest
-{
- private static final String validationFileName =
- "/target/test-classes/unit/propertiesutils-test/enhanced_validation.properties";
-
- private static final String propFileName = "/target/test-classes/unit/propertiesutils-test/enhanced.properties";
-
- private final Properties baseProps = new Properties();
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- this.baseProps.setProperty( "prop1", "valueOfProperty1" );
- }
-
- protected File getPropertyFile()
- {
- final File propFile = new File( getBasedir(), propFileName );
-
- if ( !propFile.exists() )
- {
- return null;
- }
-
- return propFile;
- }
-
- protected File getValidationFile()
- {
- final File file = new File( getBasedir(), validationFileName );
-
- if ( !file.exists() )
- {
- return null;
- }
-
- return file;
- }
-
- /**
- * Load property test case can be adjusted by modifying the enhanced.properties and enhanced_validation properties.
- *
- * @throws Exception
- */
- public void testBasicLoadProperty()
- throws Exception
- {
- final Properties props = PropertyUtils.loadPropertyFile( this.propertyFile, this.baseProps );
-
- assertNotNull( props );
- assertTrue( validateProperties( props ) );
- }
-
- /**
- * Load property test case can be adjusted by modifying the enhanced.properties and enhanced_validation properties.
- *
- * @throws Exception
- */
- public void testNonExistentProperty()
- throws Exception
- {
- final Properties props = PropertyUtils.loadPropertyFile( this.propertyFile, this.baseProps );
-
- assertNotNull( props );
- assertNull( props.getProperty( "does_not_exist" ) );
- }
-
- /**
- * Load property test case can be adjusted by modifying the enhanced.properties and enhanced_validation properties.
- *
- * @throws Exception
- */
- public void testException()
- throws Exception
- {
- try
- {
- PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), this.baseProps );
- fail( "Should not have been able to load properties from a non-existent file" );
- }
- catch ( IOException e )
- {
- // as expected.
- }
- }
-}
diff --git a/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java b/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java
deleted file mode 100644
index dd230f4..0000000
--- a/src/test/java/org/apache/maven/plugin/resources/ReflectionPropertiesTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.maven.plugin.resources;
-
-/*
- * 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.
- */
-
-import org.apache.maven.plugin.resources.stub.MavenProjectBasicStub;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-
-public class ReflectionPropertiesTest
- extends AbstractMojoTestCase
-{
- // data
- final static protected String pomFilePath = "/target/test-classes/unit/reflectionproperties-test/plugin-config.xml";
-
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown()
- throws Exception
- {
-
- }
-
- public void testGet_escapeBackslashCharacterInPath()
- throws Exception
- {
- // setup data
- MavenProjectBasicStub project = new MavenProjectBasicStub( "escapeBackSlashCharacterInPath" );
-
- // set dummy value
- project.setDescription( "c:\\\\org\\apache\\test" );
-
- ReflectionProperties reflectProp = new ReflectionProperties( project, true );
-
- // project property to be verified
- String reflectPropValue = (String) reflectProp.get( "description" );
-
- // expected value is c\:\\\\org\\apache\\test
- assertTrue( reflectPropValue.equals( "c\\:\\\\\\\\org\\\\apache\\\\test" ) );
- }
-
- public void testGet_dontEscapeBackslashCharacterInPath()
- throws Exception
- {
- // setup data
- MavenProjectBasicStub project = new MavenProjectBasicStub( "dontEscapeBackSlashCharacterInPath" );
-
- // set dummy value
- project.setDescription( "c:\\\\org\\apache\\test" );
-
- // project property to be verified
- ReflectionProperties reflectProp = new ReflectionProperties( project, false );
-
- // project property to be verified
- String reflectPropValue = (String) reflectProp.get( "description" );
-
- // expected value is c:\\org\apache\test
- assertTrue( reflectPropValue.equals( "c:\\\\org\\apache\\test" ) );
- }
-}