maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1689286 - in /maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve: ./ transform/
Date Sun, 05 Jul 2015 20:14:01 GMT
Author: rfscholte
Date: Sun Jul  5 20:14:01 2015
New Revision: 1689286

URL: http://svn.apache.org/r1689286
Log:
Add AbstractFilter for custom filters

Added:
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
Modified:
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
    maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java

Added: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java?rev=1689286&view=auto
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
(added)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
Sun Jul  5 20:14:01 2015
@@ -0,0 +1,40 @@
+package org.apache.maven.shared.artifact.filter.resolve;
+
+/*
+ * 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.util.List;
+
+/**
+ * Abstract filter for custom implementations
+ * 
+ * @author Robert Scholte
+ * @since 3.0
+ */
+public abstract class AbstractFilter implements TransformableFilter
+{
+
+    @Override
+    public final <T> T transform( FilterTransformer<T> transformer )
+    {
+        return transformer.transform( this );
+    }
+
+    public abstract boolean accept( Node node, List<Node> parents );
+}

Modified: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java?rev=1689286&r1=1689285&r2=1689286&view=diff
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
(original)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
Sun Jul  5 20:14:01 2015
@@ -77,4 +77,12 @@ public interface FilterTransformer<T>
      * @return the transformed filter, never {@code null}
      */
     T transform( PatternInclusionsFilter patternInclusionsFilter );
+
+    /**
+     * Transform a custom filter to T specific implementation 
+     * 
+     * @param abstractFilter the filter
+     * @return the transformed filter, never {@code null}
+     */
+    T transform( AbstractFilter abstractFilter );
 }

Added: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java?rev=1689286&view=auto
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
(added)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
Sun Jul  5 20:14:01 2015
@@ -0,0 +1,26 @@
+package org.apache.maven.shared.artifact.filter.resolve;
+
+/*
+ * 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.
+ */
+
+public interface Node
+{
+    org.apache.maven.model.Dependency getDependency();
+
+}

Modified: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java?rev=1689286&r1=1689285&r2=1689286&view=diff
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
(original)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
Sun Jul  5 20:14:01 2015
@@ -21,7 +21,9 @@ package org.apache.maven.shared.artifact
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
+import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter;
 import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
 import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter;
 import org.apache.maven.shared.artifact.filter.resolve.FilterTransformer;
@@ -31,6 +33,7 @@ import org.apache.maven.shared.artifact.
 import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
 import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
 import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
 import org.eclipse.aether.util.filter.AndDependencyFilter;
 import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
 import org.eclipse.aether.util.filter.OrDependencyFilter;
@@ -92,4 +95,17 @@ public class EclipseAetherFilterTransfor
     {
         return new PatternInclusionsDependencyFilter( filter.getIncludes() );
     }
+    
+    @Override
+    public DependencyFilter transform( final AbstractFilter filter )
+    {
+        return new DependencyFilter()
+        {
+            @Override
+            public boolean accept( DependencyNode node, List<DependencyNode> parents
)
+            {
+                return filter.accept( new EclipseAetherNode( node ), null );
+            }
+        }; 
+    }
 }

Added: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java?rev=1689286&view=auto
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
(added)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
Sun Jul  5 20:14:01 2015
@@ -0,0 +1,57 @@
+package org.apache.maven.shared.artifact.filter.resolve.transform;
+
+/*
+ * 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.shared.artifact.filter.resolve.Node;
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+public class EclipseAetherNode implements Node
+{
+
+    private final DependencyNode node;
+
+    public EclipseAetherNode( DependencyNode node )
+    {
+        this.node = node;
+    }
+
+    @Override
+    public org.apache.maven.model.Dependency getDependency()
+    {
+        if ( node.getDependency() == null )
+        {
+            return null;
+        }
+
+        Dependency nodeDependency = node.getDependency();
+
+        org.apache.maven.model.Dependency mavenDependency = new org.apache.maven.model.Dependency();
+        mavenDependency.setGroupId( nodeDependency.getArtifact().getGroupId() );
+        mavenDependency.setArtifactId( nodeDependency.getArtifact().getArtifactId() );
+        mavenDependency.setVersion( nodeDependency.getArtifact().getVersion() );
+        mavenDependency.setClassifier( nodeDependency.getArtifact().getClassifier() );
+        mavenDependency.setType( nodeDependency.getArtifact().getProperty( ArtifactProperties.TYPE,
null ) );
+
+        return mavenDependency;
+    }
+     
+}

Modified: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java?rev=1689286&r1=1689285&r2=1689286&view=diff
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
(original)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
Sun Jul  5 20:14:01 2015
@@ -21,7 +21,9 @@ package org.apache.maven.shared.artifact
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
+import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter;
 import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
 import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter;
 import org.apache.maven.shared.artifact.filter.resolve.FilterTransformer;
@@ -31,6 +33,7 @@ import org.apache.maven.shared.artifact.
 import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
 import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
 import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.graph.DependencyNode;
 import org.sonatype.aether.util.filter.AndDependencyFilter;
 import org.sonatype.aether.util.filter.ExclusionsDependencyFilter;
 import org.sonatype.aether.util.filter.OrDependencyFilter;
@@ -92,4 +95,17 @@ public class SonatypeAetherFilterTransfo
     {
         return new PatternInclusionsDependencyFilter( filter.getIncludes() );
     }
+    
+    @Override
+    public DependencyFilter transform( final AbstractFilter filter )
+    {
+        return new DependencyFilter()
+        {
+            @Override
+            public boolean accept( DependencyNode node, List<DependencyNode> parents
)
+            {
+                return filter.accept( new SonatypeAetherNode( node ), null );
+            }
+        };
+    }
 }

Added: maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java?rev=1689286&view=auto
==============================================================================
--- maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
(added)
+++ maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
Sun Jul  5 20:14:01 2015
@@ -0,0 +1,58 @@
+package org.apache.maven.shared.artifact.filter.resolve.transform;
+
+/*
+ * 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.shared.artifact.filter.resolve.Node;
+import org.sonatype.aether.graph.Dependency;
+import org.sonatype.aether.graph.DependencyNode;
+import org.sonatype.aether.util.artifact.ArtifactProperties;
+
+public class SonatypeAetherNode implements Node
+{
+
+    private final DependencyNode node;
+
+    public SonatypeAetherNode( DependencyNode node )
+    {
+        this.node = node;
+    }
+
+
+    @Override
+    public org.apache.maven.model.Dependency getDependency()
+    {
+        if ( node.getDependency() == null )
+        {
+            return null;
+        }
+        
+        Dependency nodeDependency = node.getDependency();
+
+        org.apache.maven.model.Dependency mavenDependency = new org.apache.maven.model.Dependency();
+        mavenDependency.setGroupId( nodeDependency.getArtifact().getGroupId() );
+        mavenDependency.setArtifactId( nodeDependency.getArtifact().getArtifactId() );
+        mavenDependency.setVersion( nodeDependency.getArtifact().getVersion() );
+        mavenDependency.setClassifier( nodeDependency.getArtifact().getClassifier() );
+        mavenDependency.setType( nodeDependency.getArtifact().getProperty( ArtifactProperties.TYPE,
null ) );
+
+        return mavenDependency;
+    }
+     
+}



Mime
View raw message