You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2021/09/24 20:19:11 UTC
[maven] branch master updated: [MNG-7265] Convert maven-core
artifact-handlers.xml to Providers
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 2926f03 [MNG-7265] Convert maven-core artifact-handlers.xml to Providers
2926f03 is described below
commit 2926f033cb934e7bcef51362639663bc2a39cf9a
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Sep 23 13:10:54 2021 +0200
[MNG-7265] Convert maven-core artifact-handlers.xml to Providers
Gets rid of another set of Plexus components defined in XML.
Changes:
* DefaultArtifactHandler was declared as component but it is not needed; not
a component anymore
* Sanitize DefaultArtifactHandler class but retain Plexus XML provisioning
compatiblity (as plugins does have it declared in Plexus XML) and update its
uses within Maven code (be explicit)
* Use new "full" constructors in handler providers for easier comparison and
inspection (be explicit)
This closes #551
---
.../maven/artifact/handler/ArtifactHandler.java | 1 +
.../java/org/apache/maven/RepositoryUtils.java | 18 +-
.../artifact/handler/DefaultArtifactHandler.java | 96 +++++++---
.../providers/EarArtifactHandlerProvider.java | 57 ++++++
.../providers/EjbArtifactHandlerProvider.java | 57 ++++++
.../EjbClientArtifactHandlerProvider.java | 57 ++++++
.../providers/JarArtifactHandlerProvider.java | 57 ++++++
.../JavaSourceArtifactHandlerProvider.java | 57 ++++++
.../providers/JavadocArtifactHandlerProvider.java | 57 ++++++
.../MavenPluginArtifactHandlerProvider.java | 57 ++++++
.../providers/PomArtifactHandlerProvider.java | 57 ++++++
.../providers/RarArtifactHandlerProvider.java | 57 ++++++
.../providers/TestJarArtifactHandlerProvider.java | 57 ++++++
.../providers/WarArtifactHandlerProvider.java | 57 ++++++
.../maven/project/artifact/PluginArtifact.java | 1 +
.../maven/project/artifact/ProjectArtifact.java | 1 +
.../META-INF/plexus/artifact-handlers.xml | 194 ---------------------
.../plugin/internal/MavenPluginValidatorTest.java | 8 +-
18 files changed, 719 insertions(+), 227 deletions(-)
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
index f85f4ea..db101bf 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
@@ -30,6 +30,7 @@ package org.apache.maven.artifact.handler;
*/
public interface ArtifactHandler
{
+ @Deprecated
String ROLE = ArtifactHandler.class.getName();
/**
diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
index 1f4abfc..a49b670 100644
--- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
+++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
@@ -279,14 +279,16 @@ public class RepositoryUtils
public static ArtifactHandler newHandler( Artifact artifact )
{
String type = artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() );
- DefaultArtifactHandler handler = new DefaultArtifactHandler( type );
- handler.setExtension( artifact.getExtension() );
- handler.setLanguage( artifact.getProperty( ArtifactProperties.LANGUAGE, null ) );
- String addedToClasspath = artifact.getProperty( ArtifactProperties.CONSTITUTES_BUILD_PATH, "" );
- handler.setAddedToClasspath( Boolean.parseBoolean( addedToClasspath ) );
- String includesDependencies = artifact.getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" );
- handler.setIncludesDependencies( Boolean.parseBoolean( includesDependencies ) );
- return handler;
+ return new DefaultArtifactHandler(
+ type,
+ artifact.getExtension(),
+ null,
+ null,
+ null,
+ Boolean.parseBoolean( artifact.getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ) ),
+ artifact.getProperty( ArtifactProperties.LANGUAGE, null ),
+ Boolean.parseBoolean( artifact.getProperty( ArtifactProperties.CONSTITUTES_BUILD_PATH, "" ) )
+ );
}
public static ArtifactType newArtifactType( String id, ArtifactHandler handler )
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java
index e4ab338..bb90aff 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.java
@@ -19,21 +19,18 @@ package org.apache.maven.artifact.handler;
* under the License.
*/
-import javax.inject.Named;
-import javax.inject.Singleton;
+import static java.util.Objects.requireNonNull;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl
*/
-@Named
-@Singleton
public class DefaultArtifactHandler
implements ArtifactHandler
{
- private String extension;
+ private final String type;
- private String type;
+ private String extension;
private String classifier;
@@ -47,90 +44,147 @@ public class DefaultArtifactHandler
private boolean addedToClasspath;
+ /**
+ * Default ctor for Plexus compatibility, as many plugins have artifact handlers declared in legacy Plexus XML.
+ * Do not use directly!
+ *
+ * @deprecated This ctor is present only for Plexus XML defined component compatibility, do not use it.
+ */
+ @Deprecated
public DefaultArtifactHandler()
{
+ this.type = null;
+ }
+
+ public DefaultArtifactHandler( final String type )
+ {
+ this(
+ type,
+ null,
+ null,
+ null,
+ null,
+ false,
+ null,
+ false
+ );
+ }
+
+ public DefaultArtifactHandler( final String type,
+ final String extension,
+ final String classifier,
+ final String directory,
+ final String packaging,
+ final boolean includesDependencies,
+ final String language,
+ final boolean addedToClasspath )
+ {
+ this.type = requireNonNull( type );
+ this.extension = extension;
+ this.classifier = classifier;
+ this.directory = directory;
+ this.packaging = packaging;
+ this.includesDependencies = includesDependencies;
+ this.language = language;
+ this.addedToClasspath = addedToClasspath;
}
- public DefaultArtifactHandler( String type )
+ public String getType()
{
- this.type = type;
+ return type;
}
+ @Override
public String getExtension()
{
if ( extension == null )
{
- extension = type;
+ return type;
}
return extension;
}
- public void setExtension( String extension )
+ public void setExtension( final String extension )
{
this.extension = extension;
}
- public String getType()
+ @Override
+ public String getClassifier()
{
- return type;
+ return classifier;
}
- public String getClassifier()
+ public void setClassifier( final String classifier )
{
- return classifier;
+ this.classifier = classifier;
}
+ @Override
public String getDirectory()
{
if ( directory == null )
{
- directory = getPackaging() + "s";
+ return getPackaging() + "s";
}
return directory;
}
+ public void setDirectory( final String directory )
+ {
+ this.directory = directory;
+ }
+
+ @Override
public String getPackaging()
{
if ( packaging == null )
{
- packaging = type;
+ return type;
}
return packaging;
}
+ public void setPackaging( final String packaging )
+ {
+ this.packaging = packaging;
+ }
+
+ @Override
public boolean isIncludesDependencies()
{
return includesDependencies;
}
- public void setIncludesDependencies( boolean includesDependencies )
+ public void setIncludesDependencies( final boolean includesDependencies )
{
this.includesDependencies = includesDependencies;
}
+ @Override
public String getLanguage()
{
if ( language == null )
{
- language = "none";
+ return "none";
}
return language;
}
- public void setLanguage( String language )
+ public void setLanguage( final String language )
{
this.language = language;
}
+ @Override
public boolean isAddedToClasspath()
{
return addedToClasspath;
}
- public void setAddedToClasspath( boolean addedToClasspath )
+ public void setAddedToClasspath( final boolean addedToClasspath )
{
this.addedToClasspath = addedToClasspath;
}
-
}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java
new file mode 100644
index 0000000..57a582d
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "ear" )
+@Singleton
+public class EarArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public EarArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "ear",
+ null,
+ null,
+ null,
+ null,
+ true,
+ "java",
+ false
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java
new file mode 100644
index 0000000..fb5bfaa
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "ejb" )
+@Singleton
+public class EjbArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public EjbArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "ejb",
+ "jar",
+ null,
+ null,
+ null,
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java
new file mode 100644
index 0000000..86a224d
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "ejb-client" )
+@Singleton
+public class EjbClientArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public EjbClientArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "ejb-client",
+ "jar",
+ "client",
+ null,
+ "ejb",
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java
new file mode 100644
index 0000000..ed69ccb
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "jar" )
+@Singleton
+public class JarArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public JarArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "jar",
+ null,
+ null,
+ null,
+ null,
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java
new file mode 100644
index 0000000..8d0d034
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "java-source" )
+@Singleton
+public class JavaSourceArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public JavaSourceArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "java-source",
+ "jar",
+ "sources",
+ null,
+ null,
+ false,
+ "java",
+ false
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java
new file mode 100644
index 0000000..82f7fce
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "javadoc" )
+@Singleton
+public class JavadocArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public JavadocArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "javadoc",
+ "jar",
+ "javadoc",
+ null,
+ null,
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java
new file mode 100644
index 0000000..4b1a89f
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "maven-plugin" )
+@Singleton
+public class MavenPluginArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public MavenPluginArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "maven-plugin",
+ "jar",
+ null,
+ null,
+ null,
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java
new file mode 100644
index 0000000..92bd813
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "pom" )
+@Singleton
+public class PomArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public PomArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "pom",
+ null,
+ null,
+ null,
+ null,
+ false,
+ "none",
+ false
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java
new file mode 100644
index 0000000..a8b8cac
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "rar" )
+@Singleton
+public class RarArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public RarArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "rar",
+ null,
+ null,
+ null,
+ null,
+ true,
+ "java",
+ false
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java
new file mode 100644
index 0000000..1aa1b93
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "test-jar" )
+@Singleton
+public class TestJarArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public TestJarArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "test-jar",
+ "jar",
+ "tests",
+ null,
+ "jar",
+ false,
+ "java",
+ true
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java
new file mode 100644
index 0000000..3b119d9
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java
@@ -0,0 +1,57 @@
+package org.apache.maven.artifact.handler.providers;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Named( "war" )
+@Singleton
+public class WarArtifactHandlerProvider
+ implements Provider<ArtifactHandler>
+{
+ private final ArtifactHandler artifactHandler;
+
+ @Inject
+ public WarArtifactHandlerProvider()
+ {
+ this.artifactHandler = new DefaultArtifactHandler(
+ "war",
+ null,
+ null,
+ null,
+ null,
+ true,
+ "java",
+ false
+ );
+ }
+
+ @Override
+ public ArtifactHandler get()
+ {
+ return artifactHandler;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/PluginArtifact.java b/maven-core/src/main/java/org/apache/maven/project/artifact/PluginArtifact.java
index 3b4e2ef..c6bf9b8 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/PluginArtifact.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/PluginArtifact.java
@@ -56,6 +56,7 @@ public class PluginArtifact
return Collections.emptyList();
}
+ // TODO: this is duplicate of MavenPluginArtifactHandlerProvider provided one
static class PluginArtifactHandler
implements ArtifactHandler
{
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
index 46e56dc..af63596 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
@@ -65,6 +65,7 @@ public class ProjectArtifact
}
+ // TODO: this is duplicate of PomArtifactHandlerProvider provided one
static class PomArtifactHandler
implements ArtifactHandler
{
diff --git a/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml b/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml
deleted file mode 100644
index 2f26ce2..0000000
--- a/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<!--
-
-Artifact handlers are required by the dependency resolution mechanism.
-
--->
-
-<component-set>
- <components>
- <!--
- | POM
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>pom</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>pom</type>
- </configuration>
- </component>
-
- <!--
- | JAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>jar</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>jar</type>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | EJB
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>ejb</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>ejb</type>
- <extension>jar</extension>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>ejb-client</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>ejb-client</type>
- <extension>jar</extension>
- <packaging>ejb</packaging>
- <classifier>client</classifier>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | TEST JAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>test-jar</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <classifier>tests</classifier>
- <extension>jar</extension>
- <type>test-jar</type>
- <packaging>jar</packaging>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | MAVEN PLUGIN
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>maven-plugin</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>maven-plugin</type>
- <extension>jar</extension>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | SOURCE JAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>java-source</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <classifier>sources</classifier>
- <type>java-source</type>
- <extension>jar</extension>
- <language>java</language>
- <addedToClasspath>false</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | JAVADOC JAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>javadoc</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <classifier>javadoc</classifier>
- <type>javadoc</type>
- <extension>jar</extension>
- <language>java</language>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | WAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>war</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>war</type>
- <includesDependencies>true</includesDependencies>
- <language>java</language>
- <addedToClasspath>false</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | EAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>ear</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>ear</type>
- <includesDependencies>true</includesDependencies>
- <language>java</language>
- <addedToClasspath>false</addedToClasspath>
- </configuration>
- </component>
-
- <!--
- | RAR
- |-->
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>rar</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>rar</type>
- <includesDependencies>true</includesDependencies>
- <language>java</language>
- <addedToClasspath>false</addedToClasspath>
- </configuration>
- </component>
-
- </components>
-</component-set>
diff --git a/maven-core/src/test/java/org/apache/maven/plugin/internal/MavenPluginValidatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/internal/MavenPluginValidatorTest.java
index cd96409..8728096 100644
--- a/maven-core/src/test/java/org/apache/maven/plugin/internal/MavenPluginValidatorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/plugin/internal/MavenPluginValidatorTest.java
@@ -52,7 +52,7 @@ public class MavenPluginValidatorTest extends AbstractCoreMavenComponentTestCase
public void testValidate()
{
Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
- "jar", null, new DefaultArtifactHandler() );
+ "jar", null, new DefaultArtifactHandler( "ignore" ) );
PluginDescriptor descriptor = new PluginDescriptor();
descriptor.setGroupId( "org.apache.maven.its.plugins" );
descriptor.setArtifactId( "maven-it-plugin" );
@@ -66,7 +66,7 @@ public class MavenPluginValidatorTest extends AbstractCoreMavenComponentTestCase
public void testInvalidGroupId()
{
Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
- "jar", null, new DefaultArtifactHandler() );
+ "jar", null, new DefaultArtifactHandler( "ignore" ) );
PluginDescriptor descriptor = new PluginDescriptor();
descriptor.setGroupId( "org.apache.maven.its.plugins.invalid" );
descriptor.setArtifactId( "maven-it-plugin" );
@@ -80,7 +80,7 @@ public class MavenPluginValidatorTest extends AbstractCoreMavenComponentTestCase
public void testInvalidArtifactId()
{
Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
- "jar", null, new DefaultArtifactHandler() );
+ "jar", null, new DefaultArtifactHandler( "ignore" ) );
PluginDescriptor descriptor = new PluginDescriptor();
descriptor.setGroupId( "org.apache.maven.its.plugins" );
descriptor.setArtifactId( "maven-it-plugin.invalid" );
@@ -94,7 +94,7 @@ public class MavenPluginValidatorTest extends AbstractCoreMavenComponentTestCase
public void testInvalidVersion()
{
Artifact plugin = new DefaultArtifact( "org.apache.maven.its.plugins", "maven-it-plugin", "0.1", "compile",
- "jar", null, new DefaultArtifactHandler() );
+ "jar", null, new DefaultArtifactHandler( "ignore" ) );
PluginDescriptor descriptor = new PluginDescriptor();
descriptor.setGroupId( "org.apache.maven.its.plugins" );
descriptor.setArtifactId( "maven-it-plugin" );