You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ke...@apache.org on 2006/09/29 16:23:03 UTC
svn commit: r451306 - in
/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly:
filter/ interpolation/ mojos/ utils/
Author: kenney
Date: Fri Sep 29 07:23:02 2006
New Revision: 451306
URL: http://svn.apache.org/viewvc?view=rev&rev=451306
Log:
Fixed svn properties
Modified:
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java (contents, props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java (contents, props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java (contents, props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java (contents, props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AssemblyMojo.java (props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java (contents, props changed)
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java (contents, props changed)
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java Fri Sep 29 07:23:02 2006
@@ -1,208 +1,208 @@
-package org.apache.maven.plugin.assembly.filter;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.codehaus.plexus.logging.Logger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * TODO: include in maven-artifact in future
- */
-public class AssemblyScopeArtifactFilter
- implements ArtifactFilter, StatisticsReportingFilter
-{
- private final boolean compileScope;
-
- private final boolean runtimeScope;
-
- private final boolean testScope;
-
- private final boolean providedScope;
-
- private final boolean systemScope;
-
- private boolean compileScopeHit = false;
-
- private boolean runtimeScopeHit = false;
-
- private boolean testScopeHit = false;
-
- private boolean providedScopeHit = false;
-
- private boolean systemScopeHit = false;
-
- private List filteredArtifactIds = new ArrayList();
-
- public AssemblyScopeArtifactFilter( String scope )
- {
- if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) )
- {
- systemScope = true;
- providedScope = true;
- compileScope = true;
- runtimeScope = false;
- testScope = false;
- }
- else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) )
- {
- systemScope = false;
- providedScope = false;
- compileScope = true;
- runtimeScope = true;
- testScope = false;
- }
- else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) )
- {
- systemScope = true;
- providedScope = true;
- compileScope = true;
- runtimeScope = true;
- testScope = true;
- }
- else if ( DefaultArtifact.SCOPE_PROVIDED.equals( scope ) )
- {
- systemScope = false;
- providedScope = true;
- compileScope = false;
- runtimeScope = false;
- testScope = false;
- }
- else if ( DefaultArtifact.SCOPE_SYSTEM.equals( scope ) )
- {
- systemScope = true;
- providedScope = false;
- compileScope = false;
- runtimeScope = false;
- testScope = false;
- }
- else
- {
- systemScope = false;
- providedScope = false;
- compileScope = false;
- runtimeScope = false;
- testScope = false;
- }
- }
-
- public boolean include( Artifact artifact )
- {
- boolean result = true;
-
- if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
- {
- compileScopeHit = true;
- result = compileScope;
- }
- else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
- {
- runtimeScopeHit = true;
- result = runtimeScope;
- }
- else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
- {
- testScopeHit = true;
- result = testScope;
- }
- else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
- {
- providedScopeHit = true;
- result = providedScope;
- }
- else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
- {
- systemScopeHit = true;
- result = systemScope;
- }
-
- if ( !result )
- {
- filteredArtifactIds.add( artifact.getId() );
- }
-
- return result;
- }
-
- public String toString()
- {
- return "Scope filter [compile=" + compileScope + ", runtime=" + runtimeScope + ", test=" + testScope
- + ", provided=" + providedScope + ", system=" + systemScope + "]";
- }
-
- public void reportFilteredArtifacts( Logger logger )
- {
- if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
- {
- StringBuffer buffer = new StringBuffer( "The following artifacts were removed by this filter: " );
-
- for ( Iterator it = filteredArtifactIds.iterator(); it.hasNext(); )
- {
- String artifactId = ( String ) it.next();
-
- buffer.append( '\n' ).append( artifactId );
- }
-
- logger.debug( buffer.toString() );
- }
- }
-
- public void reportMissedCriteria( Logger logger )
- {
- if ( logger.isDebugEnabled() )
- {
- StringBuffer buffer = new StringBuffer();
-
- boolean report = false;
- if ( !compileScopeHit )
- {
- buffer.append( "\no Compile" );
- report = true;
- }
- if ( !runtimeScopeHit )
- {
- buffer.append( "\no Runtime" );
- report = true;
- }
- if ( !testScopeHit )
- {
- buffer.append( "\no Test" );
- report = true;
- }
- if ( !providedScopeHit )
- {
- buffer.append( "\no Provided" );
- report = true;
- }
- if ( !systemScopeHit )
- {
- buffer.append( "\no System" );
- report = true;
- }
-
- if ( report )
- {
- logger.debug( "The following scope filters were not used: " + buffer.toString() );
- }
- }
- }
-}
+package org.apache.maven.plugin.assembly.filter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.logging.Logger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * TODO: include in maven-artifact in future
+ */
+public class AssemblyScopeArtifactFilter
+ implements ArtifactFilter, StatisticsReportingFilter
+{
+ private final boolean compileScope;
+
+ private final boolean runtimeScope;
+
+ private final boolean testScope;
+
+ private final boolean providedScope;
+
+ private final boolean systemScope;
+
+ private boolean compileScopeHit = false;
+
+ private boolean runtimeScopeHit = false;
+
+ private boolean testScopeHit = false;
+
+ private boolean providedScopeHit = false;
+
+ private boolean systemScopeHit = false;
+
+ private List filteredArtifactIds = new ArrayList();
+
+ public AssemblyScopeArtifactFilter( String scope )
+ {
+ if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = true;
+ compileScope = true;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) )
+ {
+ systemScope = false;
+ providedScope = false;
+ compileScope = true;
+ runtimeScope = true;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = true;
+ compileScope = true;
+ runtimeScope = true;
+ testScope = true;
+ }
+ else if ( DefaultArtifact.SCOPE_PROVIDED.equals( scope ) )
+ {
+ systemScope = false;
+ providedScope = true;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_SYSTEM.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = false;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else
+ {
+ systemScope = false;
+ providedScope = false;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ }
+
+ public boolean include( Artifact artifact )
+ {
+ boolean result = true;
+
+ if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
+ {
+ compileScopeHit = true;
+ result = compileScope;
+ }
+ else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
+ {
+ runtimeScopeHit = true;
+ result = runtimeScope;
+ }
+ else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
+ {
+ testScopeHit = true;
+ result = testScope;
+ }
+ else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
+ {
+ providedScopeHit = true;
+ result = providedScope;
+ }
+ else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
+ {
+ systemScopeHit = true;
+ result = systemScope;
+ }
+
+ if ( !result )
+ {
+ filteredArtifactIds.add( artifact.getId() );
+ }
+
+ return result;
+ }
+
+ public String toString()
+ {
+ return "Scope filter [compile=" + compileScope + ", runtime=" + runtimeScope + ", test=" + testScope
+ + ", provided=" + providedScope + ", system=" + systemScope + "]";
+ }
+
+ public void reportFilteredArtifacts( Logger logger )
+ {
+ if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer( "The following artifacts were removed by this filter: " );
+
+ for ( Iterator it = filteredArtifactIds.iterator(); it.hasNext(); )
+ {
+ String artifactId = ( String ) it.next();
+
+ buffer.append( '\n' ).append( artifactId );
+ }
+
+ logger.debug( buffer.toString() );
+ }
+ }
+
+ public void reportMissedCriteria( Logger logger )
+ {
+ if ( logger.isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ boolean report = false;
+ if ( !compileScopeHit )
+ {
+ buffer.append( "\no Compile" );
+ report = true;
+ }
+ if ( !runtimeScopeHit )
+ {
+ buffer.append( "\no Runtime" );
+ report = true;
+ }
+ if ( !testScopeHit )
+ {
+ buffer.append( "\no Test" );
+ report = true;
+ }
+ if ( !providedScopeHit )
+ {
+ buffer.append( "\no Provided" );
+ report = true;
+ }
+ if ( !systemScopeHit )
+ {
+ buffer.append( "\no System" );
+ report = true;
+ }
+
+ if ( report )
+ {
+ logger.debug( "The following scope filters were not used: " + buffer.toString() );
+ }
+ }
+ }
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyScopeArtifactFilter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java Fri Sep 29 07:23:02 2006
@@ -1,61 +1,61 @@
-package org.apache.maven.plugin.assembly.interpolation;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-public class AssemblyInterpolationException
- extends Exception
-{
- private String expression;
-
- private String originalMessage;
-
- public AssemblyInterpolationException( String message )
- {
- super( message );
- }
-
- public AssemblyInterpolationException( String message, Throwable cause )
- {
- super( message, cause );
- }
-
- public AssemblyInterpolationException( String expression, String message, Throwable cause )
- {
- super( "The Assembly expression: " + expression + " could not be evaluated. Reason: " + message, cause );
-
- this.expression = expression;
- this.originalMessage = message;
- }
-
- public AssemblyInterpolationException( String expression, String message )
- {
- super( "The Assembly expression: " + expression + " could not be evaluated. Reason: " + message );
-
- this.expression = expression;
- this.originalMessage = message;
- }
-
- public String getExpression()
- {
- return expression;
- }
-
- public String getOriginalMessage()
- {
- return originalMessage;
- }
-}
+package org.apache.maven.plugin.assembly.interpolation;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class AssemblyInterpolationException
+ extends Exception
+{
+ private String expression;
+
+ private String originalMessage;
+
+ public AssemblyInterpolationException( String message )
+ {
+ super( message );
+ }
+
+ public AssemblyInterpolationException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public AssemblyInterpolationException( String expression, String message, Throwable cause )
+ {
+ super( "The Assembly expression: " + expression + " could not be evaluated. Reason: " + message, cause );
+
+ this.expression = expression;
+ this.originalMessage = message;
+ }
+
+ public AssemblyInterpolationException( String expression, String message )
+ {
+ super( "The Assembly expression: " + expression + " could not be evaluated. Reason: " + message );
+
+ this.expression = expression;
+ this.originalMessage = message;
+ }
+
+ public String getExpression()
+ {
+ return expression;
+ }
+
+ public String getOriginalMessage()
+ {
+ return originalMessage;
+ }
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolationException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java Fri Sep 29 07:23:02 2006
@@ -1,268 +1,268 @@
-package org.apache.maven.plugin.assembly.interpolation;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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.model.Model;
-import org.apache.maven.plugins.assembly.model.Assembly;
-import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader;
-import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class AssemblyInterpolator
- extends AbstractLogEnabled
-{
- private static final Pattern ELEMENT_PATTERN = Pattern.compile( "\\<([^> ]+)[^>]*>([^<]+)" );
-
- private static final Pattern EXPRESSION_PATTERN = Pattern.compile( "\\$\\{(pom\\.|project\\.|env\\.)?([^}]+)\\}" );
-
- private static final Map INTERPOLATION_BLACKLIST;
-
- static
- {
- Map blacklist = new HashMap();
-
- List ofnmBlacklistings = new ArrayList();
-
- ofnmBlacklistings.add( "groupId" );
- ofnmBlacklistings.add( "artifactId" );
- ofnmBlacklistings.add( "version" );
-
- // TODO: We should be blacklisting these, but currently they're not supported by filename mapping interpolation.
-// ofnmBlacklistings.add( "build.finalName" );
-// ofnmBlacklistings.add( "finalName" );
-
- blacklist.put( "outputFileNameMapping", ofnmBlacklistings );
- blacklist.put( "outputDirectoryMapping", ofnmBlacklistings );
-
-
- List odBlacklist = new ArrayList();
-
- odBlacklist.add( "groupId" );
- odBlacklist.add( "artifactId" );
- odBlacklist.add( "version" );
- odBlacklist.add( "build.finalName" );
-
- // wouldn't work, but just to future-proof this...
- odBlacklist.add( "finalName" );
-
- blacklist.put( "outputDirectory", odBlacklist );
-
- INTERPOLATION_BLACKLIST = blacklist;
- }
-
- private Properties envars;
-
- public AssemblyInterpolator( Properties envars )
- {
- this.envars = envars;
- }
-
- public AssemblyInterpolator()
- throws IOException
- {
- // FIXME: Once Maven (all supported versions in the wild) are using plexus-utils >= 1.3,
- // we should remove this.
- try
- {
- envars = CommandLineUtils.getSystemEnvVars( false );
- }
- catch( NoSuchMethodError e )
- {
- envars = CommandLineUtils.getSystemEnvVars();
- }
- }
-
- public Assembly interpolate( Assembly assembly, Model model, Map context )
- throws AssemblyInterpolationException
- {
- return interpolate( assembly, model, context, true );
- }
-
- public Assembly interpolate( Assembly assembly, Model model, Map context, boolean strict )
- throws AssemblyInterpolationException
- {
- StringWriter sWriter = new StringWriter();
-
- AssemblyXpp3Writer writer = new AssemblyXpp3Writer();
-
- try
- {
- writer.write( sWriter, assembly );
- }
- catch ( IOException e )
- {
- throw new AssemblyInterpolationException( "Cannot serialize assembly descriptor for interpolation.", e );
- }
-
- String serializedAssembly = sWriter.toString();
-
- serializedAssembly = interpolateInternal( serializedAssembly, assembly, model, context );
-
- StringReader sReader = new StringReader( serializedAssembly );
-
- AssemblyXpp3Reader assemblyReader = new AssemblyXpp3Reader();
- try
- {
- assembly = assemblyReader.read( sReader );
- }
- catch ( IOException e )
- {
- throw new AssemblyInterpolationException(
- "Cannot read assembly descriptor from interpolating filter of serialized version.", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new AssemblyInterpolationException(
- "Cannot read assembly descriptor from interpolating filter of serialized version.", e );
- }
-
- return assembly;
- }
-
- private String interpolateInternal( String src, Assembly assembly, Model model, Map context )
- throws AssemblyInterpolationException
- {
- String result = src;
-
- Matcher elementMatcher = ELEMENT_PATTERN.matcher( result );
-
- while ( elementMatcher.find() )
- {
- String element = elementMatcher.group( 0 );
-
- String elementName = elementMatcher.group( 1 );
- String value = elementMatcher.group( 2 );
-
- // only attempt to interpolate if the following is met:
- // 1. the element is not in the interpolation blacklist.
- // 2. the value is not empty (otherwise there's nothing to interpolate)
- // 3. the value contains a "${" (a pretty good clue that there's an expression in it)
- if ( StringUtils.isNotEmpty( value ) && value.indexOf( "${" ) > -1 )
- {
- List blacklistedExpressions = (List) INTERPOLATION_BLACKLIST.get( elementName );
- if ( blacklistedExpressions == null )
- {
- blacklistedExpressions = Collections.EMPTY_LIST;
- }
-
- String interpolatedValue =
- interpolateElementValue( value, assembly, model, context, blacklistedExpressions );
-
- String modifiedElement = StringUtils.replace( element, value, interpolatedValue );
- result = StringUtils.replace( result, element, modifiedElement );
- }
- }
-
- return result;
- }
-
- private String interpolateElementValue( String src, Assembly assembly, Model model, Map context,
- List blacklistedExpressions )
- throws AssemblyInterpolationException
- {
- String result = src;
-
- Matcher matcher = EXPRESSION_PATTERN.matcher( result );
- while ( matcher.find() )
- {
- String wholeExpr = matcher.group( 0 );
- String realExpr = matcher.group( 2 );
-
- if ( blacklistedExpressions.contains( realExpr ) )
- {
- continue;
- }
-
- Object value = context.get( realExpr );
-
- if ( value == null )
- {
- value = model.getProperties().getProperty( realExpr );
- }
-
- if ( value == null )
- {
- try
- {
- value = ReflectionValueExtractor.evaluate( realExpr, model );
- }
- catch ( Exception e )
- {
- Logger logger = getLogger();
- if ( logger.isDebugEnabled() )
- {
- logger.debug( "Assembly descriptor interpolation cannot proceed with expression: " + wholeExpr +
- ". Skipping...", e );
- }
- }
- }
-
- if ( value == null )
- {
- value = envars.getProperty( realExpr );
- }
-
- // if the expression refers to itself, skip it.
- if ( wholeExpr.equals( value ) )
- {
- throw new AssemblyInterpolationException( wholeExpr, assembly.getId() + " references itself." );
- }
-
- if ( value != null )
- {
- result = StringUtils.replace( result, wholeExpr, String.valueOf( value ) );
- // could use:
- // result = matcher.replaceFirst( stringValue );
- // but this could result in multiple lookups of stringValue, and replaceAll is not correct behaviour
- matcher.reset( result );
- }
- }
- return result;
- }
-
- protected Logger getLogger()
- {
- Logger logger = super.getLogger();
-
- if ( logger == null )
- {
- logger = new ConsoleLogger( Logger.LEVEL_INFO, "interpolator-internal" );
-
- enableLogging( logger );
- }
-
- return logger;
- }
-}
+package org.apache.maven.plugin.assembly.interpolation;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.model.Model;
+import org.apache.maven.plugins.assembly.model.Assembly;
+import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader;
+import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AssemblyInterpolator
+ extends AbstractLogEnabled
+{
+ private static final Pattern ELEMENT_PATTERN = Pattern.compile( "\\<([^> ]+)[^>]*>([^<]+)" );
+
+ private static final Pattern EXPRESSION_PATTERN = Pattern.compile( "\\$\\{(pom\\.|project\\.|env\\.)?([^}]+)\\}" );
+
+ private static final Map INTERPOLATION_BLACKLIST;
+
+ static
+ {
+ Map blacklist = new HashMap();
+
+ List ofnmBlacklistings = new ArrayList();
+
+ ofnmBlacklistings.add( "groupId" );
+ ofnmBlacklistings.add( "artifactId" );
+ ofnmBlacklistings.add( "version" );
+
+ // TODO: We should be blacklisting these, but currently they're not supported by filename mapping interpolation.
+// ofnmBlacklistings.add( "build.finalName" );
+// ofnmBlacklistings.add( "finalName" );
+
+ blacklist.put( "outputFileNameMapping", ofnmBlacklistings );
+ blacklist.put( "outputDirectoryMapping", ofnmBlacklistings );
+
+
+ List odBlacklist = new ArrayList();
+
+ odBlacklist.add( "groupId" );
+ odBlacklist.add( "artifactId" );
+ odBlacklist.add( "version" );
+ odBlacklist.add( "build.finalName" );
+
+ // wouldn't work, but just to future-proof this...
+ odBlacklist.add( "finalName" );
+
+ blacklist.put( "outputDirectory", odBlacklist );
+
+ INTERPOLATION_BLACKLIST = blacklist;
+ }
+
+ private Properties envars;
+
+ public AssemblyInterpolator( Properties envars )
+ {
+ this.envars = envars;
+ }
+
+ public AssemblyInterpolator()
+ throws IOException
+ {
+ // FIXME: Once Maven (all supported versions in the wild) are using plexus-utils >= 1.3,
+ // we should remove this.
+ try
+ {
+ envars = CommandLineUtils.getSystemEnvVars( false );
+ }
+ catch( NoSuchMethodError e )
+ {
+ envars = CommandLineUtils.getSystemEnvVars();
+ }
+ }
+
+ public Assembly interpolate( Assembly assembly, Model model, Map context )
+ throws AssemblyInterpolationException
+ {
+ return interpolate( assembly, model, context, true );
+ }
+
+ public Assembly interpolate( Assembly assembly, Model model, Map context, boolean strict )
+ throws AssemblyInterpolationException
+ {
+ StringWriter sWriter = new StringWriter();
+
+ AssemblyXpp3Writer writer = new AssemblyXpp3Writer();
+
+ try
+ {
+ writer.write( sWriter, assembly );
+ }
+ catch ( IOException e )
+ {
+ throw new AssemblyInterpolationException( "Cannot serialize assembly descriptor for interpolation.", e );
+ }
+
+ String serializedAssembly = sWriter.toString();
+
+ serializedAssembly = interpolateInternal( serializedAssembly, assembly, model, context );
+
+ StringReader sReader = new StringReader( serializedAssembly );
+
+ AssemblyXpp3Reader assemblyReader = new AssemblyXpp3Reader();
+ try
+ {
+ assembly = assemblyReader.read( sReader );
+ }
+ catch ( IOException e )
+ {
+ throw new AssemblyInterpolationException(
+ "Cannot read assembly descriptor from interpolating filter of serialized version.", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new AssemblyInterpolationException(
+ "Cannot read assembly descriptor from interpolating filter of serialized version.", e );
+ }
+
+ return assembly;
+ }
+
+ private String interpolateInternal( String src, Assembly assembly, Model model, Map context )
+ throws AssemblyInterpolationException
+ {
+ String result = src;
+
+ Matcher elementMatcher = ELEMENT_PATTERN.matcher( result );
+
+ while ( elementMatcher.find() )
+ {
+ String element = elementMatcher.group( 0 );
+
+ String elementName = elementMatcher.group( 1 );
+ String value = elementMatcher.group( 2 );
+
+ // only attempt to interpolate if the following is met:
+ // 1. the element is not in the interpolation blacklist.
+ // 2. the value is not empty (otherwise there's nothing to interpolate)
+ // 3. the value contains a "${" (a pretty good clue that there's an expression in it)
+ if ( StringUtils.isNotEmpty( value ) && value.indexOf( "${" ) > -1 )
+ {
+ List blacklistedExpressions = (List) INTERPOLATION_BLACKLIST.get( elementName );
+ if ( blacklistedExpressions == null )
+ {
+ blacklistedExpressions = Collections.EMPTY_LIST;
+ }
+
+ String interpolatedValue =
+ interpolateElementValue( value, assembly, model, context, blacklistedExpressions );
+
+ String modifiedElement = StringUtils.replace( element, value, interpolatedValue );
+ result = StringUtils.replace( result, element, modifiedElement );
+ }
+ }
+
+ return result;
+ }
+
+ private String interpolateElementValue( String src, Assembly assembly, Model model, Map context,
+ List blacklistedExpressions )
+ throws AssemblyInterpolationException
+ {
+ String result = src;
+
+ Matcher matcher = EXPRESSION_PATTERN.matcher( result );
+ while ( matcher.find() )
+ {
+ String wholeExpr = matcher.group( 0 );
+ String realExpr = matcher.group( 2 );
+
+ if ( blacklistedExpressions.contains( realExpr ) )
+ {
+ continue;
+ }
+
+ Object value = context.get( realExpr );
+
+ if ( value == null )
+ {
+ value = model.getProperties().getProperty( realExpr );
+ }
+
+ if ( value == null )
+ {
+ try
+ {
+ value = ReflectionValueExtractor.evaluate( realExpr, model );
+ }
+ catch ( Exception e )
+ {
+ Logger logger = getLogger();
+ if ( logger.isDebugEnabled() )
+ {
+ logger.debug( "Assembly descriptor interpolation cannot proceed with expression: " + wholeExpr +
+ ". Skipping...", e );
+ }
+ }
+ }
+
+ if ( value == null )
+ {
+ value = envars.getProperty( realExpr );
+ }
+
+ // if the expression refers to itself, skip it.
+ if ( wholeExpr.equals( value ) )
+ {
+ throw new AssemblyInterpolationException( wholeExpr, assembly.getId() + " references itself." );
+ }
+
+ if ( value != null )
+ {
+ result = StringUtils.replace( result, wholeExpr, String.valueOf( value ) );
+ // could use:
+ // result = matcher.replaceFirst( stringValue );
+ // but this could result in multiple lookups of stringValue, and replaceAll is not correct behaviour
+ matcher.reset( result );
+ }
+ }
+ return result;
+ }
+
+ protected Logger getLogger()
+ {
+ Logger logger = super.getLogger();
+
+ if ( logger == null )
+ {
+ logger = new ConsoleLogger( Logger.LEVEL_INFO, "interpolator-internal" );
+
+ enableLogging( logger );
+ }
+
+ return logger;
+ }
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java Fri Sep 29 07:23:02 2006
@@ -1,96 +1,96 @@
-package org.apache.maven.plugin.assembly.mojos;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
-import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
-import org.apache.maven.plugin.assembly.archive.AssemblyArchiver;
-import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
-import org.apache.maven.plugin.assembly.io.AssemblyReadException;
-import org.apache.maven.plugin.assembly.io.AssemblyReader;
-import org.apache.maven.plugins.assembly.model.Assembly;
-
-import java.util.Iterator;
-import java.util.List;
-
-public abstract class AbstractDirectoryMojo
- extends AbstractAssemblyMojo
-{
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- AssemblyReader reader = getAssemblyReader();
-
- List assemblies;
- try
- {
- assemblies = reader.readAssemblies( this );
- }
- catch ( AssemblyReadException e )
- {
- throw new MojoExecutionException( "Error reading assembly descriptors: " + e.getMessage(), e );
- }
- catch ( InvalidAssemblerConfigurationException e )
- {
- throw new MojoFailureException( reader, e.getMessage(), "Mojo configuration is invalid: " + e.getMessage() );
- }
-
- for ( Iterator i = assemblies.iterator(); i.hasNext(); )
- {
- Assembly assembly = ( Assembly ) i.next();
- createDirectory( assembly );
- }
- }
-
- private void createDirectory( Assembly assembly )
- throws MojoExecutionException, MojoFailureException
- {
- AssemblyArchiver archiver = getAssemblyArchiver();
-
- String fullName = getFinalName();
-
- if ( appendAssemblyId )
- {
- fullName = fullName + "-" + assembly.getId();
- }
- else if ( getClassifier() != null )
- {
- fullName = fullName + "-" + getClassifier();
- }
-
- try
- {
- archiver.createArchive( assembly, fullName, "dir", this );
- }
- catch ( ArchiveCreationException e )
- {
- throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
- }
- catch ( AssemblyFormattingException e )
- {
- throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
- }
- catch ( InvalidAssemblerConfigurationException e )
- {
- throw new MojoFailureException( assembly, "Assembly is incorrectly configured: " + assembly.getId(), "Assembly: "
- + assembly.getId() + " is not configured correctly: " + e.getMessage() );
- }
- }
-
-}
+package org.apache.maven.plugin.assembly.mojos;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
+import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
+import org.apache.maven.plugin.assembly.archive.AssemblyArchiver;
+import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
+import org.apache.maven.plugin.assembly.io.AssemblyReadException;
+import org.apache.maven.plugin.assembly.io.AssemblyReader;
+import org.apache.maven.plugins.assembly.model.Assembly;
+
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class AbstractDirectoryMojo
+ extends AbstractAssemblyMojo
+{
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ AssemblyReader reader = getAssemblyReader();
+
+ List assemblies;
+ try
+ {
+ assemblies = reader.readAssemblies( this );
+ }
+ catch ( AssemblyReadException e )
+ {
+ throw new MojoExecutionException( "Error reading assembly descriptors: " + e.getMessage(), e );
+ }
+ catch ( InvalidAssemblerConfigurationException e )
+ {
+ throw new MojoFailureException( reader, e.getMessage(), "Mojo configuration is invalid: " + e.getMessage() );
+ }
+
+ for ( Iterator i = assemblies.iterator(); i.hasNext(); )
+ {
+ Assembly assembly = ( Assembly ) i.next();
+ createDirectory( assembly );
+ }
+ }
+
+ private void createDirectory( Assembly assembly )
+ throws MojoExecutionException, MojoFailureException
+ {
+ AssemblyArchiver archiver = getAssemblyArchiver();
+
+ String fullName = getFinalName();
+
+ if ( appendAssemblyId )
+ {
+ fullName = fullName + "-" + assembly.getId();
+ }
+ else if ( getClassifier() != null )
+ {
+ fullName = fullName + "-" + getClassifier();
+ }
+
+ try
+ {
+ archiver.createArchive( assembly, fullName, "dir", this );
+ }
+ catch ( ArchiveCreationException e )
+ {
+ throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
+ }
+ catch ( AssemblyFormattingException e )
+ {
+ throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
+ }
+ catch ( InvalidAssemblerConfigurationException e )
+ {
+ throw new MojoFailureException( assembly, "Assembly is incorrectly configured: " + assembly.getId(), "Assembly: "
+ + assembly.getId() + " is not configured correctly: " + e.getMessage() );
+ }
+ }
+
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractDirectoryMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AssemblyMojo.java
('svn:executable' removed)
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java Fri Sep 29 07:23:02 2006
@@ -1,45 +1,45 @@
-package org.apache.maven.plugin.assembly.mojos;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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;
-
-/**
- * Assemble an application bundle or distribution from an assembly descriptor without
- * launching a parallel lifecycle build.
- *
- * @author <a href="mailto:gscokart@users.sourceforge.net">Gilles Scokart</a>
- *
- * @goal directory-inline
- * @aggregator
- */
-public class DirectoryInlineMojo
- extends AbstractDirectoryMojo
-{
- /**
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- public MavenProject getProject()
- {
- return project;
- }
-
-}
+package org.apache.maven.plugin.assembly.mojos;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+/**
+ * Assemble an application bundle or distribution from an assembly descriptor without
+ * launching a parallel lifecycle build.
+ *
+ * @author <a href="mailto:gscokart@users.sourceforge.net">Gilles Scokart</a>
+ *
+ * @goal directory-inline
+ * @aggregator
+ */
+public class DirectoryInlineMojo
+ extends AbstractDirectoryMojo
+{
+ /**
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/DirectoryInlineMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java?view=diff&rev=451306&r1=451305&r2=451306
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java Fri Sep 29 07:23:02 2006
@@ -1,94 +1,94 @@
-package org.apache.maven.plugin.assembly.utils;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed 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 org.codehaus.plexus.util.interpolation.RegexBasedInterpolator;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Properties;
-
-
-/**
- * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
- * @version $Id: PropertyUtils.java 191749 2005-06-22 01:21:07Z brett $
- */
-public final class PropertyUtils
-{
- private PropertyUtils()
- {
- // prevent instantiation
- }
-
- /**
- * 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 getInterpolatedPropertiesFromFile( File propfile, boolean fail, boolean useSystemProps )
- throws IOException
- {
- Properties props;
-
- if ( useSystemProps )
- {
- props = new Properties( System.getProperties() );
- }
- else
- {
- props = new Properties();
- }
-
- if ( propfile.exists() )
- {
- FileInputStream inStream = new FileInputStream( propfile );
- try
- {
- props.load( inStream );
- }
- finally
- {
- IOUtil.close( inStream );
- }
- }
- else if ( fail )
- {
- throw new FileNotFoundException( propfile.toString() );
- }
-
- RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
- interpolator.addValueSource( new PropertiesInterpolationValueSource( props ) );
-
- for ( Enumeration n = props.propertyNames(); n.hasMoreElements(); )
- {
- String key = (String) n.nextElement();
- String value = interpolator.interpolate( props.getProperty( key ), "__properties" );
-
- props.setProperty( key, value );
- }
-
- return props;
- }
-
-}
+package org.apache.maven.plugin.assembly.utils;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 org.codehaus.plexus.util.interpolation.RegexBasedInterpolator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Properties;
+
+
+/**
+ * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
+ * @version $Id$
+ */
+public final class PropertyUtils
+{
+ private PropertyUtils()
+ {
+ // prevent instantiation
+ }
+
+ /**
+ * 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 getInterpolatedPropertiesFromFile( File propfile, boolean fail, boolean useSystemProps )
+ throws IOException
+ {
+ Properties props;
+
+ if ( useSystemProps )
+ {
+ props = new Properties( System.getProperties() );
+ }
+ else
+ {
+ props = new Properties();
+ }
+
+ if ( propfile.exists() )
+ {
+ FileInputStream inStream = new FileInputStream( propfile );
+ try
+ {
+ props.load( inStream );
+ }
+ finally
+ {
+ IOUtil.close( inStream );
+ }
+ }
+ else if ( fail )
+ {
+ throw new FileNotFoundException( propfile.toString() );
+ }
+
+ RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
+ interpolator.addValueSource( new PropertiesInterpolationValueSource( props ) );
+
+ for ( Enumeration n = props.propertyNames(); n.hasMoreElements(); )
+ {
+ String key = (String) n.nextElement();
+ String value = interpolator.interpolate( props.getProperty( key ), "__properties" );
+
+ props.setProperty( key, value );
+ }
+
+ return props;
+ }
+
+}
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision