Bug 433805 - Move all code for Ant tasks into internal package Moved classes into org.eclipse.aether.internal.ant.* packages
Project: http://git-wip-us.apache.org/repos/asf/maven-aether/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-aether/commit/1ec78d99 Tree: http://git-wip-us.apache.org/repos/asf/maven-aether/tree/1ec78d99 Diff: http://git-wip-us.apache.org/repos/asf/maven-aether/diff/1ec78d99 Branch: refs/heads/ant-tasks Commit: 1ec78d99bd97f3d2438e418b6d703606ec083a43 Parents: d981a95 Author: Benjamin Bentmann <[email protected]> Authored: Wed Apr 30 01:37:03 2014 +0200 Committer: Benjamin Bentmann <[email protected]> Committed: Wed Apr 30 01:37:03 2014 +0200 ---------------------------------------------------------------------- pom.xml | 11 +- .../java/org/eclipse/aether/ant/AntLogger.java | 59 -- .../eclipse/aether/ant/AntModelResolver.java | 148 ---- .../java/org/eclipse/aether/ant/AntRepoSys.java | 753 ------------------- .../eclipse/aether/ant/AntSecDispatcher.java | 36 - .../ant/AntServiceLocatorErrorHandler.java | 41 - .../aether/ant/AntSettingsDecryptorFactory.java | 42 -- src/main/java/org/eclipse/aether/ant/Names.java | 33 - .../aether/ant/ProjectWorkspaceReader.java | 135 ---- .../ant/listeners/AntRepositoryListener.java | 114 --- .../ant/listeners/AntTransferListener.java | 82 -- .../aether/ant/tasks/AbstractDistTask.java | 197 ----- .../aether/ant/tasks/AbstractResolvingTask.java | 96 --- .../aether/ant/tasks/DependencyGraphLogger.java | 76 -- .../org/eclipse/aether/ant/tasks/Deploy.java | 120 --- .../org/eclipse/aether/ant/tasks/Install.java | 50 -- .../org/eclipse/aether/ant/tasks/Layout.java | 122 --- .../org/eclipse/aether/ant/tasks/RefTask.java | 89 --- .../org/eclipse/aether/ant/tasks/Resolve.java | 542 ------------- .../org/eclipse/aether/ant/types/Artifact.java | 172 ----- .../aether/ant/types/ArtifactContainer.java | 26 - .../org/eclipse/aether/ant/types/Artifacts.java | 88 --- .../aether/ant/types/Authentication.java | 143 ---- .../eclipse/aether/ant/types/Dependencies.java | 188 ----- .../eclipse/aether/ant/types/Dependency.java | 320 -------- .../aether/ant/types/DependencyContainer.java | 22 - .../org/eclipse/aether/ant/types/Exclusion.java | 181 ----- .../aether/ant/types/LocalRepository.java | 81 -- .../org/eclipse/aether/ant/types/Mirror.java | 145 ---- .../aether/ant/types/ModelValueExtractor.java | 90 --- .../java/org/eclipse/aether/ant/types/Pom.java | 343 --------- .../aether/ant/types/PomPropertyEvaluator.java | 53 -- .../aether/ant/types/PomPropertyHelper.java | 56 -- .../org/eclipse/aether/ant/types/Proxy.java | 154 ---- .../aether/ant/types/RemoteRepositories.java | 88 --- .../aether/ant/types/RemoteRepository.java | 340 --------- .../ant/types/RemoteRepositoryContainer.java | 26 - .../org/eclipse/aether/ant/types/Settings.java | 77 -- .../eclipse/aether/ant/util/AetherUtils.java | 75 -- .../eclipse/aether/ant/util/ConverterUtils.java | 218 ------ .../eclipse/aether/ant/util/SettingsUtils.java | 173 ----- .../eclipse/aether/internal/ant/AntLogger.java | 59 ++ .../aether/internal/ant/AntModelResolver.java | 148 ++++ .../eclipse/aether/internal/ant/AntRepoSys.java | 751 ++++++++++++++++++ .../internal/ant/AntRepositoryListener.java | 114 +++ .../aether/internal/ant/AntSecDispatcher.java | 36 + .../ant/AntServiceLocatorErrorHandler.java | 41 + .../ant/AntSettingsDecryptorFactory.java | 42 ++ .../internal/ant/AntTransferListener.java | 82 ++ .../org/eclipse/aether/internal/ant/Names.java | 33 + .../internal/ant/ProjectWorkspaceReader.java | 135 ++++ .../internal/ant/tasks/AbstractDistTask.java | 197 +++++ .../ant/tasks/AbstractResolvingTask.java | 96 +++ .../ant/tasks/DependencyGraphLogger.java | 76 ++ .../aether/internal/ant/tasks/Deploy.java | 120 +++ .../aether/internal/ant/tasks/Install.java | 50 ++ .../aether/internal/ant/tasks/Layout.java | 122 +++ .../aether/internal/ant/tasks/RefTask.java | 89 +++ .../aether/internal/ant/tasks/Resolve.java | 542 +++++++++++++ .../aether/internal/ant/types/Artifact.java | 172 +++++ .../internal/ant/types/ArtifactContainer.java | 26 + .../aether/internal/ant/types/Artifacts.java | 88 +++ .../internal/ant/types/Authentication.java | 143 ++++ .../aether/internal/ant/types/Dependencies.java | 188 +++++ .../aether/internal/ant/types/Dependency.java | 320 ++++++++ .../internal/ant/types/DependencyContainer.java | 22 + .../aether/internal/ant/types/Exclusion.java | 181 +++++ .../internal/ant/types/LocalRepository.java | 81 ++ .../aether/internal/ant/types/Mirror.java | 145 ++++ .../internal/ant/types/ModelValueExtractor.java | 90 +++ .../eclipse/aether/internal/ant/types/Pom.java | 343 +++++++++ .../ant/types/PomPropertyEvaluator.java | 53 ++ .../internal/ant/types/PomPropertyHelper.java | 56 ++ .../aether/internal/ant/types/Proxy.java | 154 ++++ .../internal/ant/types/RemoteRepositories.java | 88 +++ .../internal/ant/types/RemoteRepository.java | 340 +++++++++ .../ant/types/RemoteRepositoryContainer.java | 26 + .../aether/internal/ant/types/Settings.java | 77 ++ .../aether/internal/ant/util/AetherUtils.java | 75 ++ .../internal/ant/util/ConverterUtils.java | 218 ++++++ .../aether/internal/ant/util/SettingsUtils.java | 173 +++++ .../resources/org/eclipse/aether/ant/antlib.xml | 32 +- .../org/eclipse/aether/ant/AntBuildsTest.java | 114 --- .../java/org/eclipse/aether/ant/DeployTest.java | 82 -- .../org/eclipse/aether/ant/InstallTest.java | 89 --- .../aether/ant/ProjectWorkspaceReaderTest.java | 115 --- .../org/eclipse/aether/ant/ReactorTest.java | 91 --- .../org/eclipse/aether/ant/ResolveTest.java | 123 --- .../org/eclipse/aether/ant/SettingsTest.java | 54 -- .../eclipse/aether/ant/tasks/LayoutTest.java | 46 -- .../aether/ant/types/DependencyTest.java | 79 -- .../eclipse/aether/ant/types/ExclusionTest.java | 79 -- .../org/eclipse/aether/ant/types/PomTest.java | 34 - .../aether/internal/ant/AntBuildsTest.java | 115 +++ .../eclipse/aether/internal/ant/DeployTest.java | 82 ++ .../aether/internal/ant/InstallTest.java | 89 +++ .../ant/ProjectWorkspaceReaderTest.java | 115 +++ .../aether/internal/ant/ReactorTest.java | 91 +++ .../aether/internal/ant/ResolveTest.java | 123 +++ .../aether/internal/ant/SettingsTest.java | 56 ++ .../aether/internal/ant/tasks/LayoutTest.java | 46 ++ .../internal/ant/types/DependencyTest.java | 79 ++ .../internal/ant/types/ExclusionTest.java | 79 ++ .../aether/internal/ant/types/PomTest.java | 34 + 104 files changed, 6723 insertions(+), 6721 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index d225f7e..caa7ab9 100644 --- a/pom.xml +++ b/pom.xml @@ -524,18 +524,19 @@ <relocations> <relocation> <pattern>org.eclipse.aether</pattern> - <shadedPattern>org.eclipse.aether.ant.org.eclipse.aether</shadedPattern> + <shadedPattern>org.eclipse.aether.internal.ant.org.eclipse.aether</shadedPattern> <excludes> <exclude>org.eclipse.aether.ant.**</exclude> + <exclude>org.eclipse.aether.internal.ant.**</exclude> </excludes> </relocation> <relocation> <pattern>org.sonatype.plexus</pattern> - <shadedPattern>org.eclipse.aether.ant.org.sonatype.plexus</shadedPattern> + <shadedPattern>org.eclipse.aether.internal.ant.org.sonatype.plexus</shadedPattern> </relocation> <relocation> <pattern>org.apache</pattern> - <shadedPattern>org.eclipse.aether.ant.org.apache</shadedPattern> + <shadedPattern>org.eclipse.aether.internal.ant.org.apache</shadedPattern> <excludes> <exclude>org.apache.tools.**</exclude> <exclude>org.apache.maven.model.pom-*</exclude> @@ -543,11 +544,11 @@ </relocation> <relocation> <pattern>org.codehaus</pattern> - <shadedPattern>org.eclipse.aether.ant.org.codehaus</shadedPattern> + <shadedPattern>org.eclipse.aether.internal.ant.org.codehaus</shadedPattern> </relocation> <relocation> <pattern>org.slf4j</pattern> - <shadedPattern>org.eclipse.aether.ant.org.slf4j</shadedPattern> + <shadedPattern>org.eclipse.aether.internal.ant.org.slf4j</shadedPattern> </relocation> </relocations> </configuration> http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntLogger.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntLogger.java b/src/main/java/org/eclipse/aether/ant/AntLogger.java deleted file mode 100644 index a462ff3..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntLogger.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import org.apache.tools.ant.Project; -import org.eclipse.aether.spi.log.Logger; - -/** - */ -class AntLogger - implements Logger -{ - - private Project project; - - public AntLogger( Project project ) - { - this.project = project; - } - - public void debug( String msg ) - { - project.log( msg, Project.MSG_DEBUG ); - } - - public void debug( String msg, Throwable error ) - { - project.log( msg, error, Project.MSG_DEBUG ); - } - - public boolean isDebugEnabled() - { - return true; - } - - public boolean isWarnEnabled() - { - return true; - } - - public void warn( String msg ) - { - project.log( msg, Project.MSG_WARN ); - } - - public void warn( String msg, Throwable error ) - { - project.log( msg, error, Project.MSG_WARN ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntModelResolver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntModelResolver.java b/src/main/java/org/eclipse/aether/ant/AntModelResolver.java deleted file mode 100644 index c964feb..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntModelResolver.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import java.io.File; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.model.Repository; -import org.apache.maven.model.building.FileModelSource; -import org.apache.maven.model.building.ModelSource; -import org.apache.maven.model.resolution.InvalidRepositoryException; -import org.apache.maven.model.resolution.ModelResolver; -import org.apache.maven.model.resolution.UnresolvableModelException; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.impl.RemoteRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.repository.RepositoryPolicy; -import org.eclipse.aether.resolution.ArtifactRequest; -import org.eclipse.aether.resolution.ArtifactResolutionException; - -/** - * A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have - * been initially specified and repositories discovered in dependency POMs are recessively merged into the search chain. - * - */ -class AntModelResolver - implements ModelResolver -{ - - private final RepositorySystemSession session; - - private final String context; - - private List<org.eclipse.aether.repository.RemoteRepository> repositories; - - private final RepositorySystem repoSys; - - private final RemoteRepositoryManager remoteRepositoryManager; - - private final Set<String> repositoryIds; - - public AntModelResolver( RepositorySystemSession session, String context, RepositorySystem repoSys, - RemoteRepositoryManager remoteRepositoryManager, List<RemoteRepository> repositories ) - { - this.session = session; - this.context = context; - this.repoSys = repoSys; - this.remoteRepositoryManager = remoteRepositoryManager; - this.repositories = repositories; - this.repositoryIds = new HashSet<String>(); - } - - private AntModelResolver( AntModelResolver original ) - { - this.session = original.session; - this.context = original.context; - this.repoSys = original.repoSys; - this.remoteRepositoryManager = original.remoteRepositoryManager; - this.repositories = original.repositories; - this.repositoryIds = new HashSet<String>( original.repositoryIds ); - } - - public void addRepository( Repository repository ) - throws InvalidRepositoryException - { - if ( !repositoryIds.add( repository.getId() ) ) - { - return; - } - - List<RemoteRepository> newRepositories = Collections.singletonList( convert( repository ) ); - - this.repositories = - remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true ); - } - - static RemoteRepository convert( Repository repository ) - { - RemoteRepository.Builder builder = - new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() ); - builder.setSnapshotPolicy( convert( repository.getSnapshots() ) ); - builder.setReleasePolicy( convert( repository.getReleases() ) ); - return builder.build(); - } - - private static RepositoryPolicy convert( org.apache.maven.model.RepositoryPolicy policy ) - { - boolean enabled = true; - String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN; - String updates = RepositoryPolicy.UPDATE_POLICY_DAILY; - - if ( policy != null ) - { - enabled = policy.isEnabled(); - if ( policy.getUpdatePolicy() != null ) - { - updates = policy.getUpdatePolicy(); - } - if ( policy.getChecksumPolicy() != null ) - { - checksums = policy.getChecksumPolicy(); - } - } - - return new RepositoryPolicy( enabled, updates, checksums ); - } - - public ModelResolver newCopy() - { - return new AntModelResolver( this ); - } - - public ModelSource resolveModel( String groupId, String artifactId, String version ) - throws UnresolvableModelException - { - Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version ); - - try - { - ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context ); - pomArtifact = repoSys.resolveArtifact( session, request ).getArtifact(); - } - catch ( ArtifactResolutionException e ) - { - throw new UnresolvableModelException( "Failed to resolve POM for " + groupId + ":" + artifactId + ":" - + version + " due to " + e.getMessage(), groupId, artifactId, version, e ); - } - - File pomFile = pomArtifact.getFile(); - - return new FileModelSource( pomFile ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntRepoSys.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntRepoSys.java b/src/main/java/org/eclipse/aether/ant/AntRepoSys.java deleted file mode 100644 index 364173f..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntRepoSys.java +++ /dev/null @@ -1,753 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2014 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.maven.model.Model; -import org.apache.maven.model.building.DefaultModelBuilderFactory; -import org.apache.maven.model.building.DefaultModelBuildingRequest; -import org.apache.maven.model.building.FileModelSource; -import org.apache.maven.model.building.ModelBuilder; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.resolution.ModelResolver; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.Settings; -import org.apache.maven.settings.building.DefaultSettingsBuilderFactory; -import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; -import org.apache.maven.settings.building.SettingsBuilder; -import org.apache.maven.settings.building.SettingsBuildingException; -import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; -import org.apache.maven.settings.crypto.SettingsDecrypter; -import org.apache.maven.settings.crypto.SettingsDecryptionResult; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.types.Reference; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.eclipse.aether.ConfigurationProperties; -import org.eclipse.aether.DefaultRepositoryCache; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.ant.listeners.AntRepositoryListener; -import org.eclipse.aether.ant.listeners.AntTransferListener; -import org.eclipse.aether.ant.types.Authentication; -import org.eclipse.aether.ant.types.Dependencies; -import org.eclipse.aether.ant.types.Dependency; -import org.eclipse.aether.ant.types.DependencyContainer; -import org.eclipse.aether.ant.types.Exclusion; -import org.eclipse.aether.ant.types.LocalRepository; -import org.eclipse.aether.ant.types.Mirror; -import org.eclipse.aether.ant.types.Pom; -import org.eclipse.aether.ant.types.Proxy; -import org.eclipse.aether.ant.types.RemoteRepositories; -import org.eclipse.aether.ant.types.RemoteRepository; -import org.eclipse.aether.ant.util.AetherUtils; -import org.eclipse.aether.ant.util.ConverterUtils; -import org.eclipse.aether.ant.util.SettingsUtils; -import org.eclipse.aether.collection.CollectRequest; -import org.eclipse.aether.collection.CollectResult; -import org.eclipse.aether.collection.DependencyCollectionException; -import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; -import org.eclipse.aether.impl.DefaultServiceLocator; -import org.eclipse.aether.impl.RemoteRepositoryManager; -import org.eclipse.aether.repository.AuthenticationSelector; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.MirrorSelector; -import org.eclipse.aether.repository.ProxySelector; -import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.transport.classpath.ClasspathTransporterFactory; -import org.eclipse.aether.transport.file.FileTransporterFactory; -import org.eclipse.aether.transport.http.HttpTransporterFactory; -import org.eclipse.aether.util.repository.AuthenticationBuilder; -import org.eclipse.aether.util.repository.ConservativeAuthenticationSelector; -import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; -import org.eclipse.aether.util.repository.DefaultMirrorSelector; -import org.eclipse.aether.util.repository.DefaultProxySelector; - -/** - */ -public class AntRepoSys -{ - - private static boolean OS_WINDOWS = Os.isFamily( "windows" ); - - private static final ModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance(); - - private static final SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance(); - - private static final SettingsDecrypter settingsDecrypter = new AntSettingsDecryptorFactory().newInstance(); - - private final Project project; - - private final DefaultServiceLocator locator; - - private RepositorySystem repoSys; - - private RemoteRepositoryManager remoteRepoMan; - - private File userSettings; - - private File globalSettings; - - private Settings settings; - - private final List<Mirror> mirrors = new CopyOnWriteArrayList<Mirror>(); - - private final List<Proxy> proxies = new CopyOnWriteArrayList<Proxy>(); - - private final List<Authentication> authentications = new CopyOnWriteArrayList<Authentication>(); - - private LocalRepository localRepository; - - private Pom defaultPom; - - private static <T> boolean eq( T o1, T o2 ) - { - return ( o1 == null ) ? o2 == null : o1.equals( o2 ); - } - - public static synchronized AntRepoSys getInstance( Project project ) - { - Object obj = project.getReference( Names.ID ); - if ( obj instanceof AntRepoSys ) - { - return (AntRepoSys) obj; - } - AntRepoSys instance = new AntRepoSys( project ); - project.addReference( Names.ID, instance ); - instance.initDefaults(); - return instance; - } - - private AntRepoSys( Project project ) - { - this.project = project; - - locator = MavenRepositorySystemUtils.newServiceLocator(); - locator.setErrorHandler( new AntServiceLocatorErrorHandler( project ) ); - locator.setServices( Logger.class, new AntLogger( project ) ); - locator.setServices( ModelBuilder.class, modelBuilder ); - locator.addService( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class ); - locator.addService( TransporterFactory.class, FileTransporterFactory.class ); - locator.addService( TransporterFactory.class, HttpTransporterFactory.class ); - locator.addService( TransporterFactory.class, ClasspathTransporterFactory.class ); - } - - private void initDefaults() - { - RemoteRepository repo = new RemoteRepository(); - repo.setProject( project ); - repo.setId( "central" ); - repo.setUrl( "http://repo1.maven.org/maven2/" ); - project.addReference( Names.ID_CENTRAL, repo ); - - repo = new RemoteRepository(); - repo.setProject( project ); - repo.setRefid( new Reference( project, Names.ID_CENTRAL ) ); - RemoteRepositories repos = new RemoteRepositories(); - repos.setProject( project ); - repos.addRemoterepo( repo ); - project.addReference( Names.ID_DEFAULT_REPOS, repos ); - } - - public synchronized RepositorySystem getSystem() - { - if ( repoSys == null ) - { - repoSys = locator.getService( RepositorySystem.class ); - if ( repoSys == null ) - { - throw new BuildException( "The repository system could not be initialized" ); - } - } - return repoSys; - } - - private synchronized RemoteRepositoryManager getRemoteRepoMan() - { - if ( remoteRepoMan == null ) - { - remoteRepoMan = locator.getService( RemoteRepositoryManager.class ); - if ( remoteRepoMan == null ) - { - throw new BuildException( "The repository system could not be initialized" ); - } - } - return remoteRepoMan; - } - - public RepositorySystemSession getSession( Task task, LocalRepository localRepo ) - { - DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - - Map<Object, Object> configProps = new LinkedHashMap<Object, Object>(); - configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() ); - configProps.putAll( (Map<?, ?>) project.getProperties() ); - processServerConfiguration( configProps ); - session.setConfigProperties( configProps ); - - session.setOffline( isOffline() ); - session.setUserProperties( project.getUserProperties() ); - - session.setProxySelector( getProxySelector() ); - session.setMirrorSelector( getMirrorSelector() ); - session.setAuthenticationSelector( getAuthSelector() ); - - session.setCache( new DefaultRepositoryCache() ); - - session.setRepositoryListener( new AntRepositoryListener( task ) ); - session.setTransferListener( new AntTransferListener( task ) ); - - session.setLocalRepositoryManager( getLocalRepoMan( session, localRepo ) ); - - session.setWorkspaceReader( ProjectWorkspaceReader.getInstance() ); - - return session; - } - - private String getUserAgent() - { - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( "Apache-Ant/" ).append( project.getProperty( "ant.version" ) ); - buffer.append( " (" ); - buffer.append( "Java " ).append( System.getProperty( "java.version" ) ); - buffer.append( "; " ); - buffer.append( System.getProperty( "os.name" ) ).append( " " ).append( System.getProperty( "os.version" ) ); - buffer.append( ")" ); - buffer.append( " Aether" ); - - return buffer.toString(); - } - - private boolean isOffline() - { - String prop = project.getProperty( Names.PROPERTY_OFFLINE ); - if ( prop != null ) - { - return Boolean.parseBoolean( prop ); - } - return getSettings().isOffline(); - } - - private void processServerConfiguration( Map<Object, Object> configProps ) - { - Settings settings = getSettings(); - for ( Server server : settings.getServers() ) - { - if ( server.getConfiguration() != null ) - { - Xpp3Dom dom = (Xpp3Dom) server.getConfiguration(); - for ( int i = dom.getChildCount() - 1; i >= 0; i-- ) - { - Xpp3Dom child = dom.getChild( i ); - if ( "wagonProvider".equals( child.getName() ) ) - { - dom.removeChild( i ); - } - else if ( "httpHeaders".equals( child.getName() ) ) - { - configProps.put( ConfigurationProperties.HTTP_HEADERS + "." + server.getId(), - getHttpHeaders( child ) ); - } - } - - configProps.put( "aether.connector.wagon.config." + server.getId(), dom ); - } - - configProps.put( "aether.connector.perms.fileMode." + server.getId(), server.getFilePermissions() ); - configProps.put( "aether.connector.perms.dirMode." + server.getId(), server.getDirectoryPermissions() ); - } - } - - private Map<String, String> getHttpHeaders( Xpp3Dom dom ) - { - Map<String, String> headers = new HashMap<String, String>(); - for ( int i = 0; i < dom.getChildCount(); i++ ) - { - Xpp3Dom child = dom.getChild( i ); - Xpp3Dom name = child.getChild( "name" ); - Xpp3Dom value = child.getChild( "value" ); - if ( name != null && name.getValue() != null ) - { - headers.put( name.getValue(), ( value != null ) ? value.getValue() : null ); - } - } - return Collections.unmodifiableMap( headers ); - } - - private File getDefaultLocalRepoDir() - { - String dir = project.getProperty( "maven.repo.local" ); - if ( dir != null ) - { - return project.resolveFile( dir ); - } - - Settings settings = getSettings(); - if ( settings.getLocalRepository() != null ) - { - return new File( settings.getLocalRepository() ); - } - - return new File( new File( project.getProperty( "user.home" ), ".m2" ), "repository" ); - } - - private LocalRepositoryManager getLocalRepoMan( RepositorySystemSession session, LocalRepository localRepo ) - { - if ( localRepo == null ) - { - localRepo = localRepository; - } - - File repoDir; - if ( localRepo != null && localRepo.getDir() != null ) - { - repoDir = localRepo.getDir(); - } - else - { - repoDir = getDefaultLocalRepoDir(); - } - - org.eclipse.aether.repository.LocalRepository repo = - new org.eclipse.aether.repository.LocalRepository( repoDir ); - - return getSystem().newLocalRepositoryManager( session, repo ); - } - - private synchronized Settings getSettings() - { - if ( settings == null ) - { - DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); - request.setUserSettingsFile( getUserSettings() ); - request.setGlobalSettingsFile( getGlobalSettings() ); - request.setSystemProperties( getSystemProperties() ); - request.setUserProperties( getUserProperties() ); - - try - { - settings = settingsBuilder.build( request ).getEffectiveSettings(); - } - catch ( SettingsBuildingException e ) - { - project.log( "Could not process settings.xml: " + e.getMessage(), e, Project.MSG_WARN ); - } - - SettingsDecryptionResult result = - settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( settings ) ); - settings.setServers( result.getServers() ); - settings.setProxies( result.getProxies() ); - } - return settings; - } - - private ProxySelector getProxySelector() - { - DefaultProxySelector selector = new DefaultProxySelector(); - - for ( Proxy proxy : proxies ) - { - selector.add( ConverterUtils.toProxy( proxy ), proxy.getNonProxyHosts() ); - } - - Settings settings = getSettings(); - for ( org.apache.maven.settings.Proxy proxy : settings.getProxies() ) - { - AuthenticationBuilder auth = new AuthenticationBuilder(); - auth.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() ); - selector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), - proxy.getPort(), auth.build() ), - proxy.getNonProxyHosts() ); - } - - return selector; - } - - private MirrorSelector getMirrorSelector() - { - DefaultMirrorSelector selector = new DefaultMirrorSelector(); - - for ( Mirror mirror : mirrors ) - { - selector.add( mirror.getId(), mirror.getUrl(), mirror.getType(), false, mirror.getMirrorOf(), null ); - } - - Settings settings = getSettings(); - for ( org.apache.maven.settings.Mirror mirror : settings.getMirrors() ) - { - selector.add( String.valueOf( mirror.getId() ), mirror.getUrl(), mirror.getLayout(), false, - mirror.getMirrorOf(), mirror.getMirrorOfLayouts() ); - } - - return selector; - } - - private AuthenticationSelector getAuthSelector() - { - DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector(); - - Collection<String> ids = new HashSet<String>(); - for ( Authentication auth : authentications ) - { - List<String> servers = auth.getServers(); - if ( !servers.isEmpty() ) - { - org.eclipse.aether.repository.Authentication a = ConverterUtils.toAuthentication( auth ); - for ( String server : servers ) - { - if ( ids.add( server ) ) - { - selector.add( server, a ); - } - } - } - } - - Settings settings = getSettings(); - for ( Server server : settings.getServers() ) - { - AuthenticationBuilder auth = new AuthenticationBuilder(); - auth.addUsername( server.getUsername() ).addPassword( server.getPassword() ); - auth.addPrivateKey( server.getPrivateKey(), server.getPassphrase() ); - selector.add( server.getId(), auth.build() ); - } - - return new ConservativeAuthenticationSelector( selector ); - } - - public synchronized void setUserSettings( File file ) - { - if ( !eq( this.userSettings, file ) ) - { - settings = null; - } - this.userSettings = file; - } - - /* UT */File getUserSettings() - { - if ( userSettings == null ) - { - userSettings = AetherUtils.findUserSettings( project ); - } - return userSettings; - } - - public void setGlobalSettings( File file ) - { - if ( !eq( this.globalSettings, file ) ) - { - settings = null; - } - this.globalSettings = file; - } - - /* UT */File getGlobalSettings() - { - if ( globalSettings == null ) - { - globalSettings = AetherUtils.findGlobalSettings( project ); - } - return globalSettings; - } - - public void addProxy( Proxy proxy ) - { - proxies.add( proxy ); - } - - public void addMirror( Mirror mirror ) - { - mirrors.add( mirror ); - } - - public void addAuthentication( Authentication authentication ) - { - authentications.add( authentication ); - } - - public void setLocalRepository( LocalRepository localRepository ) - { - this.localRepository = localRepository; - } - - public Model loadModel( Task task, File pomFile, boolean local, RemoteRepositories remoteRepositories ) - { - RepositorySystemSession session = getSession( task, null ); - - remoteRepositories = - remoteRepositories == null ? AetherUtils.getDefaultRepositories( project ) : remoteRepositories; - - List<org.eclipse.aether.repository.RemoteRepository> repositories = - ConverterUtils.toRepositories( task.getProject(), session, remoteRepositories, getRemoteRepoMan() ); - - ModelResolver modelResolver = - new AntModelResolver( session, "project", getSystem(), getRemoteRepoMan(), repositories ); - - Settings settings = getSettings(); - - try - { - DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); - request.setLocationTracking( true ); - request.setProcessPlugins( false ); - if ( local ) - { - request.setPomFile( pomFile ); - request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); - } - else - { - request.setModelSource( new FileModelSource( pomFile ) ); - request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); - } - request.setSystemProperties( getSystemProperties() ); - request.setUserProperties( getUserProperties() ); - request.setProfiles( SettingsUtils.convert( settings.getProfiles() ) ); - request.setActiveProfileIds( settings.getActiveProfiles() ); - request.setModelResolver( modelResolver ); - return modelBuilder.build( request ).getEffectiveModel(); - } - catch ( ModelBuildingException e ) - { - throw new BuildException( "Could not load POM " + pomFile + ": " + e.getMessage(), e ); - } - } - - private Properties getSystemProperties() - { - Properties props = new Properties(); - getEnvProperties( props ); - props.putAll( System.getProperties() ); - ConverterUtils.addProperties( props, project.getProperties() ); - return props; - } - - private Properties getEnvProperties( Properties props ) - { - if ( props == null ) - { - props = new Properties(); - } - boolean envCaseInsensitive = OS_WINDOWS; - for ( Map.Entry<String, String> entry : System.getenv().entrySet() ) - { - String key = entry.getKey(); - if ( envCaseInsensitive ) - { - key = key.toUpperCase( Locale.ENGLISH ); - } - key = "env." + key; - props.put( key, entry.getValue() ); - } - return props; - } - - private Properties getUserProperties() - { - return ConverterUtils.addProperties( null, project.getUserProperties() ); - } - - /** - * Sets the default POM. - */ - public void setDefaultPom( Pom pom ) - { - this.defaultPom = pom; - } - - /** - * Returns the current default POM. - */ - public Pom getDefaultPom() - { - return defaultPom; - } - - public CollectResult collectDependencies( Task task, Dependencies dependencies, LocalRepository localRepository, - RemoteRepositories remoteRepositories ) - { - RepositorySystemSession session = getSession( task, localRepository ); - - remoteRepositories = - remoteRepositories == null ? AetherUtils.getDefaultRepositories( project ) : remoteRepositories; - - List<org.eclipse.aether.repository.RemoteRepository> repos = - ConverterUtils.toRepositories( project, session, remoteRepositories, getRemoteRepoMan() ); - - CollectRequest collectRequest = new CollectRequest(); - collectRequest.setRequestContext( "project" ); - - for ( org.eclipse.aether.repository.RemoteRepository repo : repos ) - { - task.getProject().log( "Using remote repository " + repo, Project.MSG_VERBOSE ); - collectRequest.addRepository( repo ); - } - - if ( dependencies != null ) - { - populateCollectRequest( collectRequest, task, session, dependencies, Collections.<Exclusion> emptyList() ); - } - - task.getProject().log( "Collecting dependencies", Project.MSG_VERBOSE ); - - CollectResult result; - try - { - result = getSystem().collectDependencies( session, collectRequest ); - } - catch ( DependencyCollectionException e ) - { - throw new BuildException( "Could not collect dependencies: " + e.getMessage(), e ); - } - - return result; - } - - private void populateCollectRequest( CollectRequest collectRequest, Task task, RepositorySystemSession session, - Dependencies dependencies, List<Exclusion> exclusions ) - { - List<Exclusion> globalExclusions = exclusions; - if ( !dependencies.getExclusions().isEmpty() ) - { - globalExclusions = new ArrayList<Exclusion>( exclusions ); - globalExclusions.addAll( dependencies.getExclusions() ); - } - - Collection<String> ids = new HashSet<String>(); - - for ( DependencyContainer container : dependencies.getDependencyContainers() ) - { - if ( container instanceof Dependency ) - { - Dependency dep = (Dependency) container; - ids.add( dep.getVersionlessKey() ); - collectRequest.addDependency( ConverterUtils.toDependency( dep, globalExclusions, session ) ); - } - else - { - populateCollectRequest( collectRequest, task, session, (Dependencies) container, globalExclusions ); - } - } - - if ( dependencies.getPom() != null ) - { - Model model = dependencies.getPom().getModel( task ); - for ( org.apache.maven.model.Dependency dep : model.getDependencies() ) - { - Dependency dependency = new Dependency(); - dependency.setArtifactId( dep.getArtifactId() ); - dependency.setClassifier( dep.getClassifier() ); - dependency.setGroupId( dep.getGroupId() ); - dependency.setScope( dep.getScope() ); - dependency.setType( dep.getType() ); - dependency.setVersion( dep.getVersion() ); - if ( ids.contains( dependency.getVersionlessKey() ) ) - { - project.log( "Ignoring dependency " + dependency.getVersionlessKey() + " from " + model.getId() - + ", already declared locally", Project.MSG_VERBOSE ); - continue; - } - if ( dep.getSystemPath() != null && dep.getSystemPath().length() > 0 ) - { - dependency.setSystemPath( task.getProject().resolveFile( dep.getSystemPath() ) ); - } - for ( org.apache.maven.model.Exclusion exc : dep.getExclusions() ) - { - Exclusion exclusion = new Exclusion(); - exclusion.setGroupId( exc.getGroupId() ); - exclusion.setArtifactId( exc.getArtifactId() ); - exclusion.setClassifier( "*" ); - exclusion.setExtension( "*" ); - dependency.addExclusion( exclusion ); - } - collectRequest.addDependency( ConverterUtils.toDependency( dependency, globalExclusions, session ) ); - } - } - - if ( dependencies.getFile() != null ) - { - List<Dependency> deps = readDependencies( dependencies.getFile() ); - for ( Dependency dependency : deps ) - { - if ( ids.contains( dependency.getVersionlessKey() ) ) - { - project.log( "Ignoring dependency " + dependency.getVersionlessKey() + " from " - + dependencies.getFile() + ", already declared locally", Project.MSG_VERBOSE ); - continue; - } - collectRequest.addDependency( ConverterUtils.toDependency( dependency, globalExclusions, session ) ); - } - } - } - - private List<Dependency> readDependencies( File file ) - { - List<Dependency> dependencies = new ArrayList<Dependency>(); - try - { - BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - try - { - for ( String line = reader.readLine(); line != null; line = reader.readLine() ) - { - int comment = line.indexOf( '#' ); - if ( comment >= 0 ) - { - line = line.substring( 0, comment ); - } - line = line.trim(); - if ( line.length() <= 0 ) - { - continue; - } - Dependency dependency = new Dependency(); - dependency.setCoords( line ); - dependencies.add( dependency ); - } - } - finally - { - reader.close(); - } - } - catch ( IOException e ) - { - throw new BuildException( "Cannot read " + file, e ); - } - return dependencies; - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntSecDispatcher.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntSecDispatcher.java b/src/main/java/org/eclipse/aether/ant/AntSecDispatcher.java deleted file mode 100644 index 4eb7f97..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntSecDispatcher.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; -import org.sonatype.plexus.components.cipher.PlexusCipherException; -import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; - -/** - */ -class AntSecDispatcher - extends DefaultSecDispatcher -{ - - public AntSecDispatcher() - { - _configurationFile = "~/.m2/settings-security.xml"; - try - { - _cipher = new DefaultPlexusCipher(); - } - catch ( PlexusCipherException e ) - { - e.printStackTrace(); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntServiceLocatorErrorHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntServiceLocatorErrorHandler.java b/src/main/java/org/eclipse/aether/ant/AntServiceLocatorErrorHandler.java deleted file mode 100644 index d42c72c..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntServiceLocatorErrorHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import org.apache.tools.ant.Project; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.impl.DefaultServiceLocator; - -/** - */ -class AntServiceLocatorErrorHandler - extends DefaultServiceLocator.ErrorHandler -{ - - private Project project; - - public AntServiceLocatorErrorHandler( Project project ) - { - this.project = project; - } - - public void serviceCreationFailed( Class<?> type, Class<?> impl, Throwable exception ) - { - String msg = "Could not initialize repository system"; - if ( !RepositorySystem.class.equals( type ) ) - { - msg += ", service " + type.getName() + " (" + impl.getName() + ") failed to initialize"; - } - msg += ": " + exception.getMessage(); - project.log( msg, exception, Project.MSG_ERR ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/AntSettingsDecryptorFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/AntSettingsDecryptorFactory.java b/src/main/java/org/eclipse/aether/ant/AntSettingsDecryptorFactory.java deleted file mode 100644 index 0586257..0000000 --- a/src/main/java/org/eclipse/aether/ant/AntSettingsDecryptorFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import java.lang.reflect.Field; - -import org.apache.maven.settings.crypto.DefaultSettingsDecrypter; - -/** - */ -class AntSettingsDecryptorFactory -{ - - public DefaultSettingsDecrypter newInstance() - { - AntSecDispatcher secDispatcher = new AntSecDispatcher(); - - DefaultSettingsDecrypter decrypter = new DefaultSettingsDecrypter(); - - try - { - Field field = decrypter.getClass().getDeclaredField( "securityDispatcher" ); - field.setAccessible( true ); - field.set( decrypter, secDispatcher ); - } - catch ( Exception e ) - { - throw new IllegalStateException( e ); - } - - return decrypter; - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/Names.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/Names.java b/src/main/java/org/eclipse/aether/ant/Names.java deleted file mode 100644 index c806bf6..0000000 --- a/src/main/java/org/eclipse/aether/ant/Names.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2014 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -public final class Names -{ - - private Names() - { - // hide constructor - } - - public static final String ID = "aether"; - - public static final String ID_DEFAULT_REPOS = ID + ".repositories"; - - public static final String ID_DEFAULT_POM = ID + ".pom"; - - public static final String ID_CENTRAL = "central"; - - public static final String PROPERTY_OFFLINE = "aether.offline"; - - public static final String SETTINGS_XML = "settings.xml"; - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/ProjectWorkspaceReader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/ProjectWorkspaceReader.java b/src/main/java/org/eclipse/aether/ant/ProjectWorkspaceReader.java deleted file mode 100644 index 28326ce..0000000 --- a/src/main/java/org/eclipse/aether/ant/ProjectWorkspaceReader.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2014 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.model.Model; -import org.eclipse.aether.ant.types.Pom; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.repository.WorkspaceReader; -import org.eclipse.aether.repository.WorkspaceRepository; -import org.eclipse.aether.util.artifact.ArtifactIdUtils; - -/** - * Workspace reader caching available POMs and artifacts for ant builds. - * <p/> - * <pom> elements are cached if they are defined by the 'file'-attribute, as they reference a backing pom.xml file that - * can be used for resolution with Aether. <artifact> elements are cached if they directly define a 'pom'-attribute - * or child. The POM may be file-based or in-memory. - */ -public class ProjectWorkspaceReader - implements WorkspaceReader -{ - - private static volatile ProjectWorkspaceReader instance; - - private static final Object LOCK = new Object(); - - private Map<String, Artifact> artifacts = new ConcurrentHashMap<String, Artifact>(); - - public void addPom( Pom pom ) - { - if ( pom.getFile() != null ) - { - Model model = pom.getModel( pom ); - Artifact aetherArtifact = - new DefaultArtifact( model.getGroupId(), model.getArtifactId(), null, "pom", model.getVersion() ); - aetherArtifact = aetherArtifact.setFile( pom.getFile() ); - String coords = coords( aetherArtifact ); - artifacts.put( coords, aetherArtifact ); - } - } - - public void addArtifact( org.eclipse.aether.ant.types.Artifact artifact ) - { - if ( artifact.getPom() != null ) - { - Pom pom = artifact.getPom(); - Artifact aetherArtifact; - if ( pom.getFile() != null ) - { - Model model = pom.getModel( pom ); - aetherArtifact = - new DefaultArtifact( model.getGroupId(), model.getArtifactId(), artifact.getClassifier(), - artifact.getType(), model.getVersion() ); - } - else - { - aetherArtifact = - new DefaultArtifact( pom.getGroupId(), pom.getArtifactId(), artifact.getClassifier(), - artifact.getType(), pom.getVersion() ); - } - aetherArtifact = aetherArtifact.setFile( artifact.getFile() ); - - String coords = coords( aetherArtifact ); - artifacts.put( coords, aetherArtifact ); - } - } - - private String coords( Artifact artifact ) - { - return ArtifactIdUtils.toId( artifact ); - } - - public WorkspaceRepository getRepository() - { - return new WorkspaceRepository( "ant" ); - } - - public File findArtifact( Artifact artifact ) - { - artifact = artifacts.get( coords( artifact ) ); - return ( artifact != null ) ? artifact.getFile() : null; - } - - public List<String> findVersions( Artifact artifact ) - { - List<String> versions = new ArrayList<String>(); - for ( Artifact art : artifacts.values() ) - { - if ( ArtifactIdUtils.equalsVersionlessId( artifact, art ) ) - { - versions.add( art.getVersion() ); - } - } - return versions; - } - - ProjectWorkspaceReader() - { - } - - public static ProjectWorkspaceReader getInstance() - { - if ( instance == null ) - { - synchronized ( LOCK ) - { - if ( instance == null ) - { - instance = new ProjectWorkspaceReader(); - } - } - } - return instance; - } - - static void dropInstance() - { - instance = null; - } -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/listeners/AntRepositoryListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/listeners/AntRepositoryListener.java b/src/main/java/org/eclipse/aether/ant/listeners/AntRepositoryListener.java deleted file mode 100644 index 8230b65..0000000 --- a/src/main/java/org/eclipse/aether/ant/listeners/AntRepositoryListener.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.listeners; - -import java.io.FileNotFoundException; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.eclipse.aether.AbstractRepositoryListener; -import org.eclipse.aether.RepositoryEvent; -import org.eclipse.aether.transfer.MetadataNotFoundException; - -/** - * Logs repository events like installed and unresolved artifacts and metadata. - */ -public class AntRepositoryListener - extends AbstractRepositoryListener -{ - - private Task task; - - public AntRepositoryListener( Task task ) - { - this.task = task; - } - - @Override - public void artifactInstalling( RepositoryEvent event ) - { - task.log( "Installing " + event.getArtifact().getFile() + " to " + event.getFile() ); - } - - @Override - public void metadataInstalling( RepositoryEvent event ) - { - task.log( "Installing " + event.getMetadata() + " to " + event.getFile() ); - } - - @Override - public void metadataResolved( RepositoryEvent event ) - { - Exception e = event.getException(); - if ( e != null ) - { - if ( e instanceof MetadataNotFoundException ) - { - task.log( e.getMessage(), Project.MSG_DEBUG ); - } - else - { - task.log( e.getMessage(), e, Project.MSG_WARN ); - } - } - } - - @Override - public void metadataInvalid( RepositoryEvent event ) - { - Exception exception = event.getException(); - - StringBuilder buffer = new StringBuilder( 256 ); - buffer.append( "The metadata " ); - if ( event.getMetadata().getFile() != null ) - { - buffer.append( event.getMetadata().getFile() ); - } - else - { - buffer.append( event.getMetadata() ); - } - - if ( exception instanceof FileNotFoundException ) - { - buffer.append( " is inaccessible" ); - } - else - { - buffer.append( " is invalid" ); - } - - if ( exception != null ) - { - buffer.append( ": " ); - buffer.append( exception.getMessage() ); - } - - task.log( buffer.toString(), exception, Project.MSG_WARN ); - } - - @Override - public void artifactDescriptorInvalid( RepositoryEvent event ) - { - task.log( "The POM for " + event.getArtifact() + " is invalid" - + ", transitive dependencies (if any) will not be available: " - + event.getException().getMessage(), - event.getException(), Project.MSG_WARN ); - }; - - @Override - public void artifactDescriptorMissing( RepositoryEvent event ) - { - task.log( "The POM for " + event.getArtifact() + " is missing, no dependency information available", - Project.MSG_WARN ); - }; - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/listeners/AntTransferListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/listeners/AntTransferListener.java b/src/main/java/org/eclipse/aether/ant/listeners/AntTransferListener.java deleted file mode 100644 index 7d6b944..0000000 --- a/src/main/java/org/eclipse/aether/ant/listeners/AntTransferListener.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.listeners; - -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.eclipse.aether.transfer.AbstractTransferListener; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferResource; - -/** - * Logs up- and downloads. - */ -public class AntTransferListener - extends AbstractTransferListener -{ - - private Task task; - - public AntTransferListener( Task task ) - { - this.task = task; - } - - @Override - public void transferInitiated( TransferEvent event ) - throws TransferCancelledException - { - String msg = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading"; - msg += " " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName(); - task.log( msg ); - } - - @Override - public void transferCorrupted( TransferEvent event ) - throws TransferCancelledException - { - TransferResource resource = event.getResource(); - - task.log( event.getException().getMessage() + " for " + resource.getRepositoryUrl() - + resource.getResourceName(), Project.MSG_WARN ); - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - String msg = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded"; - msg += " " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName(); - - long contentLength = event.getTransferredBytes(); - if ( contentLength >= 0 ) - { - String len = contentLength >= 1024 ? ( ( contentLength + 1023 ) / 1024 ) + " KB" : contentLength + " B"; - - String throughput = ""; - long duration = System.currentTimeMillis() - event.getResource().getTransferStartTime(); - if ( duration > 0 ) - { - DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) ); - double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 ); - throughput = " at " + format.format( kbPerSec ) + " KB/sec"; - } - - msg += " (" + len + throughput + ")"; - } - task.log( msg ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/tasks/AbstractDistTask.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/tasks/AbstractDistTask.java b/src/main/java/org/eclipse/aether/ant/tasks/AbstractDistTask.java deleted file mode 100644 index 480d7de..0000000 --- a/src/main/java/org/eclipse/aether/ant/tasks/AbstractDistTask.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.tasks; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Model; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Reference; -import org.eclipse.aether.ant.AntRepoSys; -import org.eclipse.aether.ant.types.Artifact; -import org.eclipse.aether.ant.types.Artifacts; -import org.eclipse.aether.ant.types.Pom; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.RepositorySystemSession; - -/** - */ -public abstract class AbstractDistTask - extends Task -{ - - private Pom pom; - - private Artifacts artifacts; - - protected void validate() - { - getArtifacts().validate( this ); - - Map<String, File> duplicates = new HashMap<String, File>(); - for ( Artifact artifact : getArtifacts().getArtifacts() ) - { - String key = artifact.getType() + ':' + artifact.getClassifier(); - if ( "pom:".equals( key ) ) - { - throw new BuildException( "You must not specify an <artifact> with type=pom" - + ", please use the <pom> element instead." ); - } - else if ( duplicates.containsKey( key ) ) - { - throw new BuildException( "You must not specify two or more artifacts with the same type (" - + artifact.getType() + ") and classifier (" + artifact.getClassifier() + ")" ); - } - else - { - duplicates.put( key, artifact.getFile() ); - } - - validateArtifactGav( artifact ); - } - - Pom defaultPom = AntRepoSys.getInstance( getProject() ).getDefaultPom(); - if ( pom == null && defaultPom != null ) - { - log( "Using default POM (" + defaultPom.getCoords() + ")", Project.MSG_INFO ); - pom = defaultPom; - } - - if ( pom == null ) - { - throw new BuildException( "You must specify the <pom file=\"...\"> element" - + " to denote the descriptor for the artifacts" ); - } - if ( pom.getFile() == null ) - { - throw new BuildException( "You must specify a <pom> element that has the 'file' attribute set" ); - } - } - - private void validateArtifactGav( Artifact artifact ) - { - Pom artifactPom = artifact.getPom(); - if ( artifactPom != null ) - { - String gid; - String aid; - String version; - if ( artifactPom.getFile() != null ) - { - Model model = artifactPom.getModel( this ); - gid = model.getGroupId(); - aid = model.getArtifactId(); - version = model.getVersion(); - } - else - { - gid = artifactPom.getGroupId(); - aid = artifactPom.getArtifactId(); - version = artifactPom.getVersion(); - } - - Model model = getPom().getModel( this ); - - if ( ! ( model.getGroupId().equals( gid ) && model.getArtifactId().equals( aid ) && model.getVersion().equals( version )) ) - { - throw new BuildException( "Artifact references different pom than it would be installed with: " - + artifact.toString() ); - } - } - } - - protected List<org.eclipse.aether.artifact.Artifact> toArtifacts( RepositorySystemSession session ) - { - Model model = getPom().getModel( this ); - File pomFile = getPom().getFile(); - - List<org.eclipse.aether.artifact.Artifact> results = new ArrayList<org.eclipse.aether.artifact.Artifact>(); - - org.eclipse.aether.artifact.Artifact pomArtifact = - new DefaultArtifact( model.getGroupId(), model.getArtifactId(), "pom", model.getVersion() ).setFile( pomFile ); - results.add( pomArtifact ); - - for ( Artifact artifact : getArtifacts().getArtifacts() ) - { - org.eclipse.aether.artifact.Artifact buildArtifact = - new DefaultArtifact( model.getGroupId(), model.getArtifactId(), artifact.getClassifier(), - artifact.getType(), model.getVersion() ).setFile( artifact.getFile() ); - results.add( buildArtifact ); - } - - return results; - } - - protected Artifacts getArtifacts() - { - if ( artifacts == null ) - { - artifacts = new Artifacts(); - artifacts.setProject( getProject() ); - } - return artifacts; - } - - public void addArtifact( Artifact artifact ) - { - getArtifacts().addArtifact( artifact ); - } - - public void addArtifacts( Artifacts artifacts ) - { - getArtifacts().addArtifacts( artifacts ); - } - - public void setArtifactsRef( Reference ref ) - { - Artifacts artifacts = new Artifacts(); - artifacts.setProject( getProject() ); - artifacts.setRefid( ref ); - getArtifacts().addArtifacts( artifacts ); - } - - protected Pom getPom() - { - if ( pom == null ) - { - return AntRepoSys.getInstance( getProject() ).getDefaultPom(); - } - - return pom; - } - - public void addPom( Pom pom ) - { - if ( this.pom != null ) - { - throw new BuildException( "You must not specify multiple <pom> elements" ); - } - this.pom = pom; - } - - public void setPomRef( Reference ref ) - { - if ( this.pom != null ) - { - throw new BuildException( "You must not specify multiple <pom> elements" ); - } - pom = new Pom(); - pom.setProject( getProject() ); - pom.setRefid( ref ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/tasks/AbstractResolvingTask.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/tasks/AbstractResolvingTask.java b/src/main/java/org/eclipse/aether/ant/tasks/AbstractResolvingTask.java deleted file mode 100644 index 72094ea..0000000 --- a/src/main/java/org/eclipse/aether/ant/tasks/AbstractResolvingTask.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.tasks; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Reference; -import org.eclipse.aether.ant.AntRepoSys; -import org.eclipse.aether.ant.types.Dependencies; -import org.eclipse.aether.ant.types.LocalRepository; -import org.eclipse.aether.ant.types.RemoteRepositories; -import org.eclipse.aether.ant.types.RemoteRepository; -import org.eclipse.aether.collection.CollectResult; - -public abstract class AbstractResolvingTask - extends Task -{ - - protected Dependencies dependencies; - - protected RemoteRepositories remoteRepositories; - - protected LocalRepository localRepository; - - public void addDependencies( Dependencies dependencies ) - { - if ( this.dependencies != null ) - { - throw new BuildException( "You must not specify multiple <dependencies> elements" ); - } - this.dependencies = dependencies; - } - - public void setDependenciesRef( Reference ref ) - { - if ( dependencies == null ) - { - dependencies = new Dependencies(); - dependencies.setProject( getProject() ); - } - dependencies.setRefid( ref ); - } - - public LocalRepository createLocalRepo() - { - if ( localRepository != null ) - { - throw new BuildException( "You must not specify multiple <localRepo> elements" ); - } - localRepository = new LocalRepository( this ); - return localRepository; - } - - private RemoteRepositories getRemoteRepos() - { - if ( remoteRepositories == null ) - { - remoteRepositories = new RemoteRepositories(); - remoteRepositories.setProject( getProject() ); - } - return remoteRepositories; - } - - public void addRemoteRepo( RemoteRepository repository ) - { - getRemoteRepos().addRemoterepo( repository ); - } - - public void addRemoteRepos( RemoteRepositories repositories ) - { - getRemoteRepos().addRemoterepos( repositories ); - } - - public void setRemoteReposRef( Reference ref ) - { - RemoteRepositories repos = new RemoteRepositories(); - repos.setProject( getProject() ); - repos.setRefid( ref ); - getRemoteRepos().addRemoterepos( repos ); - } - - protected CollectResult collectDependencies() - { - return AntRepoSys.getInstance( getProject() ).collectDependencies( this, dependencies, localRepository, - remoteRepositories ); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/tasks/DependencyGraphLogger.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/tasks/DependencyGraphLogger.java b/src/main/java/org/eclipse/aether/ant/tasks/DependencyGraphLogger.java deleted file mode 100644 index f35820e..0000000 --- a/src/main/java/org/eclipse/aether/ant/tasks/DependencyGraphLogger.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2013 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.tasks; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; -import org.eclipse.aether.util.graph.manager.DependencyManagerUtils; - -/** - */ -class DependencyGraphLogger - implements DependencyVisitor -{ - - private Task task; - - private String indent = ""; - - public DependencyGraphLogger( Task task ) - { - this.task = task; - } - - public boolean visitEnter( DependencyNode node ) - { - StringBuilder buffer = new StringBuilder( 128 ); - buffer.append( indent ); - Dependency dep = node.getDependency(); - if ( dep != null ) - { - Artifact art = dep.getArtifact(); - - buffer.append( art ); - buffer.append( ':' ).append( dep.getScope() ); - - String premanagedScope = DependencyManagerUtils.getPremanagedScope( node ); - if ( premanagedScope != null && !premanagedScope.equals( dep.getScope() ) ) - { - buffer.append( " (scope managed from " ).append( premanagedScope ).append( ")" ); - } - - String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node ); - if ( premanagedVersion != null && !premanagedVersion.equals( art.getVersion() ) ) - { - buffer.append( " (version managed from " ).append( premanagedVersion ).append( ")" ); - } - } - else - { - buffer.append( "Resolved Dependency Graph:" ); - } - - task.log( buffer.toString(), Project.MSG_VERBOSE ); - indent += " "; - return true; - } - - public boolean visitLeave( DependencyNode node ) - { - indent = indent.substring( 0, indent.length() - 3 ); - return true; - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/tasks/Deploy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/tasks/Deploy.java b/src/main/java/org/eclipse/aether/ant/tasks/Deploy.java deleted file mode 100644 index 59de6c7..0000000 --- a/src/main/java/org/eclipse/aether/ant/tasks/Deploy.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.tasks; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Reference; -import org.eclipse.aether.ant.AntRepoSys; -import org.eclipse.aether.ant.util.ConverterUtils; -import org.eclipse.aether.ant.types.RemoteRepository; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.deployment.DeployRequest; -import org.eclipse.aether.deployment.DeploymentException; - -/** - */ -public class Deploy - extends AbstractDistTask -{ - - private RemoteRepository repository; - - private RemoteRepository snapshotRepository; - - @Override - protected void validate() - { - super.validate(); - - if ( repository == null ) - { - throw new BuildException( "You must specify the <remoteRepo id=\"...\" url=\"...\"> element" - + " to denote the target repository for the deployment" ); - } - else - { - repository.validate( this ); - } - if ( snapshotRepository != null ) - { - snapshotRepository.validate( this ); - } - } - - public void addRemoteRepo( RemoteRepository repository ) - { - if ( this.repository != null ) - { - throw new BuildException( "You must not specify multiple <remoteRepo> elements" ); - } - this.repository = repository; - } - - public void setRemoteRepoRef( Reference ref ) - { - if ( repository == null ) - { - repository = new RemoteRepository(); - repository.setProject( getProject() ); - } - repository.setRefid( ref ); - } - - public void addSnapshotRepo( RemoteRepository snapshotRepository ) - { - if ( this.snapshotRepository != null ) - { - throw new BuildException( "You must not specify multiple <snapshotRepo> elements" ); - } - this.snapshotRepository = snapshotRepository; - } - - public void setSnapshotRepoRef( Reference ref ) - { - if ( snapshotRepository == null ) - { - snapshotRepository = new RemoteRepository(); - snapshotRepository.setProject( getProject() ); - } - snapshotRepository.setRefid( ref ); - } - - @Override - public void execute() - throws BuildException - { - validate(); - - AntRepoSys sys = AntRepoSys.getInstance( getProject() ); - - RepositorySystemSession session = sys.getSession( this, null ); - RepositorySystem system = sys.getSystem(); - - DeployRequest request = new DeployRequest(); - - request.setArtifacts( toArtifacts( session ) ); - - boolean snapshot = request.getArtifacts().iterator().next().isSnapshot(); - RemoteRepository distRepo = ( snapshot && snapshotRepository != null ) ? snapshotRepository : repository; - request.setRepository( ConverterUtils.toDistRepository( distRepo, session ) ); - - try - { - system.deploy( session, request ); - } - catch ( DeploymentException e ) - { - throw new BuildException( "Could not deploy artifacts: " + e.getMessage(), e ); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-aether/blob/1ec78d99/src/main/java/org/eclipse/aether/ant/tasks/Install.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/eclipse/aether/ant/tasks/Install.java b/src/main/java/org/eclipse/aether/ant/tasks/Install.java deleted file mode 100644 index 0d013bb..0000000 --- a/src/main/java/org/eclipse/aether/ant/tasks/Install.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.aether.ant.tasks; - -import org.apache.tools.ant.BuildException; -import org.eclipse.aether.ant.AntRepoSys; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.installation.InstallRequest; -import org.eclipse.aether.installation.InstallationException; - -/** - */ -public class Install - extends AbstractDistTask -{ - - @Override - public void execute() - throws BuildException - { - validate(); - - AntRepoSys sys = AntRepoSys.getInstance( getProject() ); - - RepositorySystemSession session = sys.getSession( this, null ); - RepositorySystem system = sys.getSystem(); - - InstallRequest request = new InstallRequest(); - request.setArtifacts( toArtifacts( session ) ); - - try - { - system.install( session, request ); - } - catch ( InstallationException e ) - { - throw new BuildException( "Could not install artifacts: " + e.getMessage(), e ); - } - } - -}
