http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java deleted file mode 100644 index ed4d55b..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java +++ /dev/null @@ -1,233 +0,0 @@ -package org.eclipse.aether.util.artifact; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.Map; - -import org.eclipse.aether.artifact.AbstractArtifact; -import org.eclipse.aether.artifact.Artifact; - -/** - * An artifact whose identity is derived from another artifact. <em>Note:</em> Instances of this class are immutable and - * the exposed mutators return new objects rather than changing the current instance. - */ -public final class SubArtifact - extends AbstractArtifact -{ - - private final Artifact mainArtifact; - - private final String classifier; - - private final String extension; - - private final File file; - - private final Map<String, String> properties; - - /** - * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk - * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier - * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be - * used to refer to the GPG signature of an artifact. - * - * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}. - * @param classifier The classifier for this artifact, may be {@code null} if none. - * @param extension The extension for this artifact, may be {@code null} if none. - */ - public SubArtifact( Artifact mainArtifact, String classifier, String extension ) - { - this( mainArtifact, classifier, extension, (File) null ); - } - - /** - * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk - * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier - * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be - * used to refer to the GPG signature of an artifact. - * - * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}. - * @param classifier The classifier for this artifact, may be {@code null} if none. - * @param extension The extension for this artifact, may be {@code null} if none. - * @param file The file for this artifact, may be {@code null} if unresolved. - */ - public SubArtifact( Artifact mainArtifact, String classifier, String extension, File file ) - { - this( mainArtifact, classifier, extension, null, file ); - } - - /** - * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk - * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier - * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be - * used to refer to the GPG signature of an artifact. - * - * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}. - * @param classifier The classifier for this artifact, may be {@code null} if none. - * @param extension The extension for this artifact, may be {@code null} if none. - * @param properties The properties of the artifact, may be {@code null}. - */ - public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties ) - { - this( mainArtifact, classifier, extension, properties, null ); - } - - /** - * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk - * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier - * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be - * used to refer to the GPG signature of an artifact. - * - * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}. - * @param classifier The classifier for this artifact, may be {@code null} if none. - * @param extension The extension for this artifact, may be {@code null} if none. - * @param properties The properties of the artifact, may be {@code null}. - * @param file The file for this artifact, may be {@code null} if unresolved. - */ - public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties, - File file ) - { - if ( mainArtifact == null ) - { - throw new IllegalArgumentException( "no artifact specified" ); - } - this.mainArtifact = mainArtifact; - this.classifier = classifier; - this.extension = extension; - this.file = file; - this.properties = copyProperties( properties ); - } - - private SubArtifact( Artifact mainArtifact, String classifier, String extension, File file, - Map<String, String> properties ) - { - // NOTE: This constructor assumes immutability of the provided properties, for internal use only - this.mainArtifact = mainArtifact; - this.classifier = classifier; - this.extension = extension; - this.file = file; - this.properties = properties; - } - - public String getGroupId() - { - return mainArtifact.getGroupId(); - } - - public String getArtifactId() - { - return mainArtifact.getArtifactId(); - } - - public String getVersion() - { - return mainArtifact.getVersion(); - } - - public String getBaseVersion() - { - return mainArtifact.getBaseVersion(); - } - - public boolean isSnapshot() - { - return mainArtifact.isSnapshot(); - } - - public String getClassifier() - { - return expand( classifier, mainArtifact.getClassifier() ); - } - - public String getExtension() - { - return expand( extension, mainArtifact.getExtension() ); - } - - public File getFile() - { - return file; - } - - public Artifact setFile( File file ) - { - if ( ( this.file == null ) ? file == null : this.file.equals( file ) ) - { - return this; - } - return new SubArtifact( mainArtifact, classifier, extension, file, properties ); - } - - public Map<String, String> getProperties() - { - return properties; - } - - public Artifact setProperties( Map<String, String> properties ) - { - if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) ) - { - return this; - } - return new SubArtifact( mainArtifact, classifier, extension, properties, file ); - } - - private static String expand( String pattern, String replacement ) - { - String result = ""; - if ( pattern != null ) - { - result = pattern.replace( "*", replacement ); - - if ( replacement.length() <= 0 ) - { - if ( pattern.startsWith( "*" ) ) - { - int i = 0; - for ( ; i < result.length(); i++ ) - { - char c = result.charAt( i ); - if ( c != '-' && c != '.' ) - { - break; - } - } - result = result.substring( i ); - } - if ( pattern.endsWith( "*" ) ) - { - int i = result.length() - 1; - for ( ; i >= 0; i-- ) - { - char c = result.charAt( i ); - if ( c != '-' && c != '.' ) - { - break; - } - } - result = result.substring( 0, i + 1 ); - } - } - } - return result; - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/package-info.java deleted file mode 100644 index 153159f..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/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 around artifacts and artifact type registries. - */ -package org.eclipse.aether.util.artifact; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java b/aether-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java deleted file mode 100644 index 270ea82..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.eclipse.aether.util.concurrency; - -/* - * 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.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.locks.LockSupport; - -/** - * A utility class to forward any uncaught {@link Error} or {@link RuntimeException} from a {@link Runnable} executed in - * a worker thread back to the parent thread. The simplified usage pattern looks like this: - * - * <pre> - * RunnableErrorForwarder errorForwarder = new RunnableErrorForwarder(); - * for ( Runnable task : tasks ) - * { - * executor.execute( errorForwarder.wrap( task ) ); - * } - * errorForwarder.await(); - * </pre> - */ -public final class RunnableErrorForwarder -{ - - private final Thread thread = Thread.currentThread(); - - private final AtomicInteger counter = new AtomicInteger(); - - private final AtomicReference<Throwable> error = new AtomicReference<Throwable>(); - - /** - * Creates a new error forwarder for worker threads spawned by the current thread. - */ - public RunnableErrorForwarder() - { - } - - /** - * Wraps the specified runnable into an equivalent runnable that will allow forwarding of uncaught errors. - * - * @param runnable The runnable from which to forward errors, must not be {@code null}. - * @return The error-forwarding runnable to eventually execute, never {@code null}. - */ - public Runnable wrap( final Runnable runnable ) - { - if ( runnable == null ) - { - throw new IllegalArgumentException( "runnable missing" ); - } - - counter.incrementAndGet(); - - return new Runnable() - { - public void run() - { - try - { - runnable.run(); - } - catch ( RuntimeException e ) - { - error.compareAndSet( null, e ); - throw e; - } - catch ( Error e ) - { - error.compareAndSet( null, e ); - throw e; - } - finally - { - counter.decrementAndGet(); - LockSupport.unpark( thread ); - } - } - }; - } - - /** - * Causes the current thread to wait until all previously {@link #wrap(Runnable) wrapped} runnables have terminated - * and potentially re-throws an uncaught {@link RuntimeException} or {@link Error} from any of the runnables. In - * case multiple runnables encountered uncaught errors, one error is arbitrarily selected. <em>Note:</em> This - * method must be called from the same thread that created this error forwarder instance. - */ - public void await() - { - awaitTerminationOfAllRunnables(); - - Throwable error = this.error.get(); - if ( error != null ) - { - if ( error instanceof RuntimeException ) - { - throw (RuntimeException) error; - } - else if ( error instanceof ThreadDeath ) - { - throw new IllegalStateException( error ); - } - else if ( error instanceof Error ) - { - throw (Error) error; - } - throw new IllegalStateException( error ); - } - } - - private void awaitTerminationOfAllRunnables() - { - if ( !thread.equals( Thread.currentThread() ) ) - { - throw new IllegalStateException( "wrong caller thread, expected " + thread + " and not " - + Thread.currentThread() ); - } - - boolean interrupted = false; - - while ( counter.get() > 0 ) - { - LockSupport.park(); - - if ( Thread.interrupted() ) - { - interrupted = true; - } - } - - if ( interrupted ) - { - Thread.currentThread().interrupt(); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/concurrency/WorkerThreadFactory.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/WorkerThreadFactory.java b/aether-util/src/main/java/org/eclipse/aether/util/concurrency/WorkerThreadFactory.java deleted file mode 100644 index 26d0fb6..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/WorkerThreadFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.eclipse.aether.util.concurrency; - -/* - * 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.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A factory to create worker threads with a given name prefix. - */ -public final class WorkerThreadFactory - implements ThreadFactory -{ - - private final ThreadFactory factory; - - private final String namePrefix; - - private final AtomicInteger threadIndex; - - private static final AtomicInteger POOL_INDEX = new AtomicInteger(); - - /** - * Creates a new thread factory whose threads will have names using the specified prefix. - * - * @param namePrefix The prefix for the thread names, may be {@code null} or empty to derive the prefix from the - * caller's simple class name. - */ - public WorkerThreadFactory( String namePrefix ) - { - this.factory = Executors.defaultThreadFactory(); - this.namePrefix = - ( ( namePrefix != null && namePrefix.length() > 0 ) ? namePrefix : getCallerSimpleClassName() + '-' ) - + POOL_INDEX.getAndIncrement() + '-'; - threadIndex = new AtomicInteger(); - } - - private static String getCallerSimpleClassName() - { - StackTraceElement[] stack = new Exception().getStackTrace(); - if ( stack == null || stack.length <= 2 ) - { - return "Worker-"; - } - String name = stack[2].getClassName(); - name = name.substring( name.lastIndexOf( '.' ) + 1 ); - return name; - } - - public Thread newThread( Runnable r ) - { - Thread thread = factory.newThread( r ); - thread.setName( namePrefix + threadIndex.getAndIncrement() ); - thread.setDaemon( true ); - return thread; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/concurrency/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/concurrency/package-info.java deleted file mode 100644 index 2bb7853..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/concurrency/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 for concurrent task processing. - */ -package org.eclipse.aether.util.concurrency; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java deleted file mode 100644 index d707d26..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.version.InvalidVersionSpecificationException; -import org.eclipse.aether.version.Version; -import org.eclipse.aether.version.VersionRange; -import org.eclipse.aether.version.VersionScheme; - -/** - */ -class AbstractPatternDependencyFilter - implements DependencyFilter -{ - - private final Set<String> patterns = new HashSet<String>(); - - private final VersionScheme versionScheme; - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public AbstractPatternDependencyFilter( final String... patterns ) - { - this( null, patterns ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be included. - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public AbstractPatternDependencyFilter( final VersionScheme versionScheme, final String... patterns ) - { - this( versionScheme, patterns == null ? null : Arrays.asList( patterns ) ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public AbstractPatternDependencyFilter( final Collection<String> patterns ) - { - this( null, patterns ); - } - - /** - * Creates a new filter using the specified patterns and {@link VersionScheme} . - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be included. - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public AbstractPatternDependencyFilter( final VersionScheme versionScheme, final Collection<String> patterns ) - { - if ( patterns != null ) - { - this.patterns.addAll( patterns ); - } - this.versionScheme = versionScheme; - } - - public boolean accept( final DependencyNode node, List<DependencyNode> parents ) - { - final Dependency dependency = node.getDependency(); - if ( dependency == null ) - { - return true; - } - return accept( dependency.getArtifact() ); - } - - protected boolean accept( final Artifact artifact ) - { - for ( final String pattern : patterns ) - { - final boolean matched = accept( artifact, pattern ); - if ( matched ) - { - return true; - } - } - return false; - } - - private boolean accept( final Artifact artifact, final String pattern ) - { - final String[] tokens = - new String[] { artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), - artifact.getBaseVersion() }; - - final String[] patternTokens = pattern.split( ":" ); - - // fail immediately if pattern tokens outnumber tokens to match - boolean matched = ( patternTokens.length <= tokens.length ); - - for ( int i = 0; matched && i < patternTokens.length; i++ ) - { - matched = matches( tokens[i], patternTokens[i] ); - } - - return matched; - } - - private boolean matches( final String token, final String pattern ) - { - boolean matches; - - // support full wildcard and implied wildcard - if ( "*".equals( pattern ) || pattern.length() == 0 ) - { - matches = true; - } - // support contains wildcard - else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) ) - { - final String contains = pattern.substring( 1, pattern.length() - 1 ); - - matches = ( token.contains( contains ) ); - } - // support leading wildcard - else if ( pattern.startsWith( "*" ) ) - { - final String suffix = pattern.substring( 1, pattern.length() ); - - matches = token.endsWith( suffix ); - } - // support trailing wildcard - else if ( pattern.endsWith( "*" ) ) - { - final String prefix = pattern.substring( 0, pattern.length() - 1 ); - - matches = token.startsWith( prefix ); - } - // support versions range - else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" ) ) - { - matches = isVersionIncludedInRange( token, pattern ); - } - // support exact match - else - { - matches = token.equals( pattern ); - } - - return matches; - } - - private boolean isVersionIncludedInRange( final String version, final String range ) - { - if ( versionScheme == null ) - { - return false; - } - else - { - try - { - final Version parsedVersion = versionScheme.parseVersion( version ); - final VersionRange parsedRange = versionScheme.parseVersionRange( range ); - - return parsedRange.containsVersion( parsedVersion ); - } - catch ( final InvalidVersionSpecificationException e ) - { - return false; - } - } - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - final AbstractPatternDependencyFilter that = (AbstractPatternDependencyFilter) obj; - - return this.patterns.equals( that.patterns ) - && ( this.versionScheme == null ? that.versionScheme == null - : this.versionScheme.equals( that.versionScheme ) ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + patterns.hashCode(); - hash = hash * 31 + ( ( versionScheme == null ) ? 0 : versionScheme.hashCode() ); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/AndDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/AndDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/AndDependencyFilter.java deleted file mode 100644 index 9997c94..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/AndDependencyFilter.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; - -/** - * A dependency filter that combines zero or more other filters using a logical {@code AND}. The resulting filter - * accepts a given dependency node if and only if all constituent filters accept it. - */ -public final class AndDependencyFilter - implements DependencyFilter -{ - - private final Set<DependencyFilter> filters = new LinkedHashSet<DependencyFilter>(); - - /** - * Creates a new filter from the specified filters. Prefer {@link #newInstance(DependencyFilter, DependencyFilter)} - * if any of the input filters might be {@code null}. - * - * @param filters The filters to combine, may be {@code null} but must not contain {@code null} elements. - */ - public AndDependencyFilter( DependencyFilter... filters ) - { - if ( filters != null ) - { - Collections.addAll( this.filters, filters ); - } - } - - /** - * Creates a new filter from the specified filters. - * - * @param filters The filters to combine, may be {@code null} but must not contain {@code null} elements. - */ - public AndDependencyFilter( Collection<DependencyFilter> filters ) - { - if ( filters != null ) - { - this.filters.addAll( filters ); - } - } - - /** - * Creates a new filter from the specified filters. - * - * @param filter1 The first filter to combine, may be {@code null}. - * @param filter2 The second filter to combine, may be {@code null}. - * @return The combined filter or {@code null} if both filter were {@code null}. - */ - public static DependencyFilter newInstance( DependencyFilter filter1, DependencyFilter filter2 ) - { - if ( filter1 == null ) - { - return filter2; - } - else if ( filter2 == null ) - { - return filter1; - } - return new AndDependencyFilter( filter1, filter2 ); - } - - public boolean accept( DependencyNode node, List<DependencyNode> parents ) - { - for ( DependencyFilter filter : filters ) - { - if ( !filter.accept( node, parents ) ) - { - return false; - } - } - return true; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - AndDependencyFilter that = (AndDependencyFilter) obj; - - return this.filters.equals( that.filters ); - } - - @Override - public int hashCode() - { - int hash = getClass().hashCode(); - hash = hash * 31 + filters.hashCode(); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java deleted file mode 100644 index 887c4b1..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.HashSet; - -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.util.artifact.JavaScopes; - -/** - * A utility class assisting in the creation of dependency node filters. - */ -public final class DependencyFilterUtils -{ - - private DependencyFilterUtils() - { - // hide constructor - } - - /** - * Creates a new filter that negates the specified filter. - * - * @param filter The filter to negate, must not be {@code null}. - * @return The new filter, never {@code null}. - */ - public static DependencyFilter notFilter( DependencyFilter filter ) - { - return new NotDependencyFilter( filter ); - } - - /** - * Creates a new filter that combines the specified filters using a logical {@code AND}. If no filters are - * specified, the resulting filter accepts everything. - * - * @param filters The filters to combine, may be {@code null}. - * @return The new filter, never {@code null}. - */ - public static DependencyFilter andFilter( DependencyFilter... filters ) - { - if ( filters != null && filters.length == 1 ) - { - return filters[0]; - } - else - { - return new AndDependencyFilter( filters ); - } - } - - /** - * Creates a new filter that combines the specified filters using a logical {@code AND}. If no filters are - * specified, the resulting filter accepts everything. - * - * @param filters The filters to combine, may be {@code null}. - * @return The new filter, never {@code null}. - */ - public static DependencyFilter andFilter( Collection<DependencyFilter> filters ) - { - if ( filters != null && filters.size() == 1 ) - { - return filters.iterator().next(); - } - else - { - return new AndDependencyFilter( filters ); - } - } - - /** - * Creates a new filter that combines the specified filters using a logical {@code OR}. If no filters are specified, - * the resulting filter accepts nothing. - * - * @param filters The filters to combine, may be {@code null}. - * @return The new filter, never {@code null}. - */ - public static DependencyFilter orFilter( DependencyFilter... filters ) - { - if ( filters != null && filters.length == 1 ) - { - return filters[0]; - } - else - { - return new OrDependencyFilter( filters ); - } - } - - /** - * Creates a new filter that combines the specified filters using a logical {@code OR}. If no filters are specified, - * the resulting filter accepts nothing. - * - * @param filters The filters to combine, may be {@code null}. - * @return The new filter, never {@code null}. - */ - public static DependencyFilter orFilter( Collection<DependencyFilter> filters ) - { - if ( filters != null && filters.size() == 1 ) - { - return filters.iterator().next(); - } - else - { - return new OrDependencyFilter( filters ); - } - } - - /** - * Creates a new filter that selects dependencies whose scope matches one or more of the specified classpath types. - * A classpath type is a set of scopes separated by either {@code ','} or {@code '+'}. - * - * @param classpathTypes The classpath types, may be {@code null} or empty to match no dependency. - * @return The new filter, never {@code null}. - * @see JavaScopes - */ - public static DependencyFilter classpathFilter( String... classpathTypes ) - { - return classpathFilter( ( classpathTypes != null ) ? Arrays.asList( classpathTypes ) : null ); - } - - /** - * Creates a new filter that selects dependencies whose scope matches one or more of the specified classpath types. - * A classpath type is a set of scopes separated by either {@code ','} or {@code '+'}. - * - * @param classpathTypes The classpath types, may be {@code null} or empty to match no dependency. - * @return The new filter, never {@code null}. - * @see JavaScopes - */ - public static DependencyFilter classpathFilter( Collection<String> classpathTypes ) - { - Collection<String> types = new HashSet<String>(); - - if ( classpathTypes != null ) - { - for ( String classpathType : classpathTypes ) - { - String[] tokens = classpathType.split( "[+,]" ); - for ( String token : tokens ) - { - token = token.trim(); - if ( token.length() > 0 ) - { - types.add( token ); - } - } - } - } - - Collection<String> included = new HashSet<String>(); - for ( String type : types ) - { - if ( JavaScopes.COMPILE.equals( type ) ) - { - Collections.addAll( included, JavaScopes.COMPILE, JavaScopes.PROVIDED, JavaScopes.SYSTEM ); - } - else if ( JavaScopes.RUNTIME.equals( type ) ) - { - Collections.addAll( included, JavaScopes.COMPILE, JavaScopes.RUNTIME ); - } - else if ( JavaScopes.TEST.equals( type ) ) - { - Collections.addAll( included, JavaScopes.COMPILE, JavaScopes.PROVIDED, JavaScopes.SYSTEM, - JavaScopes.RUNTIME, JavaScopes.TEST ); - } - else - { - included.add( type ); - } - } - - Collection<String> excluded = new HashSet<String>(); - Collections.addAll( excluded, JavaScopes.COMPILE, JavaScopes.PROVIDED, JavaScopes.SYSTEM, JavaScopes.RUNTIME, - JavaScopes.TEST ); - excluded.removeAll( included ); - - return new ScopeDependencyFilter( null, excluded ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java deleted file mode 100644 index 2de4ae8..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; - -/** - * A simple filter to exclude artifacts based on either artifact id or group id and artifact id. - */ -public final class ExclusionsDependencyFilter - implements DependencyFilter -{ - - private final Set<String> excludes = new HashSet<String>(); - - /** - * Creates a new filter using the specified exclude patterns. A pattern can either be of the form - * {@code groupId:artifactId} (recommended) or just {@code artifactId} (deprecated). - * - * @param excludes The exclude patterns, may be {@code null} or empty to exclude no artifacts. - */ - public ExclusionsDependencyFilter( Collection<String> excludes ) - { - if ( excludes != null ) - { - this.excludes.addAll( excludes ); - } - } - - public boolean accept( DependencyNode node, List<DependencyNode> parents ) - { - Dependency dependency = node.getDependency(); - - if ( dependency == null ) - { - return true; - } - - String id = dependency.getArtifact().getArtifactId(); - - if ( excludes.contains( id ) ) - { - return false; - } - - id = dependency.getArtifact().getGroupId() + ':' + id; - - if ( excludes.contains( id ) ) - { - return false; - } - - return true; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - ExclusionsDependencyFilter that = (ExclusionsDependencyFilter) obj; - - return this.excludes.equals( that.excludes ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + excludes.hashCode(); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java deleted file mode 100644 index d5fdb24..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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; - -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; - -/** - * A dependency filter that negates another filter. - */ -public final class NotDependencyFilter - implements DependencyFilter -{ - - private final DependencyFilter filter; - - /** - * Creates a new filter negatint the specified filter. - * - * @param filter The filter to negate, must not be {@code null}. - */ - public NotDependencyFilter( DependencyFilter filter ) - { - if ( filter == null ) - { - throw new IllegalArgumentException( "no filter specified" ); - } - this.filter = filter; - } - - public boolean accept( DependencyNode node, List<DependencyNode> parents ) - { - return !filter.accept( node, parents ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - NotDependencyFilter that = (NotDependencyFilter) obj; - - return this.filter.equals( that.filter ); - } - - @Override - public int hashCode() - { - int hash = getClass().hashCode(); - hash = hash * 31 + filter.hashCode(); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/OrDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/OrDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/OrDependencyFilter.java deleted file mode 100644 index 665f6e7..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/OrDependencyFilter.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; - -/** - * A dependency filter that combines zero or more other filters using a logical {@code OR}. - */ -public final class OrDependencyFilter - implements DependencyFilter -{ - - private final Set<DependencyFilter> filters = new LinkedHashSet<DependencyFilter>(); - - /** - * Creates a new filter from the specified filters. - * - * @param filters The filters to combine, may be {@code null}. - */ - public OrDependencyFilter( DependencyFilter... filters ) - { - if ( filters != null ) - { - Collections.addAll( this.filters, filters ); - } - } - - /** - * Creates a new filter from the specified filters. - * - * @param filters The filters to combine, may be {@code null}. - */ - public OrDependencyFilter( Collection<DependencyFilter> filters ) - { - if ( filters != null ) - { - this.filters.addAll( filters ); - } - } - - /** - * Creates a new filter from the specified filters. - * - * @param filter1 The first filter to combine, may be {@code null}. - * @param filter2 The first filter to combine, may be {@code null}. - * @return The combined filter or {@code null} if both filter were {@code null}. - */ - public static DependencyFilter newInstance( DependencyFilter filter1, DependencyFilter filter2 ) - { - if ( filter1 == null ) - { - return filter2; - } - else if ( filter2 == null ) - { - return filter1; - } - return new OrDependencyFilter( filter1, filter2 ); - } - - public boolean accept( DependencyNode node, List<DependencyNode> parents ) - { - for ( DependencyFilter filter : filters ) - { - if ( filter.accept( node, parents ) ) - { - return true; - } - } - return false; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - OrDependencyFilter that = (OrDependencyFilter) obj; - - return this.filters.equals( that.filters ); - } - - @Override - public int hashCode() - { - int hash = getClass().hashCode(); - hash = hash * 31 + filters.hashCode(); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilter.java deleted file mode 100644 index e768614..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternExclusionsDependencyFilter.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.Collection; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.version.VersionScheme; - -/** - * A simple filter to exclude artifacts from a list of patterns. The artifact pattern syntax is of the form: - * - * <pre> - * [groupId]:[artifactId]:[extension]:[version] - * </pre> - * <p> - * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern - * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified. - * </p> - * <p> - * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with - * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. - * </p> - */ -public final class PatternExclusionsDependencyFilter - extends AbstractPatternDependencyFilter -{ - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. - */ - public PatternExclusionsDependencyFilter( final String... patterns ) - { - super( patterns ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be excluded. - * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. - */ - public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final String... patterns ) - { - super( versionScheme, patterns ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public PatternExclusionsDependencyFilter( final Collection<String> patterns ) - { - super( patterns ); - } - - /** - * Creates a new filter using the specified patterns and {@link VersionScheme} . - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be excluded. - * @param patterns The exclude patterns, may be {@code null} or empty to exclude no artifacts. - */ - public PatternExclusionsDependencyFilter( final VersionScheme versionScheme, final Collection<String> patterns ) - { - super( versionScheme, patterns ); - } - - @Override - protected boolean accept( Artifact artifact ) - { - return !super.accept( artifact ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilter.java deleted file mode 100644 index e30600b..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilter.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.Collection; - -import org.eclipse.aether.version.VersionScheme; - -/** - * A simple filter to include artifacts from a list of patterns. The artifact pattern syntax is of the form: - * - * <pre> - * [groupId]:[artifactId]:[extension]:[version] - * </pre> - * <p> - * Where each pattern segment is optional and supports full and partial <code>*</code> wildcards. An empty pattern - * segment is treated as an implicit wildcard. Version can be a range in case a {@link VersionScheme} is specified. - * </p> - * <p> - * For example, <code>org.eclipse.*</code> would match all artifacts whose group id started with - * <code>org.eclipse.</code> , and <code>:::*-SNAPSHOT</code> would match all snapshot artifacts. - * </p> - */ -public final class PatternInclusionsDependencyFilter - extends AbstractPatternDependencyFilter -{ - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public PatternInclusionsDependencyFilter( final String... patterns ) - { - super( patterns ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be included. - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public PatternInclusionsDependencyFilter( final VersionScheme versionScheme, final String... patterns ) - { - super( versionScheme, patterns ); - } - - /** - * Creates a new filter using the specified patterns. - * - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public PatternInclusionsDependencyFilter( final Collection<String> patterns ) - { - super( patterns ); - } - - /** - * Creates a new filter using the specified patterns and {@link VersionScheme} . - * - * @param versionScheme To be used for parsing versions/version ranges. If {@code null} and pattern specifies a - * range no artifact will be included. - * @param patterns The include patterns, may be {@code null} or empty to include no artifacts. - */ - public PatternInclusionsDependencyFilter( final VersionScheme versionScheme, final Collection<String> patterns ) - { - super( versionScheme, patterns ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/ScopeDependencyFilter.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/ScopeDependencyFilter.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/ScopeDependencyFilter.java deleted file mode 100644 index bc60c41..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/ScopeDependencyFilter.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.eclipse.aether.util.filter; - -/* - * 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.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; - -/** - * A dependency filter based on dependency scopes. <em>Note:</em> This filter does not assume any relationships between - * the scopes. In particular, the filter is not aware of scopes that logically include other scopes. - * - * @see Dependency#getScope() - */ -public final class ScopeDependencyFilter - implements DependencyFilter -{ - - private final Set<String> included = new HashSet<String>(); - - private final Set<String> excluded = new HashSet<String>(); - - /** - * Creates a new filter using the specified includes and excludes. - * - * @param included The set of scopes to include, may be {@code null} or empty to include any scope. - * @param excluded The set of scopes to exclude, may be {@code null} or empty to exclude no scope. - */ - public ScopeDependencyFilter( Collection<String> included, Collection<String> excluded ) - { - if ( included != null ) - { - this.included.addAll( included ); - } - if ( excluded != null ) - { - this.excluded.addAll( excluded ); - } - } - - /** - * Creates a new filter using the specified excludes. - * - * @param excluded The set of scopes to exclude, may be {@code null} or empty to exclude no scope. - */ - public ScopeDependencyFilter( String... excluded ) - { - if ( excluded != null ) - { - this.excluded.addAll( Arrays.asList( excluded ) ); - } - } - - public boolean accept( DependencyNode node, List<DependencyNode> parents ) - { - Dependency dependency = node.getDependency(); - - if ( dependency == null ) - { - return true; - } - - String scope = node.getDependency().getScope(); - return ( included.isEmpty() || included.contains( scope ) ) - && ( excluded.isEmpty() || !excluded.contains( scope ) ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( obj == null || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - ScopeDependencyFilter that = (ScopeDependencyFilter) obj; - - return this.included.equals( that.included ) && this.excluded.equals( that.excluded ); - } - - @Override - public int hashCode() - { - int hash = 17; - hash = hash * 31 + included.hashCode(); - hash = hash * 31 + excluded.hashCode(); - return hash; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/filter/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/filter/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/filter/package-info.java deleted file mode 100644 index 6547d2e..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/filter/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 filters for selecting nodes in a dependency graph. - */ -package org.eclipse.aether.util.filter; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java deleted file mode 100644 index fefb9fb..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java +++ /dev/null @@ -1,327 +0,0 @@ -package org.eclipse.aether.util.graph.manager; - -/* - * 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.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.ArtifactProperties; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyManagement; -import org.eclipse.aether.collection.DependencyManager; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.Exclusion; -import org.eclipse.aether.util.artifact.JavaScopes; - -/** - * A dependency manager that mimics the way Maven 2.x works. - */ -public final class ClassicDependencyManager - implements DependencyManager -{ - - private final int depth; - - private final Map<Object, String> managedVersions; - - private final Map<Object, String> managedScopes; - - private final Map<Object, Boolean> managedOptionals; - - private final Map<Object, String> managedLocalPaths; - - private final Map<Object, Collection<Exclusion>> managedExclusions; - - private int hashCode; - - /** - * Creates a new dependency manager without any management information. - */ - public ClassicDependencyManager() - { - this( 0, Collections.<Object, String>emptyMap(), Collections.<Object, String>emptyMap(), - Collections.<Object, Boolean>emptyMap(), Collections.<Object, String>emptyMap(), - Collections.<Object, Collection<Exclusion>>emptyMap() ); - } - - private ClassicDependencyManager( int depth, Map<Object, String> managedVersions, - Map<Object, String> managedScopes, Map<Object, Boolean> managedOptionals, - Map<Object, String> managedLocalPaths, - Map<Object, Collection<Exclusion>> managedExclusions ) - { - this.depth = depth; - this.managedVersions = managedVersions; - this.managedScopes = managedScopes; - this.managedOptionals = managedOptionals; - this.managedLocalPaths = managedLocalPaths; - this.managedExclusions = managedExclusions; - } - - public DependencyManager deriveChildManager( DependencyCollectionContext context ) - { - if ( depth >= 2 ) - { - return this; - } - else if ( depth == 1 ) - { - return new ClassicDependencyManager( depth + 1, managedVersions, managedScopes, managedOptionals, - managedLocalPaths, managedExclusions ); - } - - Map<Object, String> managedVersions = this.managedVersions; - Map<Object, String> managedScopes = this.managedScopes; - Map<Object, Boolean> managedOptionals = this.managedOptionals; - Map<Object, String> managedLocalPaths = this.managedLocalPaths; - Map<Object, Collection<Exclusion>> managedExclusions = this.managedExclusions; - - for ( Dependency managedDependency : context.getManagedDependencies() ) - { - Artifact artifact = managedDependency.getArtifact(); - Object key = getKey( artifact ); - - String version = artifact.getVersion(); - if ( version.length() > 0 && !managedVersions.containsKey( key ) ) - { - if ( managedVersions == this.managedVersions ) - { - managedVersions = new HashMap<Object, String>( this.managedVersions ); - } - managedVersions.put( key, version ); - } - - String scope = managedDependency.getScope(); - if ( scope.length() > 0 && !managedScopes.containsKey( key ) ) - { - if ( managedScopes == this.managedScopes ) - { - managedScopes = new HashMap<Object, String>( this.managedScopes ); - } - managedScopes.put( key, scope ); - } - - Boolean optional = managedDependency.getOptional(); - if ( optional != null && !managedOptionals.containsKey( key ) ) - { - if ( managedOptionals == this.managedOptionals ) - { - managedOptionals = new HashMap<Object, Boolean>( this.managedOptionals ); - } - managedOptionals.put( key, optional ); - } - - String localPath = managedDependency.getArtifact().getProperty( ArtifactProperties.LOCAL_PATH, null ); - if ( localPath != null && !managedLocalPaths.containsKey( key ) ) - { - if ( managedLocalPaths == this.managedLocalPaths ) - { - managedLocalPaths = new HashMap<Object, String>( this.managedLocalPaths ); - } - managedLocalPaths.put( key, localPath ); - } - - Collection<Exclusion> exclusions = managedDependency.getExclusions(); - if ( !exclusions.isEmpty() ) - { - if ( managedExclusions == this.managedExclusions ) - { - managedExclusions = new HashMap<Object, Collection<Exclusion>>( this.managedExclusions ); - } - Collection<Exclusion> managed = managedExclusions.get( key ); - if ( managed == null ) - { - managed = new LinkedHashSet<Exclusion>(); - managedExclusions.put( key, managed ); - } - managed.addAll( exclusions ); - } - } - - return new ClassicDependencyManager( depth + 1, managedVersions, managedScopes, managedOptionals, - managedLocalPaths, managedExclusions ); - } - - public DependencyManagement manageDependency( Dependency dependency ) - { - DependencyManagement management = null; - - Object key = getKey( dependency.getArtifact() ); - - if ( depth >= 2 ) - { - String version = managedVersions.get( key ); - if ( version != null ) - { - if ( management == null ) - { - management = new DependencyManagement(); - } - management.setVersion( version ); - } - - String scope = managedScopes.get( key ); - if ( scope != null ) - { - if ( management == null ) - { - management = new DependencyManagement(); - } - management.setScope( scope ); - - if ( !JavaScopes.SYSTEM.equals( scope ) - && dependency.getArtifact().getProperty( ArtifactProperties.LOCAL_PATH, null ) != null ) - { - Map<String, String> properties = - new HashMap<String, String>( dependency.getArtifact().getProperties() ); - properties.remove( ArtifactProperties.LOCAL_PATH ); - management.setProperties( properties ); - } - } - - if ( ( scope != null && JavaScopes.SYSTEM.equals( scope ) ) - || ( scope == null && JavaScopes.SYSTEM.equals( dependency.getScope() ) ) ) - { - String localPath = managedLocalPaths.get( key ); - if ( localPath != null ) - { - if ( management == null ) - { - management = new DependencyManagement(); - } - Map<String, String> properties = - new HashMap<String, String>( dependency.getArtifact().getProperties() ); - properties.put( ArtifactProperties.LOCAL_PATH, localPath ); - management.setProperties( properties ); - } - } - - Boolean optional = managedOptionals.get( key ); - if ( optional != null ) - { - if ( management == null ) - { - management = new DependencyManagement(); - } - management.setOptional( optional ); - } - } - - Collection<Exclusion> exclusions = managedExclusions.get( key ); - if ( exclusions != null ) - { - if ( management == null ) - { - management = new DependencyManagement(); - } - Collection<Exclusion> result = new LinkedHashSet<Exclusion>( dependency.getExclusions() ); - result.addAll( exclusions ); - management.setExclusions( result ); - } - - return management; - } - - private Object getKey( Artifact a ) - { - return new Key( a ); - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - else if ( null == obj || !getClass().equals( obj.getClass() ) ) - { - return false; - } - - ClassicDependencyManager that = (ClassicDependencyManager) obj; - return depth == that.depth && managedVersions.equals( that.managedVersions ) - && managedScopes.equals( that.managedScopes ) && managedOptionals.equals( that.managedOptionals ) - && managedExclusions.equals( that.managedExclusions ); - } - - @Override - public int hashCode() - { - if ( hashCode == 0 ) - { - int hash = 17; - hash = hash * 31 + depth; - hash = hash * 31 + managedVersions.hashCode(); - hash = hash * 31 + managedScopes.hashCode(); - hash = hash * 31 + managedOptionals.hashCode(); - hash = hash * 31 + managedExclusions.hashCode(); - hashCode = hash; - } - return hashCode; - } - - static class Key - { - - private final Artifact artifact; - - private final int hashCode; - - public Key( Artifact artifact ) - { - this.artifact = artifact; - - int hash = 17; - hash = hash * 31 + artifact.getGroupId().hashCode(); - hash = hash * 31 + artifact.getArtifactId().hashCode(); - hashCode = hash; - } - - @Override - public boolean equals( Object obj ) - { - if ( obj == this ) - { - return true; - } - else if ( !( obj instanceof Key ) ) - { - return false; - } - Key that = (Key) obj; - return artifact.getArtifactId().equals( that.artifact.getArtifactId() ) - && artifact.getGroupId().equals( that.artifact.getGroupId() ) - && artifact.getExtension().equals( that.artifact.getExtension() ) - && artifact.getClassifier().equals( that.artifact.getClassifier() ); - } - - @Override - public int hashCode() - { - return hashCode; - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/DependencyManagerUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/DependencyManagerUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/DependencyManagerUtils.java deleted file mode 100644 index 7719096..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/DependencyManagerUtils.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.eclipse.aether.util.graph.manager; - -/* - * 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.graph.DependencyNode; - -/** - * A utility class assisting in analyzing the effects of dependency management. - */ -public final class DependencyManagerUtils -{ - - /** - * The key in the repository session's {@link RepositorySystemSession#getConfigProperties() configuration - * properties} used to store a {@link Boolean} flag controlling the verbose mode for dependency management. If - * enabled, the original attributes of a dependency before its update due to dependency managemnent will be recorded - * in the node's {@link DependencyNode#getData() custom data} when building a dependency graph. - */ - public static final String CONFIG_PROP_VERBOSE = "aether.dependencyManager.verbose"; - - /** - * The key in the dependency node's {@link DependencyNode#getData() custom data} under which the original version is - * stored. - */ - public static final String NODE_DATA_PREMANAGED_VERSION = "premanaged.version"; - - /** - * The key in the dependency node's {@link DependencyNode#getData() custom data} under which the original scope is - * stored. - */ - public static final String NODE_DATA_PREMANAGED_SCOPE = "premanaged.scope"; - - /** - * The key in the dependency node's {@link DependencyNode#getData() custom data} under which the original optional - * flag is stored. - */ - public static final String NODE_DATA_PREMANAGED_OPTIONAL = "premanaged.optional"; - - /** - * Gets the version or version range of the specified dependency node before dependency management was applied (if - * any). - * - * @param node The dependency node to retrieve the premanaged data for, must not be {@code null}. - * @return The node's dependency version before dependency management or {@code null} if the version was not managed - * or if {@link #CONFIG_PROP_VERBOSE} was not enabled. - */ - public static String getPremanagedVersion( DependencyNode node ) - { - if ( ( node.getManagedBits() & DependencyNode.MANAGED_VERSION ) == 0 ) - { - return null; - } - return cast( node.getData().get( NODE_DATA_PREMANAGED_VERSION ), String.class ); - } - - /** - * Gets the scope of the specified dependency node before dependency management was applied (if any). - * - * @param node The dependency node to retrieve the premanaged data for, must not be {@code null}. - * @return The node's dependency scope before dependency management or {@code null} if the scope was not managed or - * if {@link #CONFIG_PROP_VERBOSE} was not enabled. - */ - public static String getPremanagedScope( DependencyNode node ) - { - if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) == 0 ) - { - return null; - } - return cast( node.getData().get( NODE_DATA_PREMANAGED_SCOPE ), String.class ); - } - - /** - * Gets the optional flag of the specified dependency node before dependency management was applied (if any). - * - * @param node The dependency node to retrieve the premanaged data for, must not be {@code null}. - * @return The node's optional flag before dependency management or {@code null} if the flag was not managed or if - * {@link #CONFIG_PROP_VERBOSE} was not enabled. - */ - public static Boolean getPremanagedOptional( DependencyNode node ) - { - if ( ( node.getManagedBits() & DependencyNode.MANAGED_OPTIONAL ) == 0 ) - { - return null; - } - return cast( node.getData().get( NODE_DATA_PREMANAGED_OPTIONAL ), Boolean.class ); - } - - private static <T> T cast( Object obj, Class<T> type ) - { - return type.isInstance( obj ) ? type.cast( obj ) : null; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/NoopDependencyManager.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/NoopDependencyManager.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/NoopDependencyManager.java deleted file mode 100644 index ae8ee40..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/NoopDependencyManager.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.aether.util.graph.manager; - -/* - * 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.DependencyManagement; -import org.eclipse.aether.collection.DependencyManager; -import org.eclipse.aether.graph.Dependency; - -/** - * A dependency manager that does not do any dependency management. - */ -public final class NoopDependencyManager - implements DependencyManager -{ - - /** - * A ready-made instance of this dependency manager which can safely be reused throughout an entire application - * regardless of multi-threading. - */ - public static final DependencyManager INSTANCE = new NoopDependencyManager(); - - /** - * Creates a new instance of this dependency manager. Usually, {@link #INSTANCE} should be used instead. - */ - public NoopDependencyManager() - { - } - - public DependencyManager deriveChildManager( DependencyCollectionContext context ) - { - return this; - } - - public DependencyManagement manageDependency( Dependency dependency ) - { - return null; - } - - @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/manager/package-info.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/package-info.java deleted file mode 100644 index 7c7ae12..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/graph/manager/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 managers for building a dependency graph. - */ -package org.eclipse.aether.util.graph.manager; -