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/24 16:01:54 UTC

[maven-plugin-testing] branch mvn4 updated: Switch a few core plugins to the new api

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch mvn4
in repository https://gitbox.apache.org/repos/asf/maven-plugin-testing.git


The following commit(s) were added to refs/heads/mvn4 by this push:
     new 0e53b75  Switch a few core plugins to the new api
0e53b75 is described below

commit 0e53b75ac932d486b3fcdbf1b51d33fbfa4be172
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Feb 24 17:00:56 2022 +0100

    Switch a few core plugins to the new api
---
 .../testing/stubs/StubArtifactRepository.java      | 289 +++++++++++++++++++++
 .../plugin/testing/ExpressionEvaluatorMojo.java    |   3 +-
 .../maven/plugin/testing/ParametersMojo.java       |   3 +-
 3 files changed, 291 insertions(+), 4 deletions(-)

diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java
new file mode 100644
index 0000000..3a5d7cb
--- /dev/null
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java
@@ -0,0 +1,289 @@
+package org.apache.maven.plugin.testing.stubs;
+
+/*
+ * 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.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.Authentication;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.repository.Proxy;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class StubArtifactRepository
+    implements ArtifactRepository
+{
+    private String baseDir = null;
+
+    /**
+     * Default constructor
+     *
+     * @param dir the basedir
+     */
+    public StubArtifactRepository( String dir )
+    {
+        baseDir = dir;
+    }
+
+    /**
+     * @return the <code>artifactId</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#pathOf(org.apache.maven.artifact.Artifact)
+     */
+    @Override
+    public String pathOf( Artifact artifact )
+    {
+        return artifact.getId();
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfRemoteRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata)
+     */
+    @Override
+    public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
+    {
+        return null;
+    }
+
+    /**
+     * @return the filename of this metadata on the local repository.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfLocalRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata, org.apache.maven.artifact.repository.ArtifactRepository)
+     */
+    @Override
+    public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
+    {
+        return metadata.getLocalFilename( repository );
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getUrl()
+     */
+    @Override
+    public String getUrl()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>basedir</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getBasedir()
+     */
+    @Override
+    public String getBasedir()
+    {
+        return baseDir;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getProtocol()
+     */
+    @Override
+    public String getProtocol()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getId()
+     */
+    @Override
+    public String getId()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getSnapshots()
+     */
+    @Override
+    public ArtifactRepositoryPolicy getSnapshots()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getReleases()
+     */
+    @Override
+    public ArtifactRepositoryPolicy getReleases()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getLayout()
+     */
+    @Override
+    public ArtifactRepositoryLayout getLayout()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>null</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#getKey()
+     */
+    @Override
+    public String getKey()
+    {
+        return null;
+    }
+
+    /**
+     * @return <code>false</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#isUniqueVersion()
+     */
+    @Override
+    public boolean isUniqueVersion()
+    {
+        return false;
+    }
+
+    /**
+     * By default, do nothing.
+     *
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#setBlacklisted(boolean)
+     */
+    @Override
+    public void setBlacklisted( boolean blackListed )
+    {
+        // nop
+    }
+
+    /**
+     * @return <code>false</code>.
+     * @see org.apache.maven.artifact.repository.ArtifactRepository#isBlacklisted()
+     */
+    @Override
+    public boolean isBlacklisted()
+    {
+        return false;
+    }
+
+    @Override
+    public Artifact find( Artifact artifact )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Authentication getAuthentication()
+    {
+        return null;
+    }
+
+    @Override
+    public Proxy getProxy()
+    {
+        return null;
+    }
+
+    @Override
+    public void setAuthentication( Authentication authentication )
+    {
+
+    }
+
+    @Override
+    public void setId( String id )
+    {
+
+    }
+
+    @Override
+    public void setLayout( ArtifactRepositoryLayout layout )
+    {
+
+    }
+
+    @Override
+    public void setProxy( Proxy proxy )
+    {
+
+    }
+
+    @Override
+    public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy )
+    {
+
+    }
+
+    @Override
+    public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy )
+    {
+
+    }
+
+    @Override
+    public void setUrl( String url )
+    {
+
+    }
+
+    @Override
+    public List<String> findVersions( Artifact artifact )
+    {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public boolean isProjectAware()
+    {
+        return false;
+    }
+
+    @Override
+    public List<ArtifactRepository> getMirroredRepositories()
+    {
+        return new ArrayList<>( 0 );
+    }
+
+    @Override
+    public void setMirroredRepositories( List<ArtifactRepository> artifactRepositories )
+    {
+        // no op
+    }
+
+    @Override
+    public boolean isBlocked()
+    {
+        return false;
+    }
+
+    @Override
+    public void setBlocked( boolean blocked )
+    {
+        // no op
+    }
+}
diff --git a/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ExpressionEvaluatorMojo.java b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ExpressionEvaluatorMojo.java
index 2d4faa0..5f1f802 100644
--- a/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ExpressionEvaluatorMojo.java
+++ b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ExpressionEvaluatorMojo.java
@@ -22,7 +22,6 @@ package org.apache.maven.plugin.testing;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -40,7 +39,7 @@ public class ExpressionEvaluatorMojo
     /** {@inheritDoc} */
     @Override
     public void execute()
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
         if ( StringUtils.isEmpty( basedir ) )
         {
diff --git a/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojo.java b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojo.java
index 13d3029..d1825c4 100644
--- a/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojo.java
+++ b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/ParametersMojo.java
@@ -21,7 +21,6 @@ package org.apache.maven.plugin.testing;
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 
 public class ParametersMojo
     extends AbstractMojo
@@ -36,7 +35,7 @@ public class ParametersMojo
 
     @Override
     public void execute()
-        throws MojoExecutionException, MojoFailureException
+        throws MojoExecutionException
     {
     }
 }