From 971b2dee8aeeb8aefed5cd97aea150097895b9e5 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Mon, 12 Feb 2007 07:29:48 +0000 Subject: [PATCH] moved to its own tree git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@506345 13f79535-47bb-0310-9956-ffa450edef68 --- maven-artifact-ant/pom.xml | 112 ----- maven-artifact-ant/sample-build-test.pom | 6 - maven-artifact-ant/sample.build.xml | 218 --------- maven-artifact-ant/src/main/assembly/dep.xml | 20 - .../artifact/ant/AbstractArtifactTask.java | 463 ------------------ .../artifact/ant/AntDownloadMonitor.java | 67 --- .../artifact/ant/AntResolutionListener.java | 109 ----- .../maven/artifact/ant/Authentication.java | 43 -- .../maven/artifact/ant/DependenciesTask.java | 295 ----------- .../apache/maven/artifact/ant/DeployTask.java | 150 ------ .../maven/artifact/ant/InstallTask.java | 86 ---- .../ant/InstallWagonProviderTask.java | 131 ----- .../maven/artifact/ant/LocalRepository.java | 41 -- .../org/apache/maven/artifact/ant/Pom.java | 346 ------------- .../org/apache/maven/artifact/ant/Proxy.java | 44 -- .../maven/artifact/ant/RemoteRepository.java | 88 ---- .../apache/maven/artifact/ant/Repository.java | 80 --- .../maven/artifact/ant/RepositoryPolicy.java | 65 --- .../org/apache/maven/artifact/ant/antlib.xml | 17 - 19 files changed, 2381 deletions(-) delete mode 100755 maven-artifact-ant/pom.xml delete mode 100644 maven-artifact-ant/sample-build-test.pom delete mode 100644 maven-artifact-ant/sample.build.xml delete mode 100644 maven-artifact-ant/src/main/assembly/dep.xml delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntDownloadMonitor.java delete mode 100644 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java delete mode 100644 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Authentication.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DeployTask.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallTask.java delete mode 100644 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallWagonProviderTask.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/LocalRepository.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java delete mode 100644 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Proxy.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java delete mode 100755 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java delete mode 100644 maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RepositoryPolicy.java delete mode 100755 maven-artifact-ant/src/main/resources/org/apache/maven/artifact/ant/antlib.xml diff --git a/maven-artifact-ant/pom.xml b/maven-artifact-ant/pom.xml deleted file mode 100755 index 15a25ffc35..0000000000 --- a/maven-artifact-ant/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - maven - org.apache.maven - 2.1-SNAPSHOT - - 4.0.0 - maven-artifact-ant - Maven Tasks for Ant - - - - maven-assembly-plugin - 2.1-SNAPSHOT - - src/main/assembly/dep.xml - - - - - - - junit - junit - 3.8.1 - test - - - org.apache.maven - maven-project - 2.1-SNAPSHOT - - - junit - junit - - - - - org.apache.maven - maven-error-diagnostics - 2.1-SNAPSHOT - - - org.apache.maven - maven-settings - 2.1-SNAPSHOT - - - org.apache.maven.wagon - wagon-file - runtime - - - org.apache.maven.wagon - wagon-http-lightweight - runtime - - - ant - ant - 1.6.2 - - - org.apache.maven - maven-artifact-manager - 2.1-SNAPSHOT - - - junit - junit - - - - - org.codehaus.plexus - plexus-utils - - - org.apache.maven - maven-artifact - 2.1-SNAPSHOT - - - org.apache.maven.wagon - wagon-provider-api - - - org.codehaus.plexus - plexus-container-default - - - diff --git a/maven-artifact-ant/sample-build-test.pom b/maven-artifact-ant/sample-build-test.pom deleted file mode 100644 index dbf7a9219a..0000000000 --- a/maven-artifact-ant/sample-build-test.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - org.apache.maven.test - sample-build-test - 2.0-beta-4-SNAPSHOT - diff --git a/maven-artifact-ant/sample.build.xml b/maven-artifact-ant/sample.build.xml deleted file mode 100644 index 9034b67712..0000000000 --- a/maven-artifact-ant/sample.build.xml +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Artifact ID = ${my.maven.project.artifactId} - - Parent Artifact ID = ${my.maven.project.parent.artifactId} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - dummy - - - - - - - - - - - - - - Note: only works on snapshots! - - - - - - - - - - - - - - - - - Testing SCM Wagon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maven-artifact-ant/src/main/assembly/dep.xml b/maven-artifact-ant/src/main/assembly/dep.xml deleted file mode 100644 index d5e8d1beff..0000000000 --- a/maven-artifact-ant/src/main/assembly/dep.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - dep - - jar - - false - - - / - true - runtime - - ant:ant - - plexus:plexus-utils - - - - diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java deleted file mode 100755 index 8884ff4300..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java +++ /dev/null @@ -1,463 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.model.Model; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.Settings; -import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; -import org.apache.maven.usability.diagnostics.ErrorDiagnostics; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; -import org.codehaus.plexus.PlexusContainerException; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -/** - * Base class for artifact tasks. - * - * @author Brett Porter - * @version $Id$ - */ -public abstract class AbstractArtifactTask - extends Task -{ - private Settings settings; - - private PlexusContainer container; - - private Pom pom; - - private String pomRefId; - - private LocalRepository localRepository; - - protected ArtifactRepository createLocalArtifactRepository() - { - if ( localRepository == null ) - { - localRepository = getDefaultLocalRepository(); - } - - ArtifactRepositoryLayout repositoryLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, localRepository.getLayout() ); - - return new DefaultArtifactRepository( "local", "file://" + localRepository.getLocation(), repositoryLayout ); - } - - protected ArtifactRepository createRemoteArtifactRepository( RemoteRepository repository ) - { - ArtifactRepositoryLayout repositoryLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout() ); - - WagonManager manager = (WagonManager) lookup( WagonManager.ROLE ); - - Authentication authentication = repository.getAuthentication(); - if ( authentication != null ) - { - manager.addAuthenticationInfo( repository.getId(), authentication.getUserName(), authentication.getPassword(), - authentication.getPrivateKey(), authentication.getPassphrase() ); - } - - Proxy proxy = repository.getProxy(); - if ( proxy != null ) - { - manager.addProxy( proxy.getType(), proxy.getHost(), proxy.getPort(), proxy.getUserName(), - proxy.getPassword(), proxy.getNonProxyHosts() ); - } - - ArtifactRepositoryFactory repositoryFactory = null; - - ArtifactRepository artifactRepository; - - try - { - repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repository.getSnapshots() ); - ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repository.getReleases() ); - - artifactRepository = repositoryFactory.createArtifactRepository( repository.getId(), repository.getUrl(), - repositoryLayout, snapshots, releases ); - } - finally - { - try - { - getContainer().release( repositoryFactory ); - } - catch ( ComponentLifecycleException e ) - { - // TODO: Warn the user, or not? - } - } - - return artifactRepository; - } - - private static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy ) - { - boolean enabled = true; - String updatePolicy = null; - String checksumPolicy = null; - - if ( policy != null ) - { - enabled = policy.isEnabled(); - if ( policy.getUpdatePolicy() != null ) - { - updatePolicy = policy.getUpdatePolicy(); - } - if ( policy.getChecksumPolicy() != null ) - { - checksumPolicy = policy.getChecksumPolicy(); - } - } - - return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); - } - - protected LocalRepository getDefaultLocalRepository() - { - Settings settings = getSettings(); - LocalRepository localRepository = new LocalRepository(); - localRepository.setId( "local" ); - localRepository.setLocation( new File( settings.getLocalRepository() ) ); - return localRepository; - } - - protected synchronized Settings getSettings() - { - if ( settings == null ) - { - settings = new Settings(); - - File settingsFile = new File( System.getProperty( "user.home" ), ".ant/settings.xml" ); - if ( !settingsFile.exists() ) - { - settingsFile = new File( System.getProperty( "user.home" ), ".m2/settings.xml" ); - } - - if ( settingsFile.exists() ) - { - FileReader reader = null; - try - { - reader = new FileReader( settingsFile ); - - SettingsXpp3Reader modelReader = new SettingsXpp3Reader(); - - settings = modelReader.read( reader ); - } - catch ( IOException e ) - { - log( "Error reading settings file '" + settingsFile + "' - ignoring. Error was: " + e.getMessage(), - Project.MSG_WARN ); - } - catch ( XmlPullParserException e ) - { - log( "Error parsing settings file '" + settingsFile + "' - ignoring. Error was: " + e.getMessage(), - Project.MSG_WARN ); - } - finally - { - IOUtil.close( reader ); - } - } - - if ( StringUtils.isEmpty( settings.getLocalRepository() ) ) - { - String location = new File( System.getProperty( "user.home" ), ".m2/repository" ).getAbsolutePath(); - settings.setLocalRepository( location ); - } - } - return settings; - } - - protected RemoteRepository createAntRemoteRepository( org.apache.maven.model.Repository pomRepository ) - { - RemoteRepository r = createAntRemoteRepositoryBase( pomRepository ); - - if ( pomRepository.getSnapshots() != null ) - { - r.addSnapshots( convertRepositoryPolicy( pomRepository.getSnapshots() ) ); - } - if ( pomRepository.getReleases() != null ) - { - r.addReleases( convertRepositoryPolicy( pomRepository.getReleases() ) ); - } - - return r; - } - - protected RemoteRepository createAntRemoteRepositoryBase( org.apache.maven.model.RepositoryBase pomRepository ) - { - // TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon - // manager at the start like m2 does, and then match up by repository id - // As is, this could potentially cause a problem with 2 remote repositories with different authentication info - - RemoteRepository r = new RemoteRepository(); - r.setId( pomRepository.getId() ); - r.setUrl( pomRepository.getUrl() ); - r.setLayout( pomRepository.getLayout() ); - - Server server = getSettings().getServer( pomRepository.getId() ); - if ( server != null ) - { - r.addAuthentication( new Authentication( server ) ); - } - - org.apache.maven.settings.Proxy proxy = getSettings().getActiveProxy(); - if ( proxy != null ) - { - r.addProxy( new Proxy( proxy ) ); - } - - Mirror mirror = getSettings().getMirrorOf( pomRepository.getId() ); - if ( mirror != null ) - { - r.setUrl( mirror.getUrl() ); - } - return r; - } - - protected Object lookup( String role ) - { - try - { - return getContainer().lookup( role ); - } - catch ( ComponentLookupException e ) - { - throw new BuildException( "Unable to find component: " + role, e ); - } - } - - protected Object lookup( String role, String roleHint ) - { - try - { - return getContainer().lookup( role, roleHint ); - } - catch ( ComponentLookupException e ) - { - throw new BuildException( "Unable to find component: " + role + "[" + roleHint + "]", e ); - } - } - - protected static RemoteRepository getDefaultRemoteRepository() - { - // TODO: could we utilise the super POM for this? - RemoteRepository remoteRepository = new RemoteRepository(); - remoteRepository.setId( "central" ); - remoteRepository.setUrl( "http://repo1.maven.org/maven2" ); - RepositoryPolicy snapshots = new RepositoryPolicy(); - snapshots.setEnabled( false ); - remoteRepository.addSnapshots( snapshots ); - return remoteRepository; - } - - protected synchronized PlexusContainer getContainer() - { - if ( container == null ) - { - container = (PlexusContainer) getProject().getReference( PlexusContainer.class.getName() ); - - if ( container == null ) - { - try - { - ClassWorld classWorld = new ClassWorld(); - - classWorld.newRealm( "plexus.core", getClass().getClassLoader() ); - - container = new DefaultPlexusContainer( null, null, classWorld ); - - } - catch ( PlexusContainerException e ) - { - throw new BuildException( "Unable to start embedder", e ); - } - catch ( DuplicateRealmException e ) - { - throw new BuildException( "Unable to create embedder ClassRealm", e ); - } - - getProject().addReference( PlexusContainer.class.getName(),container ); - } - } - - return container; - } - - public Pom buildPom( MavenProjectBuilder projectBuilder, ArtifactRepository localArtifactRepository ) - { - if ( pomRefId != null && pom != null ) - { - throw new BuildException( "You cannot specify both a POM element and a pomrefid element" ); - } - - Pom pom = this.pom; - if ( pomRefId != null ) - { - pom = (Pom) getProject().getReference( pomRefId ); - if ( pom == null ) - { - throw new BuildException( "Reference '" + pomRefId + "' was not found." ); - } - } - - if ( pom != null ) - { - pom.initialise( projectBuilder, localArtifactRepository ); - } - return pom; - } - - protected Pom createDummyPom() - { - Model mavenModel = new Model(); - - mavenModel.setGroupId( "unspecified" ); - mavenModel.setArtifactId( "unspecified" ); - mavenModel.setVersion( "0.0" ); - mavenModel.setPackaging( "jar" ); - - MavenProject mavenProject = new MavenProject( mavenModel ); - - Pom pom = new Pom(); - - pom.setMavenProject( mavenProject ); - - return pom; - } - - public void diagnoseError( Throwable error ) - { - try - { - ErrorDiagnostics diagnostics = (ErrorDiagnostics) container.lookup( ErrorDiagnostics.ROLE ); - - StringBuffer message = new StringBuffer(); - - message.append( "An error has occurred while processing the Maven artifact tasks.\n" ); - message.append( " Diagnosis:\n\n" ); - - message.append( diagnostics.diagnose( error ) ); - - message.append( "\n\n" ); - - log( message.toString(), Project.MSG_INFO ); - } - catch ( ComponentLookupException e ) - { - log( "Failed to retrieve error diagnoser.", Project.MSG_DEBUG ); - } - } - - public void addPom( Pom pom ) - { - this.pom = pom; - } - - public String getPomRefId() - { - return pomRefId; - } - - public void setPomRefId( String pomRefId ) - { - this.pomRefId = pomRefId; - } - - public LocalRepository getLocalRepository() - { - return localRepository; - } - - public void addLocalRepository( LocalRepository localRepository ) - { - this.localRepository = localRepository; - } - - public void setProfiles( String profiles ) - { - if ( profiles != null ) - { - // TODO: not sure this is the best way to do this... -// System.setProperty( ProfileActivationUtils.ACTIVE_PROFILE_IDS, profiles ); - } - } - - protected Artifact createArtifact( Pom pom ) - { - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't - return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), - pom.getPackaging() ); - } - - private static RepositoryPolicy convertRepositoryPolicy( org.apache.maven.model.RepositoryPolicy pomRepoPolicy ) - { - RepositoryPolicy policy = new RepositoryPolicy(); - policy.setEnabled( pomRepoPolicy.isEnabled() ); - policy.setUpdatePolicy( pomRepoPolicy.getUpdatePolicy() ); - return policy; - } - - /** - * @noinspection RefusedBequest - */ - public void execute() - { - try - { - doExecute(); - } - catch ( BuildException e ) - { - diagnoseError( e ); - - throw e; - } - } - - protected abstract void doExecute(); -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntDownloadMonitor.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntDownloadMonitor.java deleted file mode 100755 index 78e758cb8f..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntDownloadMonitor.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.events.TransferEvent; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectComponent; - -/** - * Log wagon events in the ant tasks - * - * @author Brett Porter - * @version $Id$ - */ -public class AntDownloadMonitor - extends ProjectComponent - implements TransferListener -{ - public void debug( String s ) - { - log( s, Project.MSG_DEBUG ); - } - - public void transferCompleted( TransferEvent event ) - { - } - - public void transferError( TransferEvent event ) - { - log( event.getException().getMessage(), Project.MSG_ERR ); - } - - public void transferInitiated( TransferEvent event ) - { - String message = event.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; - - log( message + ": " + event.getResource().getName() ); - } - - public void transferProgress( TransferEvent event, byte[] bytes, int i ) - { - } - - public void transferStarted( TransferEvent event ) - { - long contentLength = event.getResource().getContentLength(); - if ( contentLength > 0 ) - { - log( "Transferring " + ( contentLength / 1024 ) + "K" ); - } - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java deleted file mode 100644 index 51b6b11582..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.resolver.ResolutionListener; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.tools.ant.Project; - -/** - * Show resolution information in Ant. - * - * @author Brett Porter - * @version $Id$ - */ -public class AntResolutionListener - implements ResolutionListener -{ - private String indent = ""; - - private final Project project; - - public AntResolutionListener( Project project ) - { - this.project = project; - } - - public void testArtifact( Artifact node ) - { - } - - public void startProcessChildren( Artifact artifact ) - { - indent += " "; - } - - public void endProcessChildren( Artifact artifact ) - { - indent = indent.substring( 2 ); - } - - public void includeArtifact( Artifact artifact ) - { - project.log( indent + artifact + " (selected)" ); - } - - public void omitForNearer( Artifact omitted, Artifact kept ) - { - project.log( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" ); - } - - public void omitForCycle( Artifact omitted ) - { - project.log( indent + omitted + " (removed - causes a cycle in the graph)" ); - } - - public void updateScope( Artifact artifact, String scope ) - { - project.log( indent + artifact + " (setting scope to: " + scope + ")" ); - } - - public void updateScopeCurrentPom( Artifact artifact, String scope ) - { - project.log( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() + - " wins)" ); - } - - public void selectVersionFromRange( Artifact artifact ) - { - project.log( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " + - artifact.getVersionRange() + ")" ); - } - - public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) - { - project.log( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " + - replacement.getVersionRange() + " to: " + newRange + " )" ); - } - - public void manageArtifact( Artifact artifact, Artifact replacement ) - { - String msg = indent + artifact; - msg += " ("; - if ( replacement.getVersion() != null ) - { - msg += "applying version: " + replacement.getVersion() + ";"; - } - if ( replacement.getScope() != null ) - { - msg += "applying scope: " + replacement.getScope(); - } - msg += ")"; - project.log( msg ); - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Authentication.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Authentication.java deleted file mode 100644 index b566abc275..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Authentication.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.authentication.AuthenticationInfo; -import org.apache.maven.settings.Server; - -/** - * Ant Wrapper for wagon authentication. - * - * @author Brett Porter - * @version $Id$ - */ -public class Authentication - extends AuthenticationInfo -{ - public Authentication() - { - super(); - } - - public Authentication( Server server ) - { - setUserName( server.getUsername() ); - setPassword( server.getPassword() ); - setPassphrase( server.getPassphrase() ); - setPrivateKey( server.getPrivateKey() ); - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java deleted file mode 100755 index c7133c9e7f..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java +++ /dev/null @@ -1,295 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.artifact.resolver.filter.TypeArtifactFilter; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Repository; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; -import org.apache.maven.project.artifact.MavenMetadataSource; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileList; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.Path; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Dependencies task, using maven-artifact. - * - * @author Brett Porter - * @version $Id$ - */ -public class DependenciesTask - extends AbstractArtifactTask -{ - private List dependencies = new ArrayList(); - - private List remoteRepositories = new ArrayList(); - - private String pathId; - - private String filesetId; - - private String useScope; - - private String type; - - private boolean verbose; - - protected void doExecute() - { - ArtifactRepository localRepo = createLocalArtifactRepository(); - - ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE ); - MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); - ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE ); - - List dependencies = this.dependencies; - - Pom pom = buildPom( projectBuilder, localRepo ); - if ( pom != null ) - { - if ( !dependencies.isEmpty() ) - { - throw new BuildException( "You cannot specify both dependencies and a pom in the dependencies task" ); - } - - dependencies = pom.getDependencies(); - - for ( Iterator i = pom.getRepositories().iterator(); i.hasNext(); ) - { - Repository pomRepository = (Repository) i.next(); - - remoteRepositories.add( createAntRemoteRepository( pomRepository ) ); - } - } - else - { - // we have to have some sort of Pom object in order to satisfy the requirements for building the - // originating Artifact below... - pom = createDummyPom(); - } - - if ( dependencies.isEmpty() ) - { - log( "There were no dependencies specified", Project.MSG_WARN ); - } - - log( "Resolving dependencies...", Project.MSG_VERBOSE ); - - WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE ); - wagonManager.setDownloadMonitor( new AntDownloadMonitor() ); - - ArtifactResolutionResult result; - Set artifacts; - try - { - artifacts = MavenMetadataSource.createArtifacts( artifactFactory, dependencies, null, null, null ); - - Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom - .getVersion(), pom.getPackaging() ); - - List listeners = Collections.EMPTY_LIST; - if ( verbose ) - { - listeners = Collections.singletonList( new AntResolutionListener( getProject() ) ); - } - - List remoteRepositories = getRemoteRepositories(); - - RemoteRepository remoteRepository = getDefaultRemoteRepository(); - remoteRepositories.add( remoteRepository ); - - List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories ); - - // TODO: managed dependencies - Map managedDependencies = Collections.EMPTY_MAP; - - ArtifactFilter filter = null; - if ( useScope != null ) - { - filter = new ScopeArtifactFilter( useScope ); - } - if ( type != null ) - { - TypeArtifactFilter typeArtifactFilter = new TypeArtifactFilter( type ); - if ( filter != null ) - { - AndArtifactFilter andFilter = new AndArtifactFilter(); - andFilter.add( filter ); - andFilter.add( typeArtifactFilter ); - filter = andFilter; - } - else - { - filter = typeArtifactFilter; - } - } - - result = resolver.resolveTransitively( artifacts, pomArtifact, managedDependencies, localRepo, - remoteArtifactRepositories, metadataSource, filter, listeners ); - } - catch ( ArtifactResolutionException e ) - { - throw new BuildException( "Unable to resolve artifact: " + e.getMessage(), e ); - } - catch ( ArtifactNotFoundException e ) - { - throw new BuildException( "Dependency not found: " + e.getMessage(), e ); - } - catch ( InvalidDependencyVersionException e ) - { - throw new BuildException( e.getMessage(), e ); - } - - if ( pathId != null && getProject().getReference( pathId ) != null ) - { - throw new BuildException( "Reference ID " + pathId + " already exists" ); - } - - if ( filesetId != null && getProject().getReference( filesetId ) != null ) - { - throw new BuildException( "Reference ID " + filesetId + " already exists" ); - } - - FileList fileList = new FileList(); - fileList.setDir( getLocalRepository().getLocation() ); - - FileSet fileSet = new FileSet(); - fileSet.setDir( fileList.getDir( getProject() ) ); - - if ( result.getArtifacts().isEmpty() ) - { - fileSet.createExclude().setName( "**/**" ); - } - else - { - for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - String filename = localRepo.pathOf( artifact ); - - FileList.FileName file = new FileList.FileName(); - file.setName( filename ); - - fileList.addConfiguredFile( file ); - - fileSet.createInclude().setName( filename ); - } - } - - if ( pathId != null ) - { - Path path = new Path( getProject() ); - path.addFilelist( fileList ); - getProject().addReference( pathId, path ); - } - - if ( filesetId != null ) - { - getProject().addReference( filesetId, fileSet ); - } - } - - private List createRemoteArtifactRepositories( List remoteRepositories ) - { - List list = new ArrayList(); - for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) - { - list.add( createRemoteArtifactRepository( (RemoteRepository) i.next() ) ); - } - return list; - } - - public List getRemoteRepositories() - { - return remoteRepositories; - } - - public void addRemoteRepository( RemoteRepository remoteRepository ) - { - remoteRepositories.add( remoteRepository ); - } - - public List getDependencies() - { - return dependencies; - } - - public void addDependency( Dependency dependency ) - { - dependencies.add( dependency ); - } - - public String getPathId() - { - return pathId; - } - - public void setPathId( String pathId ) - { - this.pathId = pathId; - } - - public String getFilesetId() - { - return filesetId; - } - - public void setFilesetId( String filesetId ) - { - this.filesetId = filesetId; - } - - public void setVerbose( boolean verbose ) - { - this.verbose = verbose; - } - - public void setUseScope( String useScope ) - { - this.useScope = useScope; - } - - public void setType( String type ) - { - this.type = type; - } - - -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DeployTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DeployTask.java deleted file mode 100755 index 6a79d72eda..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DeployTask.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeployer; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.model.DistributionManagement; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.tools.ant.BuildException; - -import java.io.File; - -/** - * Deploy task, using maven-artifact. - * - * @author Brett Porter - * @version $Id$ - */ -public class DeployTask - extends AbstractArtifactTask -{ - private RemoteRepository remoteRepository; - - private RemoteRepository remoteSnapshotRepository; - - private File file; - - protected void doExecute() - { - ArtifactRepository localRepo = createLocalArtifactRepository(); - MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); - - Pom pom = buildPom( builder, localRepo ); - - if ( pom == null ) - { - throw new BuildException( "A POM element is required to deploy to the repository" ); - } - - Artifact artifact = createArtifact( pom ); - - DistributionManagement distributionManagement = pom.getDistributionManagement(); - - if ( remoteSnapshotRepository == null && remoteRepository == null ) - { - if ( distributionManagement != null ) - { - if ( distributionManagement.getSnapshotRepository() != null ) - { - remoteSnapshotRepository = createAntRemoteRepositoryBase( distributionManagement - .getSnapshotRepository() ); - } - if ( distributionManagement.getRepository() != null ) - { - remoteRepository = createAntRemoteRepositoryBase( distributionManagement.getRepository() ); - } - } - } - - if ( remoteSnapshotRepository == null ) - { - remoteSnapshotRepository = remoteRepository; - } - - ArtifactRepository deploymentRepository; - if ( artifact.isSnapshot() && remoteSnapshotRepository != null ) - { - deploymentRepository = createRemoteArtifactRepository( remoteSnapshotRepository ); - } - else if ( remoteRepository != null ) - { - deploymentRepository = createRemoteArtifactRepository( remoteRepository ); - } - else - { - throw new BuildException( - "A distributionManagement element or remoteRepository element is required to deploy" ); - } - - // Deploy the POM - boolean isPomArtifact = "pom".equals( pom.getPackaging() ); - if ( !isPomArtifact ) - { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() ); - artifact.addMetadata( metadata ); - } - - log( "Deploying to " + deploymentRepository.getUrl() ); - ArtifactDeployer deployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); - try - { - if ( !isPomArtifact ) - { - deployer.deploy( file, artifact, deploymentRepository, localRepo ); - } - else - { - deployer.deploy( pom.getFile(), artifact, deploymentRepository, localRepo ); - } - } - catch ( ArtifactDeploymentException e ) - { - throw new BuildException( - "Error deploying artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); - } - } - - public RemoteRepository getRemoteRepository() - { - return remoteRepository; - } - - public void addRemoteSnapshotRepository( RemoteRepository remoteSnapshotRepository ) - { - this.remoteSnapshotRepository = remoteSnapshotRepository; - } - - public void addRemoteRepository( RemoteRepository remoteRepository ) - { - this.remoteRepository = remoteRepository; - } - - public File getFile() - { - return file; - } - - public void setFile( File file ) - { - this.file = file; - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallTask.java deleted file mode 100755 index dfe9c826de..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallTask.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.installer.ArtifactInstallationException; -import org.apache.maven.artifact.installer.ArtifactInstaller; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.tools.ant.BuildException; - -import java.io.File; - -/** - * Install task, using maven-artifact. - * - * @author Brett Porter - * @version $Id$ - * @todo should be able to incorporate into the install mojo? - */ -public class InstallTask - extends AbstractArtifactTask -{ - private File file; - - protected void doExecute() - { - ArtifactRepository localRepo = createLocalArtifactRepository(); - - MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); - Pom pom = buildPom( builder, localRepo ); - - Artifact artifact = createArtifact( pom ); - - boolean isPomArtifact = "pom".equals( pom.getPackaging() ); - if ( !isPomArtifact ) - { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() ); - artifact.addMetadata( metadata ); - } - - ArtifactInstaller installer = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); - try - { - if ( !isPomArtifact ) - { - installer.install( file, artifact, localRepo ); - } - else - { - installer.install( pom.getFile(), artifact, localRepo ); - } - } - catch ( ArtifactInstallationException e ) - { - throw new BuildException( - "Error installing artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); - } - } - - public File getFile() - { - return file; - } - - public void setFile( File file ) - { - this.file = file; - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallWagonProviderTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallWagonProviderTask.java deleted file mode 100644 index fd8a121468..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/InstallWagonProviderTask.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.Artifact; -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.project.artifact.MavenMetadataSource; -import org.apache.tools.ant.BuildException; -import org.codehaus.plexus.PlexusContainerException; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * Ant Wrapper for wagon provider installation. - * - * @author Brett Porter - * @version $Id$ - */ -public class InstallWagonProviderTask - extends AbstractArtifactTask -{ - private String artifactId; - - private String version; - - private static final String WAGON_GROUP_ID = "org.apache.maven.wagon"; - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public void doExecute() - throws BuildException - { - MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE ); - - ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE ); - ArtifactRepository artifactRepository = createRemoteArtifactRepository( getDefaultRemoteRepository() ); - List remoteRepositories = Collections.singletonList( artifactRepository ); - - VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new BuildException( "Unable to get extension '" + - ArtifactUtils.versionlessKey( WAGON_GROUP_ID, artifactId ) + "' because version '" + version + - " is invalid: " + e.getMessage(), e ); - } - - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - Artifact providerArtifact = factory.createExtensionArtifact( WAGON_GROUP_ID, artifactId, versionRange ); - - ArtifactResolutionResult result; - try - { - result = resolver.resolveTransitively( Collections.singleton( providerArtifact ), - createArtifact( createDummyPom() ), createLocalArtifactRepository(), - remoteRepositories, metadataSource, null ); - } - catch ( ArtifactResolutionException e ) - { - throw new BuildException( "Error downloading wagon provider from the remote repository: " + e.getMessage(), - e ); - } - catch ( ArtifactNotFoundException e ) - { - throw new BuildException( "Unable to locate wagon provider in remote repository: " + e.getMessage(), e ); - } - - log( "Installing provider: " + providerArtifact ); - - try - { - for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); ) - { - Artifact a = (Artifact) i.next(); - - getContainer().addJarResource( a.getFile() ); - } - } - catch ( PlexusContainerException e ) - { - throw new BuildException( "Unable to locate wagon provider in remote repository", e ); - } - } - -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/LocalRepository.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/LocalRepository.java deleted file mode 100755 index 4f69dc1758..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/LocalRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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; - -/** - * Local repository type. - * - * @author Brett Porter - * @version $Id$ - */ -public class LocalRepository - extends Repository -{ - private File location; - - public File getLocation() - { - return ( (LocalRepository) getInstance() ).location; - } - - public void setLocation( File location ) - { - this.location = location; - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java deleted file mode 100755 index e13b87812d..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java +++ /dev/null @@ -1,346 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.artifact.repository.ArtifactRepository; -import org.apache.maven.model.Build; -import org.apache.maven.model.CiManagement; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.DistributionManagement; -import org.apache.maven.model.IssueManagement; -import org.apache.maven.model.Organization; -import org.apache.maven.model.Reporting; -import org.apache.maven.model.Scm; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.PropertyHelper; -import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; - -import java.io.File; - -/** - * A POM typedef. - * - * Also an Ant Task that registers a handler called POMPropertyHelper - * that intercepts all calls to property value resolution and replies instead - * of Ant to properties that start with the id of the pom. - * - * Example: - * ${maven.project.artifactId} - * - * @author Brett Porter - * @author Nicola Ken Barozzi - * @version $Id$ - */ -public class Pom - extends AbstractArtifactTask -{ - private String refid; - - private String antId; - - private MavenProject mavenProject; - - private File file; - - /** - * The property interceptor. - */ - private final POMPropertyHelper helper = new POMPropertyHelper(); - - public String getRefid() - { - return refid; - } - - public void setRefid( String refid ) - { - this.refid = refid; - } - - public void setId( String id ) - { - this.antId = id; - } - - protected Pom getInstance() - { - Pom instance = this; - if ( refid != null ) - { - instance = (Pom) getProject().getReference( refid ); - if ( instance == null ) - { - throw new BuildException( "Invalid reference: '" + refid + "'" ); - } - } - return instance; - } - - public void setMavenProject( MavenProject mavenProject ) - { - getInstance().mavenProject = mavenProject; - } - - public File getFile() - { - return getInstance().file; - } - - public void setFile( File file ) - { - this.file = file; - } - - void initialise( MavenProjectBuilder builder, ArtifactRepository localRepository ) - { - if ( mavenProject != null ) - { - log( "POM is already initialized for: " + mavenProject.getId(), Project.MSG_DEBUG ); - - return; - } - // TODO: should this be in execute() too? Would that work when it is used as a type? - if ( file != null ) - { - try - { - // TODO: should the profiles be constructed and passed in here? From Ant, or perhaps settings? - mavenProject = builder.build( file, localRepository, null ); - } - catch ( ProjectBuildingException e ) - { - throw new BuildException( "Unable to build project: " + file, e ); - } - } - else if ( refid != null ) - { - getInstance().initialise( builder, localRepository ); - } - } - - protected MavenProject getMavenProject() - { - return getInstance().mavenProject; - } - - public String getArtifactId() - { - return getMavenProject().getArtifactId(); - } //-- String getArtifactId() - - public Build getBuild() - { - return getMavenProject().getBuild(); - } //-- Build getBuild() - - public CiManagement getCiManagement() - { - return getMavenProject().getCiManagement(); - } //-- CiManagement getCiManagement() - - public java.util.List getContributors() - { - return getMavenProject().getContributors(); - } //-- java.util.List getContributors() - - public java.util.List getDependencies() - { - return getMavenProject().getDependencies(); - } //-- java.util.List getDependencies() - - public DependencyManagement getDependencyManagement() - { - return getMavenProject().getDependencyManagement(); - } //-- DependencyManagement getDependencyManagement() - - public String getDescription() - { - return getMavenProject().getDescription(); - } //-- String getDescription() - - public java.util.List getDevelopers() - { - return getMavenProject().getDevelopers(); - } //-- java.util.List getDevelopers() - - public DistributionManagement getDistributionManagement() - { - return getMavenProject().getDistributionManagement(); - } //-- DistributionManagement getDistributionManagement() - - public String getGroupId() - { - return getMavenProject().getGroupId(); - } //-- String getGroupId() - - public String getInceptionYear() - { - return getMavenProject().getInceptionYear(); - } //-- String getInceptionYear() - - public IssueManagement getIssueManagement() - { - return getMavenProject().getIssueManagement(); - } //-- IssueManagement getIssueManagement() - - public java.util.List getLicenses() - { - return getMavenProject().getLicenses(); - } //-- java.util.List getLicenses() - - public java.util.List getMailingLists() - { - return getMavenProject().getMailingLists(); - } //-- java.util.List getMailingLists() - - public String getModelVersion() - { - return getMavenProject().getModelVersion(); - } //-- String getModelVersion() - - public java.util.List getModules() - { - return getMavenProject().getModules(); - } //-- java.util.List getModules() - - public String getName() - { - return getMavenProject().getName(); - } //-- String getName() - - public Organization getOrganization() - { - return getMavenProject().getOrganization(); - } //-- Organization getOrganization() - - public String getPackaging() - { - return getMavenProject().getPackaging(); - } //-- String getPackaging() - - public java.util.List getPluginRepositories() - { - return getMavenProject().getPluginRepositories(); - } //-- java.util.List getPluginRepositories() - - public Reporting getReporting() - { - return getMavenProject().getReporting(); - } //-- Reports getReports() - - public java.util.List getRepositories() - { - return getMavenProject().getRepositories(); - } //-- java.util.List getRepositories() - - public Scm getScm() - { - return getMavenProject().getScm(); - } //-- Scm getScm() - - public String getUrl() - { - return getMavenProject().getUrl(); - } //-- String getUrl() - - public String getVersion() - { - return getMavenProject().getVersion(); - } //-- String getVersion() - - public String getId() - { - return getMavenProject().getId(); - } - - /** - * Registers POMPropertyHelper as a property interceptor - */ - protected void doExecute() - { - ArtifactRepository localRepo = createLocalArtifactRepository(); - MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); - initialise( projectBuilder, localRepo ); - - Project project = getProject(); - - // Add a reference to this task/type - project.addReference( antId, this ); - - // Register the property interceptor - PropertyHelper phelper = PropertyHelper.getPropertyHelper( project ); - helper.setNext( phelper.getNext() ); - helper.setProject( project ); - phelper.setNext( helper ); - } - - /** - * The property interceptor that handles the calls for "pom." properties - */ - private class POMPropertyHelper - extends PropertyHelper - { - /** - * The method that gets called by Ant with every request of property - */ - public Object getPropertyHook( String ns, String name, boolean user ) - { - - String prefix = antId + "."; - - if ( !name.startsWith( prefix ) ) - { - // pass on to next interceptor - return super.getPropertyHook( ns, name, user ); - } - try - { - // else handle the property resolution - String expression = name.substring( prefix.length() ); - return getPOMValue( "project." + expression ); - - } - catch ( Exception ex ) - { - ex.printStackTrace(); - return null; - } - } - - private Object getPOMValue( String expression ) - { - Object value = null; - - try - { - value = ReflectionValueExtractor.evaluate( expression, getMavenProject() ); - } - catch ( Exception e ) - { - throw new BuildException( "Error extracting expression from POM", e ); - } - - return value; - } - - } - -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Proxy.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Proxy.java deleted file mode 100644 index 47e4bb8534..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Proxy.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.proxy.ProxyInfo; - -/** - * Ant Wrapper for wagon proxy. - * - * @author Brett Porter - * @version $Id$ - */ -public class Proxy - extends ProxyInfo -{ - public Proxy() - { - super(); - } - - public Proxy( org.apache.maven.settings.Proxy proxy ) - { - setHost( proxy.getHost() ); - setPort( proxy.getPort() ); - setNonProxyHosts( proxy.getNonProxyHosts() ); - setUserName( proxy.getUsername() ); - setPassword( proxy.getPassword() ); - setType( proxy.getProtocol() ); - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java deleted file mode 100755 index 3ab77f6dbd..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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. - */ - -/** - * Remote repository type. - * - * @author Brett Porter - * @version $Id$ - */ -public class RemoteRepository - extends Repository -{ - private String url; - - private Authentication authentication; - - private Proxy proxy; - - private RepositoryPolicy snapshots; - - private RepositoryPolicy releases; - - public String getUrl() - { - return ( (RemoteRepository) getInstance() ).url; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public Authentication getAuthentication() - { - return authentication; - } - - public void addAuthentication( Authentication authentication ) - { - this.authentication = authentication; - } - - public void addProxy( Proxy proxy ) - { - this.proxy = proxy; - } - - public Proxy getProxy() - { - return ( (RemoteRepository) getInstance() ).proxy; - } - - public RepositoryPolicy getSnapshots() - { - return ( (RemoteRepository) getInstance() ).snapshots; - } - - public void addSnapshots( RepositoryPolicy snapshots ) - { - this.snapshots = snapshots; - } - - public RepositoryPolicy getReleases() - { - return ( (RemoteRepository) getInstance() ).releases; - } - - public void addReleases( RepositoryPolicy releases ) - { - this.releases = releases; - } - -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java deleted file mode 100755 index b4182fb798..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.tools.ant.BuildException; -import org.apache.tools.ant.ProjectComponent; - -/** - * Base class for a repository. - * - * @author Brett Porter - * @version $Id$ - */ -public abstract class Repository - extends ProjectComponent -{ - private String id; - - private String refid; - - private String layout = "default"; - - public String getId() - { - if ( getInstance().id == null ) - { - getInstance().setId( "remote" ); - } - return getInstance().id; - } - - public void setId( String id ) - { - this.id = id; - } - - public String getRefid() - { - return refid; - } - - public void setRefid( String refid ) - { - this.refid = refid; - } - - protected Repository getInstance() - { - Repository instance = this; - if ( refid != null ) - { - instance = (Repository) getProject().getReference( refid ); - } - return instance; - } - - public String getLayout() - { - return getInstance().layout; - } - - public void setLayout( String layout ) - { - this.layout = layout; - } -} diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RepositoryPolicy.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RepositoryPolicy.java deleted file mode 100644 index 312b2514e3..0000000000 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RepositoryPolicy.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.maven.artifact.ant; - -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed 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.tools.ant.ProjectComponent; - -/** - * Base class for a repository. - * - * @author Brett Porter - * @version $Id$ - */ -public class RepositoryPolicy - extends ProjectComponent -{ - private String updatePolicy; - - private String checksumPolicy; - - private boolean enabled = true; - - public String getUpdatePolicy() - { - return updatePolicy; - } - - public void setUpdatePolicy( String updatePolicy ) - { - this.updatePolicy = updatePolicy; - } - - public boolean isEnabled() - { - return enabled; - } - - public void setEnabled( boolean enabled ) - { - this.enabled = enabled; - } - - public String getChecksumPolicy() - { - return checksumPolicy; - } - - public void setChecksumPolicy( String checksumPolicy ) - { - this.checksumPolicy = checksumPolicy; - } -} diff --git a/maven-artifact-ant/src/main/resources/org/apache/maven/artifact/ant/antlib.xml b/maven-artifact-ant/src/main/resources/org/apache/maven/artifact/ant/antlib.xml deleted file mode 100755 index 50b31d3cd7..0000000000 --- a/maven-artifact-ant/src/main/resources/org/apache/maven/artifact/ant/antlib.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - -