http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverser.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverser.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverser.java deleted file mode 100644 index fb08b3b..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverser.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; - -/** - * A dependency traverser that combines zero or more other traversers using a logical {@code AND}. The resulting - * traverser enables processing of child dependencies if and only if all constituent traversers request traversal. - */ -public final class AndDependencyTraverser - implements DependencyTraverser -{ - - private final Set<? extends DependencyTraverser> traversers; - - private int hashCode; - - /** - * Creates a new traverser from the specified traversers. Prefer - * {@link #newInstance(DependencyTraverser, DependencyTraverser)} if any of the input traversers might be - * {@code null}. - * - * @param traversers The traversers to combine, may be {@code null} but must not contain {@code null} elements. - */ - public AndDependencyTraverser( DependencyTraverser... traversers ) - { - if ( traversers != null && traversers.length > 0 ) - { - this.traversers = new LinkedHashSet<DependencyTraverser>( Arrays.asList( traversers ) ); - } - else - { - this.traversers = Collections.emptySet(); - } - } - - /** - * Creates a new traverser from the specified traversers. - * - * @param traversers The traversers to combine, may be {@code null} but must not contain {@code null} elements. - */ - public AndDependencyTraverser( Collection<? extends DependencyTraverser> traversers ) - { - if ( traversers != null && !traversers.isEmpty() ) - { - this.traversers = new LinkedHashSet<DependencyTraverser>( traversers ); - } - else - { - this.traversers = Collections.emptySet(); - } - } - - private AndDependencyTraverser( Set<DependencyTraverser> traversers ) - { - if ( traversers != null && !traversers.isEmpty() ) - { - this.traversers = traversers; - } - else - { - this.traversers = Collections.emptySet(); - } - } - - /** - * Creates a new traverser from the specified traversers. - * - * @param traverser1 The first traverser to combine, may be {@code null}. - * @param traverser2 The second traverser to combine, may be {@code null}. - * @return The combined traverser or {@code null} if both traversers were {@code null}. - */ - public static DependencyTraverser newInstance( DependencyTraverser traverser1, DependencyTraverser traverser2 ) - { - if ( traverser1 == null ) - { - return traverser2; - } - else if ( traverser2 == null || traverser2.equals( traverser1 ) ) - { - return traverser1; - } - return new AndDependencyTraverser( traverser1, traverser2 ); - } - - public boolean traverseDependency( Dependency dependency ) - { - for ( DependencyTraverser traverser : traversers ) - { - if ( !traverser.traverseDependency( dependency ) ) - { - return false; - } - } - return true; - } - - public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) - { - int seen = 0; - Set<DependencyTraverser> childTraversers = null; - - for ( DependencyTraverser traverser : traversers ) - { - DependencyTraverser childTraverser = traverser.deriveChildTraverser( context ); - if ( childTraversers != null ) - { - if ( childTraverser != null ) - { - childTraversers.add( childTraverser ); - } - } - else if ( traverser != childTraverser ) - { - childTraversers = new LinkedHashSet<DependencyTraverser>(); - if ( seen > 0 ) - { - for ( DependencyTraverser s : traversers ) - { - if ( childTraversers.size() >= seen ) - { - break; - } - childTraversers.add( s ); - } - } - if ( childTraverser != null ) - { - childTraversers.add( childTraverser ); - } - } - else - { - seen++; - } - } - - if ( childTraversers == null ) - { - return this; - } - if ( childTraversers.size() <= 1 ) - { - if ( childTraversers.isEmpty() ) - { - return null; - } - return childTraversers.iterator().next(); - } - return new AndDependencyTraverser( childTraversers ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - AndDependencyTraverser that = (AndDependencyTraverser) obj; - return traversers.equals( that.traversers ); - } - - @Override - public int hashCode() - { - if ( hashCode == 0 ) - { - int hash = 17; - hash = hash * 31 + traversers.hashCode(); - hashCode = hash; - } - return hashCode; - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverser.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverser.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverser.java deleted file mode 100644 index 40ce616..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverser.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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.eclipse.aether.artifact.ArtifactProperties; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; - -/** - * A dependency traverser that excludes the dependencies of fat artifacts from the traversal. Fat artifacts are - * artifacts that have the property {@link org.eclipse.aether.artifact.ArtifactProperties#INCLUDES_DEPENDENCIES} set to - * {@code true}. - * - * @see org.eclipse.aether.artifact.Artifact#getProperties() - */ -public final class FatArtifactTraverser - implements DependencyTraverser -{ - - /** - * Creates a new instance of this dependency traverser. - */ - public FatArtifactTraverser() - { - } - - public boolean traverseDependency( Dependency dependency ) - { - String prop = dependency.getArtifact().getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ); - return !Boolean.parseBoolean( prop ); - } - - public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) - { - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - return true; - } - - @Override - public int hashCode() - { - return getClass().hashCode(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverser.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverser.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverser.java deleted file mode 100644 index 5e2a703..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverser.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; - -/** - * A dependency traverser which always or never traverses children. - */ -public final class StaticDependencyTraverser - implements DependencyTraverser -{ - - private final boolean traverse; - - /** - * Creates a new traverser with the specified traversal behavior. - * - * @param traverse {@code true} to traverse all dependencies, {@code false} to never traverse. - */ - public StaticDependencyTraverser( boolean traverse ) - { - this.traverse = traverse; - } - - public boolean traverseDependency( Dependency dependency ) - { - return traverse; - } - - public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) - { - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - StaticDependencyTraverser that = (StaticDependencyTraverser) obj; - return traverse == that.traverse; - } - - @Override - public int hashCode() - { - int hash = getClass().hashCode(); - hash = hash * 31 + ( traverse ? 1 : 0 ); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/package-info.java deleted file mode 100644 index a1b71e0..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/traverser/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Various dependency traversers for building a dependency graph. - */ -package org.eclipse.aether.util.graph.traverser; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ChainedVersionFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ChainedVersionFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ChainedVersionFilter.java deleted file mode 100644 index 7d13555..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ChainedVersionFilter.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.eclipse.aether.util.graph.version; - -/* - * 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.Arrays; -import java.util.Collection; - -import org.eclipse.aether.RepositoryException; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.VersionFilter; - -/** - * A version filter that combines multiple version filters into a chain where each filter gets invoked one after the - * other, thereby accumulating their filtering effects. - */ -public final class ChainedVersionFilter - implements VersionFilter -{ - - private final VersionFilter[] filters; - - private int hashCode; - - /** - * Chains the specified version filters. - * - * @param filter1 The first version filter, may be {@code null}. - * @param filter2 The second version filter, may be {@code null}. - * @return The chained version filter or {@code null} if both input filters are {@code null}. - */ - public static VersionFilter newInstance( VersionFilter filter1, VersionFilter filter2 ) - { - if ( filter1 == null ) - { - return filter2; - } - if ( filter2 == null ) - { - return filter1; - } - return new ChainedVersionFilter( new VersionFilter[] { filter1, filter2 } ); - } - - /** - * Chains the specified version filters. - * - * @param filters The version filters to chain, must not be {@code null} or contain {@code null}. - * @return The chained version filter or {@code null} if the input array is empty. - */ - public static VersionFilter newInstance( VersionFilter... filters ) - { - if ( filters.length <= 1 ) - { - if ( filters.length <= 0 ) - { - return null; - } - return filters[0]; - } - return new ChainedVersionFilter( filters.clone() ); - } - - /** - * Chains the specified version filters. - * - * @param filters The version filters to chain, must not be {@code null} or contain {@code null}. - * @return The chained version filter or {@code null} if the input collection is empty. - */ - public static VersionFilter newInstance( Collection<? extends VersionFilter> filters ) - { - if ( filters.size() <= 1 ) - { - if ( filters.isEmpty() ) - { - return null; - } - return filters.iterator().next(); - } - return new ChainedVersionFilter( filters.toArray( new VersionFilter[filters.size()] ) ); - } - - private ChainedVersionFilter( VersionFilter[] filters ) - { - this.filters = filters; - } - - public void filterVersions( VersionFilterContext context ) - throws RepositoryException - { - for ( int i = 0, n = filters.length; i < n && context.getCount() > 0; i++ ) - { - filters[i].filterVersions( context ); - } - } - - public VersionFilter deriveChildFilter( DependencyCollectionContext context ) - { - VersionFilter[] children = null; - int removed = 0; - for ( int i = 0, n = filters.length; i < n; i++ ) - { - VersionFilter child = filters[i].deriveChildFilter( context ); - if ( children != null ) - { - children[i - removed] = child; - } - else if ( child != filters[i] ) - { - children = new VersionFilter[filters.length]; - System.arraycopy( filters, 0, children, 0, i ); - children[i - removed] = child; - } - if ( child == null ) - { - removed++; - } - } - if ( children == null ) - { - return this; - } - if ( removed > 0 ) - { - int count = filters.length - removed; - if ( count <= 0 ) - { - return null; - } - if ( count == 1 ) - { - return children[0]; - } - VersionFilter[] tmp = new VersionFilter[count]; - System.arraycopy( children, 0, tmp, 0, count ); - children = tmp; - } - return new ChainedVersionFilter( children ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - ChainedVersionFilter that = (ChainedVersionFilter) obj; - return Arrays.equals( filters, that.filters ); - } - - @Override - public int hashCode() - { - if ( hashCode == 0 ) - { - int hash = getClass().hashCode(); - hash = hash * 31 + Arrays.hashCode( filters ); - hashCode = hash; - } - return hashCode; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ContextualSnapshotVersionFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ContextualSnapshotVersionFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ContextualSnapshotVersionFilter.java deleted file mode 100644 index 569bf4c..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/ContextualSnapshotVersionFilter.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.eclipse.aether.util.graph.version; - -/* - * 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.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.VersionFilter; -import org.eclipse.aether.util.ConfigUtils; - -/** - * A version filter that blocks "*-SNAPSHOT" versions if the - * {@link org.eclipse.aether.collection.CollectRequest#getRootArtifact() root artifact} of the dependency graph is not a - * snapshot. Alternatively, this filter can be forced to always ban snapshot versions by setting the boolean - * {@link RepositorySystemSession#getConfigProperties() configuration property} {@link #CONFIG_PROP_ENABLE} to - * {@code true}. - */ -public final class ContextualSnapshotVersionFilter - implements VersionFilter -{ - - /** - * The key in the repository session's {@link RepositorySystemSession#getConfigProperties() configuration - * properties} used to store a {@link Boolean} flag whether this filter should be forced to ban snapshots. By - * default, snapshots are only filtered if the root artifact is not a snapshot. - */ - public static final String CONFIG_PROP_ENABLE = "aether.snapshotFilter"; - - private final SnapshotVersionFilter filter; - - /** - * Creates a new instance of this version filter. - */ - public ContextualSnapshotVersionFilter() - { - filter = new SnapshotVersionFilter(); - } - - private boolean isEnabled( RepositorySystemSession session ) - { - return ConfigUtils.getBoolean( session, false, CONFIG_PROP_ENABLE ); - } - - public void filterVersions( VersionFilterContext context ) - { - if ( isEnabled( context.getSession() ) ) - { - filter.filterVersions( context ); - } - } - - public VersionFilter deriveChildFilter( DependencyCollectionContext context ) - { - if ( !isEnabled( context.getSession() ) ) - { - Artifact artifact = context.getArtifact(); - if ( artifact == null ) - { - // no root artifact to test, allow snapshots and recheck once we reach the direct dependencies - return this; - } - if ( artifact.isSnapshot() ) - { - // root is a snapshot, allow snapshots all the way down - return null; - } - } - // artifact is a non-snapshot or filter explicitly enabled, block snapshots all the way down - return filter; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - return true; - } - - @Override - public int hashCode() - { - return getClass().hashCode(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/version/HighestVersionFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/HighestVersionFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/version/HighestVersionFilter.java deleted file mode 100644 index 902e08d..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/HighestVersionFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.eclipse.aether.util.graph.version; - -/* - * 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.Iterator; - -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.VersionFilter; -import org.eclipse.aether.version.Version; - -/** - * A version filter that excludes any version except the highest one. - */ -public final class HighestVersionFilter - implements VersionFilter -{ - - /** - * Creates a new instance of this version filter. - */ - public HighestVersionFilter() - { - } - - public void filterVersions( VersionFilterContext context ) - { - Iterator<Version> it = context.iterator(); - for ( boolean hasNext = it.hasNext(); hasNext; ) - { - it.next(); - if ( hasNext = it.hasNext() ) - { - it.remove(); - } - } - } - - public VersionFilter deriveChildFilter( DependencyCollectionContext context ) - { - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - return true; - } - - @Override - public int hashCode() - { - return getClass().hashCode(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/version/SnapshotVersionFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/SnapshotVersionFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/version/SnapshotVersionFilter.java deleted file mode 100644 index 6af7cf5..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/SnapshotVersionFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.eclipse.aether.util.graph.version; - -/* - * 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.Iterator; - -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.VersionFilter; -import org.eclipse.aether.version.Version; - -/** - * A version filter that (unconditionally) blocks "*-SNAPSHOT" versions. For practical purposes, - * {@link ContextualSnapshotVersionFilter} is usually more desirable. - */ -public final class SnapshotVersionFilter - implements VersionFilter -{ - - /** - * Creates a new instance of this version filter. - */ - public SnapshotVersionFilter() - { - } - - public void filterVersions( VersionFilterContext context ) - { - for ( Iterator<Version> it = context.iterator(); it.hasNext(); ) - { - String version = it.next().toString(); - if ( version.endsWith( "SNAPSHOT" ) ) - { - it.remove(); - } - } - } - - public VersionFilter deriveChildFilter( DependencyCollectionContext context ) - { - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - return true; - } - - @Override - public int hashCode() - { - return getClass().hashCode(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/version/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/version/package-info.java deleted file mode 100644 index a9f4649..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/version/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Various version filters for building a dependency graph. - */ -package org.eclipse.aether.util.graph.version; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/AbstractDepthFirstNodeListGenerator.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/AbstractDepthFirstNodeListGenerator.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/AbstractDepthFirstNodeListGenerator.java deleted file mode 100644 index 70fc7d4..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/AbstractDepthFirstNodeListGenerator.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; - -import java.io.File; -import java.util.ArrayList; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Abstract base class for depth first dependency tree traversers. Subclasses of this visitor will visit each node - * exactly once regardless how many paths within the dependency graph lead to the node such that the resulting node - * sequence is free of duplicates. - * <p> - * Actual vertex ordering (preorder, inorder, postorder) needs to be defined by subclasses through appropriate - * implementations for {@link #visitEnter(org.eclipse.aether.graph.DependencyNode)} and - * {@link #visitLeave(org.eclipse.aether.graph.DependencyNode)} - */ -abstract class AbstractDepthFirstNodeListGenerator - implements DependencyVisitor -{ - - private final Map<DependencyNode, Object> visitedNodes; - - protected final List<DependencyNode> nodes; - - public AbstractDepthFirstNodeListGenerator() - { - nodes = new ArrayList<DependencyNode>( 128 ); - visitedNodes = new IdentityHashMap<DependencyNode, Object>( 512 ); - } - - /** - * Gets the list of dependency nodes that was generated during the graph traversal. - * - * @return The list of dependency nodes, never {@code null}. - */ - public List<DependencyNode> getNodes() - { - return nodes; - } - - /** - * Gets the dependencies seen during the graph traversal. - * - * @param includeUnresolved Whether unresolved dependencies shall be included in the result or not. - * @return The list of dependencies, never {@code null}. - */ - public List<Dependency> getDependencies( boolean includeUnresolved ) - { - List<Dependency> dependencies = new ArrayList<Dependency>( getNodes().size() ); - - for ( DependencyNode node : getNodes() ) - { - Dependency dependency = node.getDependency(); - if ( dependency != null ) - { - if ( includeUnresolved || dependency.getArtifact().getFile() != null ) - { - dependencies.add( dependency ); - } - } - } - - return dependencies; - } - - /** - * Gets the artifacts associated with the list of dependency nodes generated during the graph traversal. - * - * @param includeUnresolved Whether unresolved artifacts shall be included in the result or not. - * @return The list of artifacts, never {@code null}. - */ - public List<Artifact> getArtifacts( boolean includeUnresolved ) - { - List<Artifact> artifacts = new ArrayList<Artifact>( getNodes().size() ); - - for ( DependencyNode node : getNodes() ) - { - if ( node.getDependency() != null ) - { - Artifact artifact = node.getDependency().getArtifact(); - if ( includeUnresolved || artifact.getFile() != null ) - { - artifacts.add( artifact ); - } - } - } - - return artifacts; - } - - /** - * Gets the files of resolved artifacts seen during the graph traversal. - * - * @return The list of artifact files, never {@code null}. - */ - public List<File> getFiles() - { - List<File> files = new ArrayList<File>( getNodes().size() ); - - for ( DependencyNode node : getNodes() ) - { - if ( node.getDependency() != null ) - { - File file = node.getDependency().getArtifact().getFile(); - if ( file != null ) - { - files.add( file ); - } - } - } - - return files; - } - - /** - * Gets a class path by concatenating the artifact files of the visited dependency nodes. Nodes with unresolved - * artifacts are automatically skipped. - * - * @return The class path, using the platform-specific path separator, never {@code null}. - */ - public String getClassPath() - { - StringBuilder buffer = new StringBuilder( 1024 ); - - for ( Iterator<DependencyNode> it = getNodes().iterator(); it.hasNext(); ) - { - DependencyNode node = it.next(); - if ( node.getDependency() != null ) - { - Artifact artifact = node.getDependency().getArtifact(); - if ( artifact.getFile() != null ) - { - buffer.append( artifact.getFile().getAbsolutePath() ); - if ( it.hasNext() ) - { - buffer.append( File.pathSeparatorChar ); - } - } - } - } - - return buffer.toString(); - } - - /** - * Marks the specified node as being visited and determines whether the node has been visited before. - * - * @param node The node being visited, must not be {@code null}. - * @return {@code true} if the node has not been visited before, {@code false} if the node was already visited. - */ - protected boolean setVisited( DependencyNode node ) - { - return visitedNodes.put( node, Boolean.TRUE ) == null; - } - - public abstract boolean visitEnter( DependencyNode node ); - - public abstract boolean visitLeave( DependencyNode node ); - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/CloningDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/CloningDependencyVisitor.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/CloningDependencyVisitor.java deleted file mode 100644 index a39fc84..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/CloningDependencyVisitor.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.IdentityHashMap; -import java.util.Map; - -import org.eclipse.aether.graph.DefaultDependencyNode; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; - -/** - * A dependency visitor that constructs a clone of the visited dependency graph. If such a visitor is passed into a - * {@link FilteringDependencyVisitor}, a sub graph can be created. This class creates shallow clones of the visited - * dependency nodes (via {@link DefaultDependencyNode#DefaultDependencyNode(DependencyNode)}) but clients can create a - * subclass and override {@link #clone(DependencyNode)} to alter the clone process. - */ -public class CloningDependencyVisitor - implements DependencyVisitor -{ - - private final Map<DependencyNode, DependencyNode> clones; - - private final Stack<DependencyNode> parents; - - private DependencyNode root; - - /** - * Creates a new visitor that clones the visited nodes. - */ - public CloningDependencyVisitor() - { - parents = new Stack<DependencyNode>(); - clones = new IdentityHashMap<DependencyNode, DependencyNode>( 256 ); - } - - /** - * Gets the root node of the cloned dependency graph. - * - * @return The root node of the cloned dependency graph or {@code null}. - */ - public final DependencyNode getRootNode() - { - return root; - } - - /** - * Creates a clone of the specified node. - * - * @param node The node to clone, must not be {@code null}. - * @return The cloned node, never {@code null}. - */ - protected DependencyNode clone( DependencyNode node ) - { - DefaultDependencyNode clone = new DefaultDependencyNode( node ); - return clone; - } - - public final boolean visitEnter( DependencyNode node ) - { - boolean recurse = true; - - DependencyNode clone = clones.get( node ); - if ( clone == null ) - { - clone = clone( node ); - clones.put( node, clone ); - } - else - { - recurse = false; - } - - DependencyNode parent = parents.peek(); - - if ( parent == null ) - { - root = clone; - } - else - { - parent.getChildren().add( clone ); - } - - parents.push( clone ); - - return recurse; - } - - public final boolean visitLeave( DependencyNode node ) - { - parents.pop(); - - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java deleted file mode 100644 index 49f779c..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; - -/** - * A dependency visitor that delegates to another visitor if nodes match a filter. Note that in case of a mismatching - * node, the children of that node are still visisted and presented to the filter. - */ -public final class FilteringDependencyVisitor - implements DependencyVisitor -{ - - private final DependencyFilter filter; - - private final DependencyVisitor visitor; - - private final Stack<Boolean> accepts; - - private final Stack<DependencyNode> parents; - - /** - * Creates a new visitor that delegates traversal of nodes matching the given filter to the specified visitor. - * - * @param visitor The visitor to delegate to, must not be {@code null}. - * @param filter The filter to apply, may be {@code null} to not filter. - */ - public FilteringDependencyVisitor( DependencyVisitor visitor, DependencyFilter filter ) - { - if ( visitor == null ) - { - throw new IllegalArgumentException( "dependency visitor not specified" ); - } - this.visitor = visitor; - this.filter = filter; - this.accepts = new Stack<Boolean>(); - this.parents = new Stack<DependencyNode>(); - } - - /** - * Gets the visitor to which this visitor delegates to. - * - * @return The visitor being delegated to, never {@code null}. - */ - public DependencyVisitor getVisitor() - { - return visitor; - } - - /** - * Gets the filter being applied before delegation. - * - * @return The filter being applied or {@code null} if none. - */ - public DependencyFilter getFilter() - { - return filter; - } - - public boolean visitEnter( DependencyNode node ) - { - boolean accept = filter == null || filter.accept( node, parents ); - - accepts.push( accept ); - - parents.push( node ); - - if ( accept ) - { - return visitor.visitEnter( node ); - } - else - { - return true; - } - } - - public boolean visitLeave( DependencyNode node ) - { - parents.pop(); - - Boolean accept = accepts.pop(); - - if ( accept ) - { - return visitor.visitLeave( node ); - } - else - { - return true; - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java deleted file mode 100644 index d1814ed..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitor.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.ArrayList; -import java.util.Arrays; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; - -/** - * A dependency visitor that records all paths leading to nodes matching a certain filter criteria. - */ -public final class PathRecordingDependencyVisitor - implements DependencyVisitor -{ - - private final DependencyFilter filter; - - private final List<List<DependencyNode>> paths; - - private final Stack<DependencyNode> parents; - - private final Map<DependencyNode, Object> visited; - - private final boolean excludeChildrenOfMatches; - - /** - * Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths. The visitor - * will not search for paths going beyond an already matched node. - * - * @param filter The filter used to select terminal nodes of paths to record, may be {@code null} to match any node. - */ - public PathRecordingDependencyVisitor( DependencyFilter filter ) - { - this( filter, true ); - } - - /** - * Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths. - * - * @param filter The filter used to select terminal nodes of paths to record, may be {@code null} to match any node. - * @param excludeChildrenOfMatches Flag controlling whether children of matched nodes should be excluded from the - * traversal, thereby ignoring any potential paths to other matching nodes beneath a matching ancestor - * node. If {@code true}, all recorded paths will have only one matching node (namely the terminal node), - * if {@code false} a recorded path can consist of multiple matching nodes. - */ - public PathRecordingDependencyVisitor( DependencyFilter filter, boolean excludeChildrenOfMatches ) - { - this.filter = filter; - this.excludeChildrenOfMatches = excludeChildrenOfMatches; - paths = new ArrayList<List<DependencyNode>>(); - parents = new Stack<DependencyNode>(); - visited = new IdentityHashMap<DependencyNode, Object>( 128 ); - } - - /** - * Gets the filter being used to select terminal nodes. - * - * @return The filter being used or {@code null} if none. - */ - public DependencyFilter getFilter() - { - return filter; - } - - /** - * Gets the paths leading to nodes matching the filter that have been recorded during the graph visit. A path is - * given as a sequence of nodes, starting with the root node of the graph and ending with a node that matched the - * filter. - * - * @return The recorded paths, never {@code null}. - */ - public List<List<DependencyNode>> getPaths() - { - return paths; - } - - public boolean visitEnter( DependencyNode node ) - { - boolean accept = filter == null || filter.accept( node, parents ); - - parents.push( node ); - - if ( accept ) - { - DependencyNode[] path = new DependencyNode[parents.size()]; - for ( int i = 0, n = parents.size(); i < n; i++ ) - { - path[n - i - 1] = parents.get( i ); - } - paths.add( Arrays.asList( path ) ); - - if ( excludeChildrenOfMatches ) - { - return false; - } - } - - if ( visited.put( node, Boolean.TRUE ) != null ) - { - return false; - } - - return true; - } - - public boolean visitLeave( DependencyNode node ) - { - parents.pop(); - visited.remove( node ); - - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGenerator.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGenerator.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGenerator.java deleted file mode 100644 index 47897a7..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGenerator.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.eclipse.aether.graph.DependencyNode; - -/** - * Generates a sequence of dependency nodes from a dependeny graph by traversing the graph in postorder. This visitor - * visits each node exactly once regardless how many paths within the dependency graph lead to the node such that the - * resulting node sequence is free of duplicates. - */ -public final class PostorderNodeListGenerator - extends AbstractDepthFirstNodeListGenerator -{ - - private final Stack<Boolean> visits; - - /** - * Creates a new postorder list generator. - */ - public PostorderNodeListGenerator() - { - visits = new Stack<Boolean>(); - } - - @Override - public boolean visitEnter( DependencyNode node ) - { - boolean visited = !setVisited( node ); - - visits.push( visited ); - - if ( visited ) - { - return false; - } - - return true; - } - - @Override - public boolean visitLeave( DependencyNode node ) - { - Boolean visited = visits.pop(); - - if ( visited ) - { - return true; - } - - if ( node.getDependency() != null ) - { - nodes.add( node ); - } - - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGenerator.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGenerator.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGenerator.java deleted file mode 100644 index bd9b52a..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGenerator.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.eclipse.aether.graph.DependencyNode; - -/** - * Generates a sequence of dependency nodes from a dependeny graph by traversing the graph in preorder. This visitor - * visits each node exactly once regardless how many paths within the dependency graph lead to the node such that the - * resulting node sequence is free of duplicates. - */ -public final class PreorderNodeListGenerator - extends AbstractDepthFirstNodeListGenerator -{ - - /** - * Creates a new preorder list generator. - */ - public PreorderNodeListGenerator() - { - } - - @Override - public boolean visitEnter( DependencyNode node ) - { - if ( !setVisited( node ) ) - { - return false; - } - - if ( node.getDependency() != null ) - { - nodes.add( node ); - } - - return true; - } - - @Override - public boolean visitLeave( DependencyNode node ) - { - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/Stack.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/Stack.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/Stack.java deleted file mode 100644 index 27fbb4b..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/Stack.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.AbstractList; -import java.util.NoSuchElementException; -import java.util.RandomAccess; - -/** - * A non-synchronized stack with a non-modifiable list view which starts at the top of the stack. While - * {@code LinkedList} can provide the same behavior, it creates many temp objects upon frequent pushes/pops. - */ -class Stack<E> - extends AbstractList<E> - implements RandomAccess -{ - - @SuppressWarnings( "unchecked" ) - private E[] elements = (E[]) new Object[96]; - - private int size; - - public void push( E element ) - { - if ( size >= elements.length ) - { - @SuppressWarnings( "unchecked" ) - E[] tmp = (E[]) new Object[size + 64]; - System.arraycopy( elements, 0, tmp, 0, elements.length ); - elements = tmp; - } - elements[size++] = element; - } - - public E pop() - { - if ( size <= 0 ) - { - throw new NoSuchElementException(); - } - return elements[--size]; - } - - public E peek() - { - if ( size <= 0 ) - { - return null; - } - return elements[size - 1]; - } - - @Override - public E get( int index ) - { - if ( index < 0 || index >= size ) - { - throw new IndexOutOfBoundsException( "Index: " + index + ", Size: " + size ); - } - return elements[size - index - 1]; - } - - @Override - public int size() - { - return size; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java deleted file mode 100644 index f1658a8..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.eclipse.aether.util.graph.visitor; - -/* - * 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.IdentityHashMap; -import java.util.Map; - -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; - -/** - * A dependency visitor that delegates to another visitor if a node hasn't been visited before. In other words, this - * visitor provides a tree-view of a dependency graph which generally can have multiple paths to the same node or even - * cycles. - */ -public final class TreeDependencyVisitor - implements DependencyVisitor -{ - - private final Map<DependencyNode, Object> visitedNodes; - - private final DependencyVisitor visitor; - - private final Stack<Boolean> visits; - - /** - * Creates a new visitor that delegates to the specified visitor. - * - * @param visitor The visitor to delegate to, must not be {@code null}. - */ - public TreeDependencyVisitor( DependencyVisitor visitor ) - { - if ( visitor == null ) - { - throw new IllegalArgumentException( "no visitor delegate specified" ); - } - this.visitor = visitor; - visitedNodes = new IdentityHashMap<DependencyNode, Object>( 512 ); - visits = new Stack<Boolean>(); - } - - public boolean visitEnter( DependencyNode node ) - { - boolean visited = visitedNodes.put( node, Boolean.TRUE ) != null; - - visits.push( visited ); - - if ( visited ) - { - return false; - } - - return visitor.visitEnter( node ); - } - - public boolean visitLeave( DependencyNode node ) - { - Boolean visited = visits.pop(); - - if ( visited ) - { - return true; - } - - return visitor.visitLeave( node ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/package-info.java deleted file mode 100644 index 3ea9968..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Various dependency visitors for inspecting a dependency graph. - */ -package org.eclipse.aether.util.graph.visitor; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedRepositoryListener.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedRepositoryListener.java b/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedRepositoryListener.java deleted file mode 100644 index c654510..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedRepositoryListener.java +++ /dev/null @@ -1,437 +0,0 @@ -package org.eclipse.aether.util.listener; - -/* - * 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.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.aether.AbstractRepositoryListener; -import org.eclipse.aether.RepositoryEvent; -import org.eclipse.aether.RepositoryListener; - -/** - * A repository listener that delegates to zero or more other listeners (multicast). The list of target listeners is - * thread-safe, i.e. target listeners can be added or removed by any thread at any time. - */ -public final class ChainedRepositoryListener - extends AbstractRepositoryListener -{ - - private final List<RepositoryListener> listeners = new CopyOnWriteArrayList<RepositoryListener>(); - - /** - * Creates a new multicast listener that delegates to the specified listeners. In contrast to the constructor, this - * factory method will avoid creating an actual chained listener if one of the specified readers is actually - * {@code null}. - * - * @param listener1 The first listener, may be {@code null}. - * @param listener2 The second listener, may be {@code null}. - * @return The chained listener or {@code null} if no listener was supplied. - */ - public static RepositoryListener newInstance( RepositoryListener listener1, RepositoryListener listener2 ) - { - if ( listener1 == null ) - { - return listener2; - } - else if ( listener2 == null ) - { - return listener1; - } - return new ChainedRepositoryListener( listener1, listener2 ); - } - - /** - * Creates a new multicast listener that delegates to the specified listeners. - * - * @param listeners The listeners to delegate to, may be {@code null} or empty. - */ - public ChainedRepositoryListener( RepositoryListener... listeners ) - { - if ( listeners != null ) - { - add( Arrays.asList( listeners ) ); - } - } - - /** - * Creates a new multicast listener that delegates to the specified listeners. - * - * @param listeners The listeners to delegate to, may be {@code null} or empty. - */ - public ChainedRepositoryListener( Collection<? extends RepositoryListener> listeners ) - { - add( listeners ); - } - - /** - * Adds the specified listeners to the end of the multicast chain. - * - * @param listeners The listeners to add, may be {@code null} or empty. - */ - public void add( Collection<? extends RepositoryListener> listeners ) - { - if ( listeners != null ) - { - for ( RepositoryListener listener : listeners ) - { - add( listener ); - } - } - } - - /** - * Adds the specified listener to the end of the multicast chain. - * - * @param listener The listener to add, may be {@code null}. - */ - public void add( RepositoryListener listener ) - { - if ( listener != null ) - { - listeners.add( listener ); - } - } - - /** - * Removes the specified listener from the multicast chain. Trying to remove a non-existing listener has no effect. - * - * @param listener The listener to remove, may be {@code null}. - */ - public void remove( RepositoryListener listener ) - { - if ( listener != null ) - { - listeners.remove( listener ); - } - } - - protected void handleError( RepositoryEvent event, RepositoryListener listener, RuntimeException error ) - { - // default just swallows errors - } - - @Override - public void artifactDeployed( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDeployed( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactDeploying( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDeploying( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactDescriptorInvalid( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDescriptorInvalid( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactDescriptorMissing( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDescriptorMissing( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactDownloaded( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDownloaded( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactDownloading( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactDownloading( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactInstalled( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactInstalled( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactInstalling( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactInstalling( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactResolved( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactResolved( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void artifactResolving( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.artifactResolving( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataDeployed( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataDeployed( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataDeploying( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataDeploying( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataDownloaded( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataDownloaded( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataDownloading( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataDownloading( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataInstalled( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataInstalled( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataInstalling( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataInstalling( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataInvalid( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataInvalid( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataResolved( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataResolved( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void metadataResolving( RepositoryEvent event ) - { - for ( RepositoryListener listener : listeners ) - { - try - { - listener.metadataResolving( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedTransferListener.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedTransferListener.java b/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedTransferListener.java deleted file mode 100644 index d943105..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/listener/ChainedTransferListener.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.eclipse.aether.util.listener; - -/* - * 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.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.aether.transfer.AbstractTransferListener; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferListener; - -/** - * A transfer listener that delegates to zero or more other listeners (multicast). The list of target listeners is - * thread-safe, i.e. target listeners can be added or removed by any thread at any time. - */ -public final class ChainedTransferListener - extends AbstractTransferListener -{ - - private final List<TransferListener> listeners = new CopyOnWriteArrayList<TransferListener>(); - - /** - * Creates a new multicast listener that delegates to the specified listeners. In contrast to the constructor, this - * factory method will avoid creating an actual chained listener if one of the specified readers is actually - * {@code null}. - * - * @param listener1 The first listener, may be {@code null}. - * @param listener2 The second listener, may be {@code null}. - * @return The chained listener or {@code null} if no listener was supplied. - */ - public static TransferListener newInstance( TransferListener listener1, TransferListener listener2 ) - { - if ( listener1 == null ) - { - return listener2; - } - else if ( listener2 == null ) - { - return listener1; - } - return new ChainedTransferListener( listener1, listener2 ); - } - - /** - * Creates a new multicast listener that delegates to the specified listeners. - * - * @param listeners The listeners to delegate to, may be {@code null} or empty. - */ - public ChainedTransferListener( TransferListener... listeners ) - { - if ( listeners != null ) - { - add( Arrays.asList( listeners ) ); - } - } - - /** - * Creates a new multicast listener that delegates to the specified listeners. - * - * @param listeners The listeners to delegate to, may be {@code null} or empty. - */ - public ChainedTransferListener( Collection<? extends TransferListener> listeners ) - { - add( listeners ); - } - - /** - * Adds the specified listeners to the end of the multicast chain. - * - * @param listeners The listeners to add, may be {@code null} or empty. - */ - public void add( Collection<? extends TransferListener> listeners ) - { - if ( listeners != null ) - { - for ( TransferListener listener : listeners ) - { - add( listener ); - } - } - } - - /** - * Adds the specified listener to the end of the multicast chain. - * - * @param listener The listener to add, may be {@code null}. - */ - public void add( TransferListener listener ) - { - if ( listener != null ) - { - listeners.add( listener ); - } - } - - /** - * Removes the specified listener from the multicast chain. Trying to remove a non-existing listener has no effect. - * - * @param listener The listener to remove, may be {@code null}. - */ - public void remove( TransferListener listener ) - { - if ( listener != null ) - { - listeners.remove( listener ); - } - } - - protected void handleError( TransferEvent event, TransferListener listener, RuntimeException error ) - { - // default just swallows errors - } - - @Override - public void transferInitiated( TransferEvent event ) - throws TransferCancelledException - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferInitiated( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void transferStarted( TransferEvent event ) - throws TransferCancelledException - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferStarted( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void transferProgressed( TransferEvent event ) - throws TransferCancelledException - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferProgressed( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void transferCorrupted( TransferEvent event ) - throws TransferCancelledException - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferCorrupted( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferSucceeded( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - - @Override - public void transferFailed( TransferEvent event ) - { - for ( TransferListener listener : listeners ) - { - try - { - listener.transferFailed( event ); - } - catch ( RuntimeException e ) - { - handleError( event, listener, e ); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/listener/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/listener/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/listener/package-info.java deleted file mode 100644 index 9f0be58..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/listener/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Utilities to build repository and transfer listeners. - */ -package org.eclipse.aether.util.listener; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/package-info.java deleted file mode 100644 index 605e777..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Miscellaneous utility classes. - */ -package org.eclipse.aether.util; -