http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemStreamWagon.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemStreamWagon.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemStreamWagon.java deleted file mode 100644 index 35efca1..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemStreamWagon.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * 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.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.Map; -import java.util.Properties; - -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.InputData; -import org.apache.maven.wagon.OutputData; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.StreamWagon; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.authorization.AuthorizationException; -import org.apache.maven.wagon.resource.Resource; - -/** - */ -public class MemStreamWagon - extends StreamWagon - implements Configurable -{ - - private Map<String, String> fs; - - private Properties headers; - - private Object config; - - public void setConfiguration( Object config ) - { - this.config = config; - } - - public Object getConfiguration() - { - return config; - } - - public void setHttpHeaders( Properties httpHeaders ) - { - headers = httpHeaders; - } - - @Override - protected void openConnectionInternal() - throws ConnectionException, AuthenticationException - { - fs = - MemWagonUtils.openConnection( this, getAuthenticationInfo(), - getProxyInfo( "mem", getRepository().getHost() ), headers ); - } - - @Override - public void closeConnection() - throws ConnectionException - { - fs = null; - } - - private String getData( String resource ) - { - return fs.get( URI.create( resource ).getSchemeSpecificPart() ); - } - - @Override - public boolean resourceExists( String resourceName ) - throws TransferFailedException, AuthorizationException - { - String data = getData( resourceName ); - return data != null; - } - - @Override - public void fillInputData( InputData inputData ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - String data = getData( inputData.getResource().getName() ); - if ( data == null ) - { - throw new ResourceDoesNotExistException( "Missing resource: " + inputData.getResource().getName() ); - } - byte[] bytes; - try - { - bytes = data.getBytes( "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - throw new TransferFailedException( e.getMessage(), e ); - } - inputData.getResource().setContentLength( bytes.length ); - inputData.setInputStream( new ByteArrayInputStream( bytes ) ); - } - - @Override - public void fillOutputData( OutputData outputData ) - throws TransferFailedException - { - outputData.setOutputStream( new ByteArrayOutputStream() ); - } - - @Override - protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output ) - throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException - { - String data; - try - { - data = ( (ByteArrayOutputStream) output ).toString( "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - throw new TransferFailedException( e.getMessage(), e ); - } - fs.put( URI.create( resource.getName() ).getSchemeSpecificPart(), data ); - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagon.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagon.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagon.java deleted file mode 100644 index ec3d7d6..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagon.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * 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.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.Map; -import java.util.Properties; - -import org.apache.maven.wagon.AbstractWagon; -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.InputData; -import org.apache.maven.wagon.OutputData; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.authorization.AuthorizationException; -import org.apache.maven.wagon.events.TransferEvent; -import org.apache.maven.wagon.resource.Resource; - -/** - */ -public class MemWagon - extends AbstractWagon - implements Configurable -{ - - private Map<String, String> fs; - - private Properties headers; - - private Object config; - - public void setConfiguration( Object config ) - { - this.config = config; - } - - public Object getConfiguration() - { - return config; - } - - public void setHttpHeaders( Properties httpHeaders ) - { - headers = httpHeaders; - } - - @Override - protected void openConnectionInternal() - throws ConnectionException, AuthenticationException - { - fs = - MemWagonUtils.openConnection( this, getAuthenticationInfo(), - getProxyInfo( "mem", getRepository().getHost() ), headers ); - } - - @Override - protected void closeConnection() - throws ConnectionException - { - fs = null; - } - - private String getData( String resource ) - { - return fs.get( URI.create( resource ).getSchemeSpecificPart() ); - } - - @Override - public boolean resourceExists( String resourceName ) - throws TransferFailedException, AuthorizationException - { - String data = getData( resourceName ); - return data != null; - } - - public void get( String resourceName, File destination ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - getIfNewer( resourceName, destination, 0 ); - } - - public boolean getIfNewer( String resourceName, File destination, long timestamp ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - Resource resource = new Resource( resourceName ); - fireGetInitiated( resource, destination ); - resource.setLastModified( timestamp ); - getTransfer( resource, destination, getInputStream( resource ) ); - return true; - } - - protected InputStream getInputStream( Resource resource ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - InputData inputData = new InputData(); - inputData.setResource( resource ); - try - { - fillInputData( inputData ); - } - catch ( TransferFailedException e ) - { - fireTransferError( resource, e, TransferEvent.REQUEST_GET ); - cleanupGetTransfer( resource ); - throw e; - } - catch ( ResourceDoesNotExistException e ) - { - fireTransferError( resource, e, TransferEvent.REQUEST_GET ); - cleanupGetTransfer( resource ); - throw e; - } - catch ( AuthorizationException e ) - { - fireTransferError( resource, e, TransferEvent.REQUEST_GET ); - cleanupGetTransfer( resource ); - throw e; - } - finally - { - if ( inputData.getInputStream() == null ) - { - cleanupGetTransfer( resource ); - } - } - return inputData.getInputStream(); - } - - protected void fillInputData( InputData inputData ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - String data = getData( inputData.getResource().getName() ); - if ( data == null ) - { - throw new ResourceDoesNotExistException( "Missing resource: " + inputData.getResource().getName() ); - } - byte[] bytes; - try - { - bytes = data.getBytes( "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - throw new TransferFailedException( e.getMessage(), e ); - } - inputData.getResource().setContentLength( bytes.length ); - inputData.setInputStream( new ByteArrayInputStream( bytes ) ); - } - - public void put( File source, String resourceName ) - throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException - { - Resource resource = new Resource( resourceName ); - firePutInitiated( resource, source ); - resource.setContentLength( source.length() ); - resource.setLastModified( source.lastModified() ); - OutputStream os = getOutputStream( resource ); - putTransfer( resource, source, os, true ); - } - - protected OutputStream getOutputStream( Resource resource ) - throws TransferFailedException - { - OutputData outputData = new OutputData(); - outputData.setResource( resource ); - try - { - fillOutputData( outputData ); - } - catch ( TransferFailedException e ) - { - fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); - throw e; - } - finally - { - if ( outputData.getOutputStream() == null ) - { - cleanupPutTransfer( resource ); - } - } - - return outputData.getOutputStream(); - } - - protected void fillOutputData( OutputData outputData ) - throws TransferFailedException - { - outputData.setOutputStream( new ByteArrayOutputStream() ); - } - - @Override - protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output ) - throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException - { - String data; - try - { - data = ( (ByteArrayOutputStream) output ).toString( "UTF-8" ); - } - catch ( UnsupportedEncodingException e ) - { - throw new TransferFailedException( e.getMessage(), e ); - } - fs.put( URI.create( resource.getName() ).getSchemeSpecificPart(), data ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagonUtils.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagonUtils.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagonUtils.java deleted file mode 100644 index 86d2cc7..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/MemWagonUtils.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * 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.net.URI; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.proxy.ProxyInfo; - -/** - */ -class MemWagonUtils -{ - - private static final ConcurrentMap<String, Map<String, String>> mounts = - new ConcurrentHashMap<String, Map<String, String>>(); - - public static Map<String, String> getFilesystem( String id ) - { - Map<String, String> fs = mounts.get( id ); - if ( fs == null ) - { - fs = new ConcurrentHashMap<String, String>(); - Map<String, String> prev = mounts.putIfAbsent( id, fs ); - if ( prev != null ) - { - fs = prev; - } - } - return fs; - } - - public static Map<String, String> openConnection( Wagon wagon, AuthenticationInfo auth, ProxyInfo proxy, - Properties headers ) - throws ConnectionException, AuthenticationException - { - URI uri = URI.create( wagon.getRepository().getUrl() ); - - String query = uri.getQuery(); - if ( query != null ) - { - verify( query, "config", String.valueOf( ( (Configurable) wagon ).getConfiguration() ) ); - - verify( query, "userAgent", ( headers != null ) ? headers.getProperty( "User-Agent" ) : null ); - verify( query, "requestTimeout", Integer.toString( wagon.getTimeout() ) ); - - verify( query, "serverUsername", ( auth != null ) ? auth.getUserName() : null ); - verify( query, "serverPassword", ( auth != null ) ? auth.getPassword() : null ); - verify( query, "serverPrivateKey", ( auth != null ) ? auth.getPrivateKey() : null ); - verify( query, "serverPassphrase", ( auth != null ) ? auth.getPassphrase() : null ); - - verify( query, "proxyHost", ( proxy != null ) ? proxy.getHost() : null ); - verify( query, "proxyPort", ( proxy != null ) ? Integer.toString( proxy.getPort() ) : null ); - verify( query, "proxyUsername", ( proxy != null ) ? proxy.getUserName() : null ); - verify( query, "proxyPassword", ( proxy != null ) ? proxy.getPassword() : null ); - } - - return getFilesystem( uri.getHost() ); - } - - private static void verify( String query, String key, String value ) - throws ConnectionException - { - int index = query.indexOf( key + "=" ); - if ( index < 0 ) - { - return; - } - String expected = query.substring( index + key.length() + 1 ); - index = expected.indexOf( "&" ); - if ( index >= 0 ) - { - expected = expected.substring( 0, index ); - } - - if ( expected.length() == 0 ) - { - if ( value != null ) - { - throw new ConnectionException( "Bad " + key + ": " + value ); - } - } - else if ( !expected.equals( value ) ) - { - throw new ConnectionException( "Bad " + key + ": " + value ); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/PlexusSupportTest.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/PlexusSupportTest.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/PlexusSupportTest.java deleted file mode 100644 index 231fa95..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/PlexusSupportTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * 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.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.aether.internal.test.util.TestLoggerFactory; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.spi.log.LoggerFactory; - -/** - */ -public class PlexusSupportTest - extends PlexusTestCase -{ - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) - { - containerConfiguration.setClassPathScanning( "cache" ); - } - - public void testExistenceOfPlexusComponentMetadata() - throws Exception - { - getContainer().addComponent( new TestLoggerFactory(), LoggerFactory.class, null ); - - TransporterFactory factory = lookup( TransporterFactory.class, "wagon" ); - assertNotNull( factory ); - assertEquals( WagonTransporterFactory.class, factory.getClass() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java deleted file mode 100644 index 7f61985..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/RecordingTransportListener.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * 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.ByteArrayOutputStream; -import java.nio.ByteBuffer; - -import org.eclipse.aether.spi.connector.transport.TransportListener; -import org.eclipse.aether.transfer.TransferCancelledException; - -class RecordingTransportListener - extends TransportListener -{ - - public final ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 ); - - public long dataOffset; - - public long dataLength; - - public int startedCount; - - public int progressedCount; - - public boolean cancelStart; - - public boolean cancelProgress; - - @Override - public void transportStarted( long dataOffset, long dataLength ) - throws TransferCancelledException - { - startedCount++; - progressedCount = 0; - this.dataLength = dataLength; - this.dataOffset = dataOffset; - baos.reset(); - if ( cancelStart ) - { - throw new TransferCancelledException(); - } - } - - @Override - public void transportProgressed( ByteBuffer data ) - throws TransferCancelledException - { - progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); - if ( cancelProgress ) - { - throw new TransferCancelledException(); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/StreamWagonTransporterTest.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/StreamWagonTransporterTest.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/StreamWagonTransporterTest.java deleted file mode 100644 index c3f3fd4..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/StreamWagonTransporterTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.wagon.Wagon; - -/** - */ -public class StreamWagonTransporterTest - extends AbstractWagonTransporterTest -{ - - @Override - protected Wagon newWagon() - { - return new MemStreamWagon(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/WagonTransporterTest.java ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/WagonTransporterTest.java b/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/WagonTransporterTest.java deleted file mode 100644 index 5a10399..0000000 --- a/aether-transport-wagon/src/test/java/org/eclipse/aether/transport/wagon/WagonTransporterTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.eclipse.aether.transport.wagon; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.wagon.Wagon; - -/** - */ -public class WagonTransporterTest - extends AbstractWagonTransporterTest -{ - - @Override - protected Wagon newWagon() - { - return new MemWagon(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-wagon/src/test/resources/logback-test.xml ---------------------------------------------------------------------- diff --git a/aether-transport-wagon/src/test/resources/logback-test.xml b/aether-transport-wagon/src/test/resources/logback-test.xml deleted file mode 100644 index d031998..0000000 --- a/aether-transport-wagon/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - ! Licensed to the Apache Software Foundation (ASF) under one - ! or more contributor license agreements. See the NOTICE file - ! distributed with this work for additional information - ! regarding copyright ownership. The ASF licenses this file - ! to you under the Apache License, Version 2.0 (the - ! "License"); you may not use this file except in compliance - ! with the License. You may obtain a copy of the License at - ! - ! http://www.apache.org/licenses/LICENSE-2.0 - ! - ! Unless required by applicable law or agreed to in writing, - ! software distributed under the License is distributed on an - ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ! KIND, either express or implied. See the License for the - ! specific language governing permissions and limitations - ! under the License. - !--> - -<configuration> - <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>%d{HH:mm:ss.SSS} [%-18thread] %c{1} [%p] %m%n</pattern> - </encoder> - </appender> - - <logger name="org.sonatype.tests.jetty.server" level="INFO"/> - <logger name="org.sonatype.tests.jetty.server.behaviour" level="DEBUG"/> - <logger name="org.sonatype.tests" level="DEBUG"/> - - <root level="WARN"> - <appender-ref ref="CONSOLE"/> - </root> -</configuration> http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/pom.xml ---------------------------------------------------------------------- diff --git a/aether-util/pom.xml b/aether-util/pom.xml deleted file mode 100644 index 39b5472..0000000 --- a/aether-util/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether</artifactId> - <version>1.0.3-SNAPSHOT</version> - </parent> - - <artifactId>aether-util</artifactId> - - <name>Aether Utilities</name> - <description> - A collection of utility classes to ease usage of the repository system. - </description> - - <dependencies> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-test-util</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/ChecksumUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/ChecksumUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/ChecksumUtils.java deleted file mode 100644 index b629c8d..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/ChecksumUtils.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.eclipse.aether.util; - -/* - * 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.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * A utility class to assist in the verification and generation of checksums. - */ -public final class ChecksumUtils -{ - - private ChecksumUtils() - { - // hide constructor - } - - /** - * Extracts the checksum from the specified file. - * - * @param checksumFile The path to the checksum file, must not be {@code null}. - * @return The checksum stored in the file, never {@code null}. - * @throws IOException If the checksum does not exist or could not be read for other reasons. - */ - public static String read( File checksumFile ) - throws IOException - { - String checksum = ""; - - FileInputStream fis = new FileInputStream( checksumFile ); - try - { - BufferedReader br = new BufferedReader( new InputStreamReader( fis, "UTF-8" ), 512 ); - try - { - while ( true ) - { - String line = br.readLine(); - if ( line == null ) - { - break; - } - line = line.trim(); - if ( line.length() > 0 ) - { - checksum = line; - break; - } - } - } - finally - { - try - { - br.close(); - } - catch ( IOException e ) - { - // ignored - } - } - } - finally - { - try - { - fis.close(); - } - catch ( IOException e ) - { - // ignored - } - } - - if ( checksum.matches( ".+= [0-9A-Fa-f]+" ) ) - { - int lastSpacePos = checksum.lastIndexOf( ' ' ); - checksum = checksum.substring( lastSpacePos + 1 ); - } - else - { - int spacePos = checksum.indexOf( ' ' ); - - if ( spacePos != -1 ) - { - checksum = checksum.substring( 0, spacePos ); - } - } - - return checksum; - } - - /** - * Calculates checksums for the specified file. - * - * @param dataFile The file for which to calculate checksums, must not be {@code null}. - * @param algos The names of checksum algorithms (cf. {@link MessageDigest#getInstance(String)} to use, must not be - * {@code null}. - * @return The calculated checksums, indexed by algorithm name, or the exception that occurred while trying to - * calculate it, never {@code null}. - * @throws IOException If the data file could not be read. - */ - public static Map<String, Object> calc( File dataFile, Collection<String> algos ) - throws IOException - { - Map<String, Object> results = new LinkedHashMap<String, Object>(); - - Map<String, MessageDigest> digests = new LinkedHashMap<String, MessageDigest>(); - for ( String algo : algos ) - { - try - { - digests.put( algo, MessageDigest.getInstance( algo ) ); - } - catch ( NoSuchAlgorithmException e ) - { - results.put( algo, e ); - } - } - - FileInputStream fis = new FileInputStream( dataFile ); - try - { - for ( byte[] buffer = new byte[32 * 1024];; ) - { - int read = fis.read( buffer ); - if ( read < 0 ) - { - break; - } - for ( MessageDigest digest : digests.values() ) - { - digest.update( buffer, 0, read ); - } - } - } - finally - { - try - { - fis.close(); - } - catch ( IOException e ) - { - // ignored - } - } - - for ( Map.Entry<String, MessageDigest> entry : digests.entrySet() ) - { - byte[] bytes = entry.getValue().digest(); - - results.put( entry.getKey(), toHexString( bytes ) ); - } - - return results; - } - - /** - * Creates a hexadecimal representation of the specified bytes. Each byte is converted into a two-digit hex number - * and appended to the result with no separator between consecutive bytes. - * - * @param bytes The bytes to represent in hex notation, may be be {@code null}. - * @return The hexadecimal representation of the input or {@code null} if the input was {@code null}. - */ - public static String toHexString( byte[] bytes ) - { - if ( bytes == null ) - { - return null; - } - - StringBuilder buffer = new StringBuilder( bytes.length * 2 ); - - for ( byte aByte : bytes ) - { - int b = aByte & 0xFF; - if ( b < 0x10 ) - { - buffer.append( '0' ); - } - buffer.append( Integer.toHexString( b ) ); - } - - return buffer.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/ConfigUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/ConfigUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/ConfigUtils.java deleted file mode 100644 index 2f53856..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/ConfigUtils.java +++ /dev/null @@ -1,392 +0,0 @@ -package org.eclipse.aether.util; - -/* - * 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.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.eclipse.aether.RepositorySystemSession; - -/** - * A utility class to read configuration properties from a repository system session. - * - * @see RepositorySystemSession#getConfigProperties() - */ -public final class ConfigUtils -{ - - private ConfigUtils() - { - // hide constructor - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys are set, may be {@code null}. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a valid value is found. - * @return The property value or {@code null} if none. - */ - public static Object getObject( Map<?, ?> properties, Object defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value != null ) - { - return value; - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys are set, may be {@code null}. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a valid value is found. - * @return The property value or {@code null} if none. - */ - public static Object getObject( RepositorySystemSession session, Object defaultValue, String... keys ) - { - return getObject( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a string, may be - * {@code null}. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a string value is found. - * @return The property value or {@code null} if none. - */ - public static String getString( Map<?, ?> properties, String defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof String ) - { - return (String) value; - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a string, may be - * {@code null}. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a string value is found. - * @return The property value or {@code null} if none. - */ - public static String getString( RepositorySystemSession session, String defaultValue, String... keys ) - { - return getString( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of an {@link Integer} is found. - * @return The property value. - */ - public static int getInteger( Map<?, ?> properties, int defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof Number ) - { - return ( (Number) value ).intValue(); - } - - try - { - return Integer.valueOf( (String) value ); - } - catch ( Exception e ) - { - // try next key - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of an {@link Integer} is found. - * @return The property value. - */ - public static int getInteger( RepositorySystemSession session, int defaultValue, String... keys ) - { - return getInteger( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of a {@link Long} is found. - * @return The property value. - */ - public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof Number ) - { - return ( (Number) value ).longValue(); - } - - try - { - return Long.valueOf( (String) value ); - } - catch ( Exception e ) - { - // try next key - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of a {@link Long} is found. - * @return The property value. - */ - public static long getLong( RepositorySystemSession session, long defaultValue, String... keys ) - { - return getLong( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of a {@link Float} is found. - * @return The property value. - */ - public static float getFloat( Map<?, ?> properties, float defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof Number ) - { - return ( (Number) value ).floatValue(); - } - - try - { - return Float.valueOf( (String) value ); - } - catch ( Exception e ) - { - // try next key - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a number. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Number} or a string representation of a {@link Float} is found. - * @return The property value. - */ - public static float getFloat( RepositorySystemSession session, float defaultValue, String... keys ) - { - return getFloat( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a boolean. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Boolean} or a string (to be {@link Boolean#parseBoolean(String) parsed as boolean}) is found. - * @return The property value. - */ - public static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof Boolean ) - { - return (Boolean) value; - } - else if ( value instanceof String ) - { - return Boolean.parseBoolean( (String) value ); - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a boolean. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a {@link Boolean} or a string (to be {@link Boolean#parseBoolean(String) parsed as boolean}) is found. - * @return The property value. - */ - public static boolean getBoolean( RepositorySystemSession session, boolean defaultValue, String... keys ) - { - return getBoolean( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a collection. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a collection is found. - * @return The property value or {@code null} if none. - */ - public static List<?> getList( Map<?, ?> properties, List<?> defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof List ) - { - return (List<?>) value; - } - else if ( value instanceof Collection ) - { - return Collections.unmodifiableList( new ArrayList<Object>( (Collection<?>) value ) ); - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a collection. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a collection is found. - * @return The property value or {@code null} if none. - */ - public static List<?> getList( RepositorySystemSession session, List<?> defaultValue, String... keys ) - { - return getList( session.getConfigProperties(), defaultValue, keys ); - } - - /** - * Gets the specified configuration property. - * - * @param properties The configuration properties to read, must not be {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a map. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a map is found. - * @return The property value or {@code null} if none. - */ - public static Map<?, ?> getMap( Map<?, ?> properties, Map<?, ?> defaultValue, String... keys ) - { - for ( String key : keys ) - { - Object value = properties.get( key ); - - if ( value instanceof Map ) - { - return (Map<?, ?>) value; - } - } - - return defaultValue; - } - - /** - * Gets the specified configuration property. - * - * @param session The repository system session from which to read the configuration property, must not be - * {@code null}. - * @param defaultValue The default value to return in case none of the property keys is set to a map. - * @param keys The property keys to read, must not be {@code null}. The specified keys are read one after one until - * a map is found. - * @return The property value or {@code null} if none. - */ - public static Map<?, ?> getMap( RepositorySystemSession session, Map<?, ?> defaultValue, String... keys ) - { - return getMap( session.getConfigProperties(), defaultValue, keys ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/StringUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/StringUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/StringUtils.java deleted file mode 100644 index e0ed12a..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/StringUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.eclipse.aether.util; - -/* - * 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. - */ - -/** - * A utility class to ease string processing. - */ -public final class StringUtils -{ - - private StringUtils() - { - // hide constructor - } - - /** - * Checks whether a string is {@code null} or of zero length. - * - * @param string The string to check, may be {@code null}. - * @return {@code true} if the string is {@code null} or of zero length, {@code false} otherwise. - */ - public static boolean isEmpty( String string ) - { - return string == null || string.length() <= 0; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java deleted file mode 100644 index 54ffc64..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java +++ /dev/null @@ -1,269 +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 org.eclipse.aether.artifact.Artifact; - -/** - * A utility class for artifact identifiers. - */ -public final class ArtifactIdUtils -{ - - private static final char SEP = ':'; - - private ArtifactIdUtils() - { - // hide constructor - } - - /** - * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. - * - * @param artifact The artifact to create an identifer for, may be {@code null}. - * @return The artifact identifier or {@code null} if the input was {@code null}. - */ - public static String toId( Artifact artifact ) - { - String id = null; - if ( artifact != null ) - { - id = - toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), - artifact.getClassifier(), artifact.getVersion() ); - } - return id; - } - - /** - * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. - * - * @param groupId The group id, may be {@code null}. - * @param artifactId The artifact id, may be {@code null}. - * @param extension The file extensiion, may be {@code null}. - * @param classifier The classifier, may be {@code null}. - * @param version The version, may be {@code null}. - * @return The artifact identifier, never {@code null}. - */ - public static String toId( String groupId, String artifactId, String extension, String classifier, String version ) - { - StringBuilder buffer = concat( groupId, artifactId, extension, classifier ); - buffer.append( SEP ); - if ( version != null ) - { - buffer.append( version ); - } - return buffer.toString(); - } - - /** - * Creates an artifact identifier of the form - * {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<baseVersion>}. - * - * @param artifact The artifact to create an identifer for, may be {@code null}. - * @return The artifact identifier or {@code null} if the input was {@code null}. - */ - public static String toBaseId( Artifact artifact ) - { - String id = null; - if ( artifact != null ) - { - id = - toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), - artifact.getClassifier(), artifact.getBaseVersion() ); - } - return id; - } - - /** - * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]}. - * - * @param artifact The artifact to create an identifer for, may be {@code null}. - * @return The artifact identifier or {@code null} if the input was {@code null}. - */ - public static String toVersionlessId( Artifact artifact ) - { - String id = null; - if ( artifact != null ) - { - id = - toVersionlessId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), - artifact.getClassifier() ); - } - return id; - } - - /** - * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]}. - * - * @param groupId The group id, may be {@code null}. - * @param artifactId The artifact id, may be {@code null}. - * @param extension The file extensiion, may be {@code null}. - * @param classifier The classifier, may be {@code null}. - * @return The artifact identifier, never {@code null}. - */ - public static String toVersionlessId( String groupId, String artifactId, String extension, String classifier ) - { - return concat( groupId, artifactId, extension, classifier ).toString(); - } - - private static StringBuilder concat( String groupId, String artifactId, String extension, String classifier ) - { - StringBuilder buffer = new StringBuilder( 128 ); - - if ( groupId != null ) - { - buffer.append( groupId ); - } - buffer.append( SEP ); - if ( artifactId != null ) - { - buffer.append( artifactId ); - } - buffer.append( SEP ); - if ( extension != null ) - { - buffer.append( extension ); - } - if ( classifier != null && classifier.length() > 0 ) - { - buffer.append( SEP ).append( classifier ); - } - - return buffer; - } - - /** - * Determines whether two artifacts have the same identifier. This method is equivalent to calling - * {@link String#equals(Object)} on the return values from {@link #toId(Artifact)} for the artifacts but does not - * incur the overhead of creating temporary strings. - * - * @param artifact1 The first artifact, may be {@code null}. - * @param artifact2 The second artifact, may be {@code null}. - * @return {@code true} if both artifacts are not {@code null} and have equal ids, {@code false} otherwise. - */ - public static boolean equalsId( Artifact artifact1, Artifact artifact2 ) - { - if ( artifact1 == null || artifact2 == null ) - { - return false; - } - if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) ) - { - return false; - } - if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) ) - { - return false; - } - if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) ) - { - return false; - } - if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) ) - { - return false; - } - if ( !eq( artifact1.getVersion(), artifact2.getVersion() ) ) - { - return false; - } - return true; - } - - /** - * Determines whether two artifacts have the same base identifier. This method is equivalent to calling - * {@link String#equals(Object)} on the return values from {@link #toBaseId(Artifact)} for the artifacts but does - * not incur the overhead of creating temporary strings. - * - * @param artifact1 The first artifact, may be {@code null}. - * @param artifact2 The second artifact, may be {@code null}. - * @return {@code true} if both artifacts are not {@code null} and have equal base ids, {@code false} otherwise. - */ - public static boolean equalsBaseId( Artifact artifact1, Artifact artifact2 ) - { - if ( artifact1 == null || artifact2 == null ) - { - return false; - } - if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) ) - { - return false; - } - if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) ) - { - return false; - } - if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) ) - { - return false; - } - if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) ) - { - return false; - } - if ( !eq( artifact1.getBaseVersion(), artifact2.getBaseVersion() ) ) - { - return false; - } - return true; - } - - /** - * Determines whether two artifacts have the same versionless identifier. This method is equivalent to calling - * {@link String#equals(Object)} on the return values from {@link #toVersionlessId(Artifact)} for the artifacts but - * does not incur the overhead of creating temporary strings. - * - * @param artifact1 The first artifact, may be {@code null}. - * @param artifact2 The second artifact, may be {@code null}. - * @return {@code true} if both artifacts are not {@code null} and have equal versionless ids, {@code false} - * otherwise. - */ - public static boolean equalsVersionlessId( Artifact artifact1, Artifact artifact2 ) - { - if ( artifact1 == null || artifact2 == null ) - { - return false; - } - if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) ) - { - return false; - } - if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) ) - { - return false; - } - if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) ) - { - return false; - } - if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) ) - { - return false; - } - return true; - } - - private static <T> boolean eq( T s1, T s2 ) - { - return s1 != null ? s1.equals( s2 ) : s2 == null; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/DefaultArtifactTypeRegistry.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/DefaultArtifactTypeRegistry.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/DefaultArtifactTypeRegistry.java deleted file mode 100644 index 9fb29af..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/DefaultArtifactTypeRegistry.java +++ /dev/null @@ -1,51 +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 org.eclipse.aether.artifact.ArtifactType; - -/** - * A simple artifact type registry. - */ -public final class DefaultArtifactTypeRegistry - extends SimpleArtifactTypeRegistry -{ - - /** - * Creates a new artifact type registry with initally no registered artifact types. Use {@link #add(ArtifactType)} - * to populate the registry. - */ - public DefaultArtifactTypeRegistry() - { - } - - /** - * Adds the specified artifact type to the registry. - * - * @param type The artifact type to add, must not be {@code null}. - * @return This registry for chaining, never {@code null}. - */ - public DefaultArtifactTypeRegistry add( ArtifactType type ) - { - super.add( type ); - return this; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java deleted file mode 100644 index 8816ae5..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java +++ /dev/null @@ -1,169 +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 that delegates to another artifact instance. This class serves as a base for subclasses that want to - * carry additional data fields. - */ -public abstract class DelegatingArtifact - extends AbstractArtifact -{ - - private final Artifact delegate; - - /** - * Creates a new artifact instance that delegates to the specified artifact. - * - * @param delegate The artifact to delegate to, must not be {@code null}. - */ - protected DelegatingArtifact( Artifact delegate ) - { - if ( delegate == null ) - { - throw new IllegalArgumentException( "delegate artifact not specified" ); - } - this.delegate = delegate; - } - - /** - * Creates a new artifact instance that delegates to the specified artifact. Subclasses should use this hook to - * instantiate themselves, taking along any data from the current instance that was added. - * - * @param delegate The artifact to delegate to, must not be {@code null}. - * @return The new delegating artifact, never {@code null}. - */ - protected abstract DelegatingArtifact newInstance( Artifact delegate ); - - public String getGroupId() - { - return delegate.getGroupId(); - } - - public String getArtifactId() - { - return delegate.getArtifactId(); - } - - public String getVersion() - { - return delegate.getVersion(); - } - - public Artifact setVersion( String version ) - { - Artifact artifact = delegate.setVersion( version ); - if ( artifact != delegate ) - { - return newInstance( artifact ); - } - return this; - } - - public String getBaseVersion() - { - return delegate.getBaseVersion(); - } - - public boolean isSnapshot() - { - return delegate.isSnapshot(); - } - - public String getClassifier() - { - return delegate.getClassifier(); - } - - public String getExtension() - { - return delegate.getExtension(); - } - - public File getFile() - { - return delegate.getFile(); - } - - public Artifact setFile( File file ) - { - Artifact artifact = delegate.setFile( file ); - if ( artifact != delegate ) - { - return newInstance( artifact ); - } - return this; - } - - public String getProperty( String key, String defaultValue ) - { - return delegate.getProperty( key, defaultValue ); - } - - public Map<String, String> getProperties() - { - return delegate.getProperties(); - } - - public Artifact setProperties( Map<String, String> properties ) - { - Artifact artifact = delegate.setProperties( properties ); - if ( artifact != delegate ) - { - return newInstance( artifact ); - } - return this; - } - - @Override - public boolean equals( Object obj ) - { - if ( obj == this ) - { - return true; - } - - if ( obj instanceof DelegatingArtifact ) - { - return delegate.equals( ( (DelegatingArtifact) obj ).delegate ); - } - - return delegate.equals( obj ); - } - - @Override - public int hashCode() - { - return delegate.hashCode(); - } - - @Override - public String toString() - { - return delegate.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java deleted file mode 100644 index bf4894c..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java +++ /dev/null @@ -1,45 +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. - */ - -/** - * The dependency scopes used for Java dependencies. - * - * @see org.eclipse.aether.graph.Dependency#getScope() - */ -public final class JavaScopes -{ - - public static final String COMPILE = "compile"; - - public static final String PROVIDED = "provided"; - - public static final String SYSTEM = "system"; - - public static final String RUNTIME = "runtime"; - - public static final String TEST = "test"; - - private JavaScopes() - { - // hide constructor - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/OverlayArtifactTypeRegistry.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/OverlayArtifactTypeRegistry.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/OverlayArtifactTypeRegistry.java deleted file mode 100644 index 6768b16..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/OverlayArtifactTypeRegistry.java +++ /dev/null @@ -1,70 +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 org.eclipse.aether.artifact.ArtifactType; -import org.eclipse.aether.artifact.ArtifactTypeRegistry; - -/** - * An artifact type registry which first consults its own mappings and in case of an unknown type falls back to another - * type registry. - */ -public final class OverlayArtifactTypeRegistry - extends SimpleArtifactTypeRegistry -{ - - private final ArtifactTypeRegistry delegate; - - /** - * Creates a new artifact type registry with initially no registered artifact types and the specified fallback - * registry. Use {@link #add(ArtifactType)} to populate the registry. - * - * @param delegate The artifact type registry to fall back to, may be {@code null}. - */ - public OverlayArtifactTypeRegistry( ArtifactTypeRegistry delegate ) - { - this.delegate = delegate; - } - - /** - * Adds the specified artifact type to the registry. - * - * @param type The artifact type to add, must not be {@code null}. - * @return This registry for chaining, never {@code null}. - */ - public OverlayArtifactTypeRegistry add( ArtifactType type ) - { - super.add( type ); - return this; - } - - public ArtifactType get( String typeId ) - { - ArtifactType type = super.get( typeId ); - - if ( type == null && delegate != null ) - { - type = delegate.get( typeId ); - } - - return type; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/main/java/org/eclipse/aether/util/artifact/SimpleArtifactTypeRegistry.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/artifact/SimpleArtifactTypeRegistry.java b/aether-util/src/main/java/org/eclipse/aether/util/artifact/SimpleArtifactTypeRegistry.java deleted file mode 100644 index b0bfc9f..0000000 --- a/aether-util/src/main/java/org/eclipse/aether/util/artifact/SimpleArtifactTypeRegistry.java +++ /dev/null @@ -1,71 +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.util.HashMap; -import java.util.Map; - -import org.eclipse.aether.artifact.ArtifactType; -import org.eclipse.aether.artifact.ArtifactTypeRegistry; - -/** - * A simple map-based artifact type registry. - */ -class SimpleArtifactTypeRegistry - implements ArtifactTypeRegistry -{ - - private final Map<String, ArtifactType> types; - - /** - * Creates a new artifact type registry with initally no registered artifact types. Use {@link #add(ArtifactType)} - * to populate the registry. - */ - public SimpleArtifactTypeRegistry() - { - types = new HashMap<String, ArtifactType>(); - } - - /** - * Adds the specified artifact type to the registry. - * - * @param type The artifact type to add, must not be {@code null}. - * @return This registry for chaining, never {@code null}. - */ - public SimpleArtifactTypeRegistry add( ArtifactType type ) - { - types.put( type.getId(), type ); - return this; - } - - public ArtifactType get( String typeId ) - { - ArtifactType type = types.get( typeId ); - - return type; - } - - @Override - public String toString() - { - return types.toString(); - } - -}
