You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/02/21 09:04:06 UTC
[maven-plugin-tools] branch master updated: [MPLUGIN-391] Deprecate scripting support for mojos
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 8b91073 [MPLUGIN-391] Deprecate scripting support for mojos
8b91073 is described below
commit 8b91073f390f8341a78dfa6eeb26c2acc252818c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Feb 21 10:04:01 2022 +0100
[MPLUGIN-391] Deprecate scripting support for mojos
---
.../AbstractScriptedMojoDescriptorExtractor.java | 8 +
.../extractor/ant/AntMojoDescriptorExtractor.java | 2 +
.../BeanshellMojoDescriptorExtractor.java | 2 +
.../model/PluginMetadataParseException.java | 158 ++++----
.../extractor/model/PluginMetadataParser.java | 383 +++++++++----------
.../maven/script/ant/AntMojoComponentFactory.java | 86 ++---
.../apache/maven/script/ant/AntMojoWrapper.java | 4 +-
.../apache/maven/script/ant/AntPropertyHelper.java | 412 +++++++++++----------
.../script/beanshell/BeanshellMojoAdapter.java | 142 +++----
9 files changed, 611 insertions(+), 586 deletions(-)
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
index 8955ffb..ee11cbc 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
@@ -37,8 +37,10 @@ import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
/**
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
* @author jdcasey
*/
+@Deprecated
public abstract class AbstractScriptedMojoDescriptorExtractor
extends AbstractLogEnabled
implements MojoDescriptorExtractor
@@ -75,6 +77,12 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
copyScriptsToOutputDirectory( scriptFilesKeyedByBasedir, project.getBuild().getOutputDirectory(), request );
+ if ( !mojoDescriptors.isEmpty() )
+ {
+ getLogger().warn( "Scripting support for mojos is deprecated and is planned to be removed in Maven 4." );
+ getLogger().warn( "Found " + mojoDescriptors.size() + " scripted mojos." );
+ }
+
return mojoDescriptors;
}
diff --git a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
index acd08a1..062369b 100644
--- a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
@@ -44,8 +44,10 @@ import org.codehaus.plexus.util.StringUtils;
/**
* Extracts Mojo descriptors from <a href="http://ant.apache.org">Ant</a> sources.
*
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
@Component( role = MojoDescriptorExtractor.class, hint = "ant" )
+@Deprecated
public class AntMojoDescriptorExtractor
extends AbstractScriptedMojoDescriptorExtractor
implements MojoDescriptorExtractor
diff --git a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
index 14ba47d..a688fdc 100644
--- a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
@@ -41,7 +41,9 @@ import java.util.Set;
/**
* Extracts Mojo descriptors from <a href="http://www.beanshell.org/">BeanShell</a> sources.
*
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
+@Deprecated
@Component( role = MojoDescriptorExtractor.class, hint = "bsh" )
public class BeanshellMojoDescriptorExtractor
extends AbstractScriptedMojoDescriptorExtractor
diff --git a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
index f078039..8887013 100644
--- a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
+++ b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
@@ -1,78 +1,80 @@
-package org.apache.maven.tools.plugin.extractor.model;
-
-/*
- * 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;
-
-/**
- * Exception when plugin metadata parsing occurred.
- *
- */
-public class PluginMetadataParseException
- extends Exception
-{
- /** serialVersionUID */
- static final long serialVersionUID = 4022348153707995574L;
-
- private final File metadataFile;
-
- private final String originalMessage;
-
- /**
- * @param metadataFile could be null
- * @param message could be null
- * @param cause could be null
- */
- public PluginMetadataParseException( File metadataFile, String message, Throwable cause )
- {
- super( "Error parsing file: " + metadataFile + ". Reason: " + message, cause );
-
- this.metadataFile = metadataFile;
- this.originalMessage = message;
- }
-
- /**
- * @param metadataFile could be null
- * @param message could be null
- */
- public PluginMetadataParseException( File metadataFile, String message )
- {
- super( "Error parsing file: " + metadataFile + ". Reason: " + message );
-
- this.metadataFile = metadataFile;
- this.originalMessage = message;
- }
-
- /**
- * @return the metadata file
- */
- public File getMetadataFile()
- {
- return metadataFile;
- }
-
- /**
- * @return the original message
- */
- public String getOriginalMessage()
- {
- return originalMessage;
- }
-}
+package org.apache.maven.tools.plugin.extractor.model;
+
+/*
+ * 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;
+
+/**
+ * Exception when plugin metadata parsing occurred.
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class PluginMetadataParseException
+ extends Exception
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 4022348153707995574L;
+
+ private final File metadataFile;
+
+ private final String originalMessage;
+
+ /**
+ * @param metadataFile could be null
+ * @param message could be null
+ * @param cause could be null
+ */
+ public PluginMetadataParseException( File metadataFile, String message, Throwable cause )
+ {
+ super( "Error parsing file: " + metadataFile + ". Reason: " + message, cause );
+
+ this.metadataFile = metadataFile;
+ this.originalMessage = message;
+ }
+
+ /**
+ * @param metadataFile could be null
+ * @param message could be null
+ */
+ public PluginMetadataParseException( File metadataFile, String message )
+ {
+ super( "Error parsing file: " + metadataFile + ". Reason: " + message );
+
+ this.metadataFile = metadataFile;
+ this.originalMessage = message;
+ }
+
+ /**
+ * @return the metadata file
+ */
+ public File getMetadataFile()
+ {
+ return metadataFile;
+ }
+
+ /**
+ * @return the original message
+ */
+ public String getOriginalMessage()
+ {
+ return originalMessage;
+ }
+}
diff --git a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
index e0596f4..035f997 100644
--- a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
+++ b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
@@ -1,190 +1,193 @@
-package org.apache.maven.tools.plugin.extractor.model;
-
-/*
- * 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.descriptor.DuplicateParameterException;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugin.descriptor.Parameter;
-import org.apache.maven.tools.plugin.extractor.model.io.xpp3.PluginMetadataXpp3Reader;
-import org.codehaus.plexus.component.repository.ComponentRequirement;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Parser for plugin metadata.
- */
-public class PluginMetadataParser
-{
- /**
- * Default implementation path which will be replaced in
- * AbstractScriptedMojoDescriptorExtractor#extractMojoDescriptorsFromMetadata(Map, PluginDescriptor)
- */
- public static final String IMPL_BASE_PLACEHOLDER = "<REPLACE-WITH-MOJO-PATH>";
-
- /**
- * @param metadataFile the metadata file to be parse
- * @return a set of <code>MojoDescriptor</code>
- * @throws PluginMetadataParseException if any
- */
- public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
- throws PluginMetadataParseException
- {
- Set<MojoDescriptor> descriptors = new HashSet<>();
-
- try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
- {
-
- PluginMetadataXpp3Reader metadataReader = new PluginMetadataXpp3Reader();
-
- PluginMetadata pluginMetadata = metadataReader.read( reader );
-
- List<Mojo> mojos = pluginMetadata.getMojos();
-
- if ( mojos != null )
- {
- for ( Mojo mojo : mojos )
- {
- MojoDescriptor descriptor = asDescriptor( metadataFile, mojo );
-
- descriptors.add( descriptor );
- }
- }
- }
- catch ( IOException | XmlPullParserException e )
- {
- throw new PluginMetadataParseException( metadataFile, "Cannot parse plugin metadata from file.", e );
- }
-
- return descriptors;
- }
-
- /**
- * @param metadataFile not null
- * @param mojo not null
- * @return a mojo descriptor instance
- * @throws PluginMetadataParseException if any
- */
- private MojoDescriptor asDescriptor( File metadataFile, Mojo mojo )
- throws PluginMetadataParseException
- {
- MojoDescriptor descriptor = new MojoDescriptor();
-
- if ( mojo.getCall() != null )
- {
- descriptor.setImplementation( IMPL_BASE_PLACEHOLDER + ":" + mojo.getCall() );
- }
- else
- {
- descriptor.setImplementation( IMPL_BASE_PLACEHOLDER );
- }
-
- descriptor.setGoal( mojo.getGoal() );
- descriptor.setPhase( mojo.getPhase() );
- descriptor.setDependencyResolutionRequired( mojo.getRequiresDependencyResolution() );
- descriptor.setAggregator( mojo.isAggregator() );
- descriptor.setInheritedByDefault( mojo.isInheritByDefault() );
- descriptor.setDirectInvocationOnly( mojo.isRequiresDirectInvocation() );
- descriptor.setOnlineRequired( mojo.isRequiresOnline() );
- descriptor.setProjectRequired( mojo.isRequiresProject() );
- descriptor.setRequiresReports( mojo.isRequiresReports() );
- descriptor.setDescription( mojo.getDescription() );
- descriptor.setDeprecated( mojo.getDeprecation() );
- descriptor.setSince( mojo.getSince() );
-
- LifecycleExecution le = mojo.getExecution();
- if ( le != null )
- {
- descriptor.setExecuteLifecycle( le.getLifecycle() );
- descriptor.setExecutePhase( le.getPhase() );
- descriptor.setExecuteGoal( le.getGoal() );
- }
-
- List<org.apache.maven.tools.plugin.extractor.model.Parameter> parameters = mojo.getParameters();
-
- if ( parameters != null && !parameters.isEmpty() )
- {
- for ( org.apache.maven.tools.plugin.extractor.model.Parameter param : parameters )
- {
- Parameter dParam = new Parameter();
- dParam.setAlias( param.getAlias() );
- dParam.setDeprecated( param.getDeprecation() );
- dParam.setDescription( param.getDescription() );
- dParam.setEditable( !param.isReadonly() );
- dParam.setExpression( param.getExpression() );
- dParam.setDefaultValue( param.getDefaultValue() );
- dParam.setSince( param.getSince() );
-
- String property = param.getProperty();
- if ( StringUtils.isNotEmpty( property ) )
- {
- dParam.setName( property );
- }
- else
- {
- dParam.setName( param.getName() );
- }
-
- if ( StringUtils.isEmpty( dParam.getName() ) )
- {
- throw new PluginMetadataParseException( metadataFile, "Mojo: \'" + mojo.getGoal()
- + "\' has a parameter without either property or name attributes. Please specify one." );
- }
-
- dParam.setRequired( param.isRequired() );
- dParam.setType( param.getType() );
-
- try
- {
- descriptor.addParameter( dParam );
- }
- catch ( DuplicateParameterException e )
- {
- throw new PluginMetadataParseException( metadataFile,
- "Duplicate parameters detected for mojo: " + mojo.getGoal(),
- e );
- }
- }
- }
-
- List<Component> components = mojo.getComponents();
-
- if ( components != null && !components.isEmpty() )
- {
- for ( Component component : components )
- {
- ComponentRequirement cr = new ComponentRequirement();
- cr.setRole( component.getRole() );
- cr.setRoleHint( component.getHint() );
-
- descriptor.addRequirement( cr );
- }
- }
-
- return descriptor;
- }
-}
+package org.apache.maven.tools.plugin.extractor.model;
+
+/*
+ * 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.descriptor.DuplicateParameterException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.tools.plugin.extractor.model.io.xpp3.PluginMetadataXpp3Reader;
+import org.codehaus.plexus.component.repository.ComponentRequirement;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Parser for plugin metadata.
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class PluginMetadataParser
+{
+ /**
+ * Default implementation path which will be replaced in
+ * AbstractScriptedMojoDescriptorExtractor#extractMojoDescriptorsFromMetadata(Map, PluginDescriptor)
+ */
+ public static final String IMPL_BASE_PLACEHOLDER = "<REPLACE-WITH-MOJO-PATH>";
+
+ /**
+ * @param metadataFile the metadata file to be parse
+ * @return a set of <code>MojoDescriptor</code>
+ * @throws PluginMetadataParseException if any
+ */
+ public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
+ throws PluginMetadataParseException
+ {
+ Set<MojoDescriptor> descriptors = new HashSet<>();
+
+ try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
+ {
+
+ PluginMetadataXpp3Reader metadataReader = new PluginMetadataXpp3Reader();
+
+ PluginMetadata pluginMetadata = metadataReader.read( reader );
+
+ List<Mojo> mojos = pluginMetadata.getMojos();
+
+ if ( mojos != null )
+ {
+ for ( Mojo mojo : mojos )
+ {
+ MojoDescriptor descriptor = asDescriptor( metadataFile, mojo );
+
+ descriptors.add( descriptor );
+ }
+ }
+ }
+ catch ( IOException | XmlPullParserException e )
+ {
+ throw new PluginMetadataParseException( metadataFile, "Cannot parse plugin metadata from file.", e );
+ }
+
+ return descriptors;
+ }
+
+ /**
+ * @param metadataFile not null
+ * @param mojo not null
+ * @return a mojo descriptor instance
+ * @throws PluginMetadataParseException if any
+ */
+ private MojoDescriptor asDescriptor( File metadataFile, Mojo mojo )
+ throws PluginMetadataParseException
+ {
+ MojoDescriptor descriptor = new MojoDescriptor();
+
+ if ( mojo.getCall() != null )
+ {
+ descriptor.setImplementation( IMPL_BASE_PLACEHOLDER + ":" + mojo.getCall() );
+ }
+ else
+ {
+ descriptor.setImplementation( IMPL_BASE_PLACEHOLDER );
+ }
+
+ descriptor.setGoal( mojo.getGoal() );
+ descriptor.setPhase( mojo.getPhase() );
+ descriptor.setDependencyResolutionRequired( mojo.getRequiresDependencyResolution() );
+ descriptor.setAggregator( mojo.isAggregator() );
+ descriptor.setInheritedByDefault( mojo.isInheritByDefault() );
+ descriptor.setDirectInvocationOnly( mojo.isRequiresDirectInvocation() );
+ descriptor.setOnlineRequired( mojo.isRequiresOnline() );
+ descriptor.setProjectRequired( mojo.isRequiresProject() );
+ descriptor.setRequiresReports( mojo.isRequiresReports() );
+ descriptor.setDescription( mojo.getDescription() );
+ descriptor.setDeprecated( mojo.getDeprecation() );
+ descriptor.setSince( mojo.getSince() );
+
+ LifecycleExecution le = mojo.getExecution();
+ if ( le != null )
+ {
+ descriptor.setExecuteLifecycle( le.getLifecycle() );
+ descriptor.setExecutePhase( le.getPhase() );
+ descriptor.setExecuteGoal( le.getGoal() );
+ }
+
+ List<org.apache.maven.tools.plugin.extractor.model.Parameter> parameters = mojo.getParameters();
+
+ if ( parameters != null && !parameters.isEmpty() )
+ {
+ for ( org.apache.maven.tools.plugin.extractor.model.Parameter param : parameters )
+ {
+ Parameter dParam = new Parameter();
+ dParam.setAlias( param.getAlias() );
+ dParam.setDeprecated( param.getDeprecation() );
+ dParam.setDescription( param.getDescription() );
+ dParam.setEditable( !param.isReadonly() );
+ dParam.setExpression( param.getExpression() );
+ dParam.setDefaultValue( param.getDefaultValue() );
+ dParam.setSince( param.getSince() );
+
+ String property = param.getProperty();
+ if ( StringUtils.isNotEmpty( property ) )
+ {
+ dParam.setName( property );
+ }
+ else
+ {
+ dParam.setName( param.getName() );
+ }
+
+ if ( StringUtils.isEmpty( dParam.getName() ) )
+ {
+ throw new PluginMetadataParseException( metadataFile, "Mojo: \'" + mojo.getGoal()
+ + "\' has a parameter without either property or name attributes. Please specify one." );
+ }
+
+ dParam.setRequired( param.isRequired() );
+ dParam.setType( param.getType() );
+
+ try
+ {
+ descriptor.addParameter( dParam );
+ }
+ catch ( DuplicateParameterException e )
+ {
+ throw new PluginMetadataParseException( metadataFile,
+ "Duplicate parameters detected for mojo: " + mojo.getGoal(),
+ e );
+ }
+ }
+ }
+
+ List<Component> components = mojo.getComponents();
+
+ if ( components != null && !components.isEmpty() )
+ {
+ for ( Component component : components )
+ {
+ ComponentRequirement cr = new ComponentRequirement();
+ cr.setRole( component.getRole() );
+ cr.setRoleHint( component.getHint() );
+
+ descriptor.addRequirement( cr );
+ }
+ }
+
+ return descriptor;
+ }
+}
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
index 6c5a916..e13e7ba 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
@@ -1,42 +1,44 @@
-package org.apache.maven.script.ant;
-
-/*
- * 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.classworlds.ClassRealm;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.factory.ComponentInstantiationException;
-import org.codehaus.plexus.component.factory.ant.AntComponentFactory;
-import org.codehaus.plexus.component.factory.ant.AntScriptInvoker;
-import org.codehaus.plexus.component.repository.ComponentDescriptor;
-
-/**
- *
- */
-public class AntMojoComponentFactory
- extends AntComponentFactory
-{
-
- public Object newInstance( ComponentDescriptor descriptor, ClassRealm realm, PlexusContainer container )
- throws ComponentInstantiationException
- {
- return new AntMojoWrapper( (AntScriptInvoker) super.newInstance( descriptor, realm, container ) );
- }
-
-}
+package org.apache.maven.script.ant;
+
+/*
+ * 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.classworlds.ClassRealm;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.factory.ComponentInstantiationException;
+import org.codehaus.plexus.component.factory.ant.AntComponentFactory;
+import org.codehaus.plexus.component.factory.ant.AntScriptInvoker;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+
+/**
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class AntMojoComponentFactory
+ extends AntComponentFactory
+{
+
+ public Object newInstance( ComponentDescriptor descriptor, ClassRealm realm, PlexusContainer container )
+ throws ComponentInstantiationException
+ {
+ return new AntMojoWrapper( (AntScriptInvoker) super.newInstance( descriptor, realm, container ) );
+ }
+
+}
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
index 90f33d0..852ee80 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
@@ -53,8 +53,10 @@ import java.util.List;
import java.util.Map;
/**
- *
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
+@Deprecated
public class AntMojoWrapper
extends AbstractMojo
implements ContextEnabled, MapOrientedComponent, LogEnabled
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
index ee6c701..f5c8e0d 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
@@ -1,205 +1,207 @@
-package org.apache.maven.script.ant;
-
-/*
- * 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.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.apache.tools.ant.PropertyHelper;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-
-/**
- * Makes the ${expressions} used in Maven available to Ant as properties.
- *
- * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
- */
-public class AntPropertyHelper
- extends PropertyHelper
-{
- private static final String DEPENDENCY_PREFIX = "maven.dependency.";
- private Log log;
- private ExpressionEvaluator exprEvaluator;
- private MavenProject mavenProject;
- private Map<String, String> artifactMap = new HashMap<String, String>();
-
- /**
- * @deprecated use the other constructor
- * @param project
- * @param l
- */
- public AntPropertyHelper( MavenProject project, Log l )
- {
- mavenProject = project;
- log = l;
- }
-
- /**
- * @deprecated use {@link #AntPropertyHelper(ExpressionEvaluator, Set, Log)} to resolve maven.dependency.*
- * properties
- * @param exprEvaluator
- * @param l
- */
- public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Log l )
- {
- this( exprEvaluator, Collections.<Artifact>emptySet(), l );
- }
-
- /**
- * @param exprEvaluator
- * @param artifacts
- * @param l
- */
- public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set<Artifact> artifacts, Log l )
- {
- this.mavenProject = null;
- this.exprEvaluator = exprEvaluator;
- this.log = l;
-
- for ( Artifact artifact : artifacts )
- {
- String key = DEPENDENCY_PREFIX + artifact.getGroupId() + "." + artifact.getArtifactId()
- + ( artifact.getClassifier() != null ? "." + artifact.getClassifier() : "" )
- + ( artifact.getType() != null ? "." + artifact.getType() : "" ) + ".path";
-
- log.debug( "Storing: " + key + "=" + artifact.getFile().getPath() );
-
- artifactMap.put( key, artifact.getFile().getPath() );
- }
- }
-
- /**
- * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean)
- */
- public synchronized Object getPropertyHook( String ns, String name, boolean user )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "getProperty(ns=" + ns + ", name=" + name + ", user=" + user + ")" );
- }
-
- /* keep old behaviour */
- if ( mavenProject != null )
- {
- return getPropertyHook( ns, name, user, mavenProject );
- }
-
-
- Object val = null;
-
- if ( name.startsWith( DEPENDENCY_PREFIX ) )
- {
- val = artifactMap.get( name );
- }
-
- if ( val == null )
- {
- try
- {
- val = exprEvaluator.evaluate( "${" + name + "}" );
- }
- catch ( ExpressionEvaluationException e )
- {
- if ( log.isErrorEnabled() )
- {
- log.error( "Failed to evaluate expression", e );
- }
- }
- }
-
- if ( val == null )
- {
- val = super.getPropertyHook( ns, name, user );
-
- if ( val == null )
- {
- val = System.getProperty( name );
- }
- }
-
- return val;
- }
-
- /**
- * @deprecated added to keep backwards compatibility
- * @param ns
- * @param name
- * @param user
- * @param mavenProject
- * @return The property value.
- */
- private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject )
- {
- Object val = null;
- try
- {
- if ( name.startsWith( DEPENDENCY_PREFIX ) )
- {
- val = artifactMap.get( name );
- }
- else if ( name.startsWith( "project." ) )
- {
- val = ReflectionValueExtractor.evaluate(
- name,
- mavenProject,
- true
- );
- }
- else if ( name.equals( "basedir" ) )
- {
- val = ReflectionValueExtractor.evaluate(
- "basedir.path",
- mavenProject,
- false
- );
- }
- }
- catch ( Exception e )
- {
- if ( log.isWarnEnabled() )
- {
- log.warn( "Error evaluating expression '" + name + "'", e );
- }
- }
-
- if ( val == null )
- {
- val = super.getPropertyHook( ns, name, user );
- if ( val == null )
- {
- val = System.getProperty( name );
- }
- }
-
- if ( val instanceof File )
- {
- val = ( (File) val ).getAbsoluteFile();
- }
-
- return val;
- }
-}
+package org.apache.maven.script.ant;
+
+/*
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.PropertyHelper;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+
+/**
+ * Makes the ${expressions} used in Maven available to Ant as properties.
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class AntPropertyHelper
+ extends PropertyHelper
+{
+ private static final String DEPENDENCY_PREFIX = "maven.dependency.";
+ private Log log;
+ private ExpressionEvaluator exprEvaluator;
+ private MavenProject mavenProject;
+ private Map<String, String> artifactMap = new HashMap<String, String>();
+
+ /**
+ * @deprecated use the other constructor
+ * @param project
+ * @param l
+ */
+ public AntPropertyHelper( MavenProject project, Log l )
+ {
+ mavenProject = project;
+ log = l;
+ }
+
+ /**
+ * @deprecated use {@link #AntPropertyHelper(ExpressionEvaluator, Set, Log)} to resolve maven.dependency.*
+ * properties
+ * @param exprEvaluator
+ * @param l
+ */
+ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Log l )
+ {
+ this( exprEvaluator, Collections.<Artifact>emptySet(), l );
+ }
+
+ /**
+ * @param exprEvaluator
+ * @param artifacts
+ * @param l
+ */
+ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set<Artifact> artifacts, Log l )
+ {
+ this.mavenProject = null;
+ this.exprEvaluator = exprEvaluator;
+ this.log = l;
+
+ for ( Artifact artifact : artifacts )
+ {
+ String key = DEPENDENCY_PREFIX + artifact.getGroupId() + "." + artifact.getArtifactId()
+ + ( artifact.getClassifier() != null ? "." + artifact.getClassifier() : "" )
+ + ( artifact.getType() != null ? "." + artifact.getType() : "" ) + ".path";
+
+ log.debug( "Storing: " + key + "=" + artifact.getFile().getPath() );
+
+ artifactMap.put( key, artifact.getFile().getPath() );
+ }
+ }
+
+ /**
+ * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean)
+ */
+ public synchronized Object getPropertyHook( String ns, String name, boolean user )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "getProperty(ns=" + ns + ", name=" + name + ", user=" + user + ")" );
+ }
+
+ /* keep old behaviour */
+ if ( mavenProject != null )
+ {
+ return getPropertyHook( ns, name, user, mavenProject );
+ }
+
+
+ Object val = null;
+
+ if ( name.startsWith( DEPENDENCY_PREFIX ) )
+ {
+ val = artifactMap.get( name );
+ }
+
+ if ( val == null )
+ {
+ try
+ {
+ val = exprEvaluator.evaluate( "${" + name + "}" );
+ }
+ catch ( ExpressionEvaluationException e )
+ {
+ if ( log.isErrorEnabled() )
+ {
+ log.error( "Failed to evaluate expression", e );
+ }
+ }
+ }
+
+ if ( val == null )
+ {
+ val = super.getPropertyHook( ns, name, user );
+
+ if ( val == null )
+ {
+ val = System.getProperty( name );
+ }
+ }
+
+ return val;
+ }
+
+ /**
+ * @deprecated added to keep backwards compatibility
+ * @param ns
+ * @param name
+ * @param user
+ * @param mavenProject
+ * @return The property value.
+ */
+ private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject )
+ {
+ Object val = null;
+ try
+ {
+ if ( name.startsWith( DEPENDENCY_PREFIX ) )
+ {
+ val = artifactMap.get( name );
+ }
+ else if ( name.startsWith( "project." ) )
+ {
+ val = ReflectionValueExtractor.evaluate(
+ name,
+ mavenProject,
+ true
+ );
+ }
+ else if ( name.equals( "basedir" ) )
+ {
+ val = ReflectionValueExtractor.evaluate(
+ "basedir.path",
+ mavenProject,
+ false
+ );
+ }
+ }
+ catch ( Exception e )
+ {
+ if ( log.isWarnEnabled() )
+ {
+ log.warn( "Error evaluating expression '" + name + "'", e );
+ }
+ }
+
+ if ( val == null )
+ {
+ val = super.getPropertyHook( ns, name, user );
+ if ( val == null )
+ {
+ val = System.getProperty( name );
+ }
+ }
+
+ if ( val instanceof File )
+ {
+ val = ( (File) val ).getAbsoluteFile();
+ }
+
+ return val;
+ }
+}
diff --git a/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java b/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
index 405458a..b2008f8 100644
--- a/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
+++ b/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
@@ -1,70 +1,72 @@
-package org.apache.maven.script.beanshell;
-
-/*
- * 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 bsh.EvalError;
-import bsh.Interpreter;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.component.factory.bsh.BshComponent;
-
-/**
- * Mojo adapter for a Beanshell Mojo.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public class BeanshellMojoAdapter
- extends AbstractMojo
- implements BshComponent
-{
- private Mojo mojo;
-
- private Interpreter interpreter;
-
- public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter )
- {
- this.mojo = mojo;
- this.interpreter = interpreter;
- }
-
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- try
- {
- interpreter.set( "logger", getLog() );
-
- // TODO: set out, err to a print stream that will log at info, error respectively
- }
- catch ( EvalError evalError )
- {
- throw new MojoExecutionException( "Unable to establish mojo", evalError );
- }
-
- mojo.execute();
- }
-
- public Interpreter getInterpreter()
- {
- return interpreter;
- }
-}
+package org.apache.maven.script.beanshell;
+
+/*
+ * 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 bsh.EvalError;
+import bsh.Interpreter;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.component.factory.bsh.BshComponent;
+
+/**
+ * Mojo adapter for a Beanshell Mojo.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class BeanshellMojoAdapter
+ extends AbstractMojo
+ implements BshComponent
+{
+ private Mojo mojo;
+
+ private Interpreter interpreter;
+
+ public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter )
+ {
+ this.mojo = mojo;
+ this.interpreter = interpreter;
+ }
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ try
+ {
+ interpreter.set( "logger", getLog() );
+
+ // TODO: set out, err to a print stream that will log at info, error respectively
+ }
+ catch ( EvalError evalError )
+ {
+ throw new MojoExecutionException( "Unable to establish mojo", evalError );
+ }
+
+ mojo.execute();
+ }
+
+ public Interpreter getInterpreter()
+ {
+ return interpreter;
+ }
+}