From 53acf2858f1377f867f4360ad7f05577305aef3a Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Gonzalez Date: Sat, 2 Jun 2007 00:05:35 +0000 Subject: [PATCH] [MNG-2943] Avoid using package names used in other artifacts: org.apache.maven git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@543670 13f79535-47bb-0310-9956-ffa450edef68 --- maven-project/pom.xml | 20 +- .../org/apache/maven/DefaultMavenTools.java | 181 ++++-------------- .../java/org/apache/maven/MavenTools.java | 23 +-- .../project/DefaultMavenProjectBuilder.java | 1 - .../maven/project/DefaultMavenTools.java | 174 +++++++++++++++++ .../org/apache/maven/project/MavenTools.java | 49 +++++ .../model/DefaultModelLineageBuilder.java | 2 +- .../build/profile/DefaultProfileAdvisor.java | 2 +- .../resources/META-INF/plexus/components.xml | 17 +- .../maven/project/ProjectClasspathTest.xml | 4 +- .../canonical/CanonicalProjectBuilderTest.xml | 4 +- 11 files changed, 303 insertions(+), 174 deletions(-) create mode 100644 maven-project/src/main/java/org/apache/maven/project/DefaultMavenTools.java create mode 100644 maven-project/src/main/java/org/apache/maven/project/MavenTools.java diff --git a/maven-project/pom.xml b/maven-project/pom.xml index 6b2c2c3217..3af97c36a4 100644 --- a/maven-project/pom.xml +++ b/maven-project/pom.xml @@ -19,8 +19,9 @@ specific language governing permissions and limitations under the License. --> - + maven org.apache.maven @@ -71,4 +72,19 @@ under the License. test + + + + + org.apache.felix + maven-bundle-plugin + + + + !org.apache.maven,* + + + + + diff --git a/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java b/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java index fc50f753bd..31a8b86e40 100644 --- a/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java +++ b/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java @@ -1,171 +1,70 @@ package org.apache.maven; /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ +import java.util.List; + import org.apache.maven.artifact.InvalidRepositoryException; 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.layout.ArtifactRepositoryLayout; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Repository; -import org.apache.maven.model.RepositoryBase; -import org.apache.maven.model.RepositoryPolicy; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** @author Jason van Zyl */ +/** + * @deprecated use {@link org.apache.maven.project.DefaultMavenTools} + * @author Jason van Zyl + */ public class DefaultMavenTools - implements MavenTools, Contextualizable + extends org.apache.maven.project.DefaultMavenTools + implements MavenTools { - private ArtifactRepositoryLayout repositoryLayout; - - private ArtifactRepositoryFactory artifactRepositoryFactory; - - private PlexusContainer container; - - // ---------------------------------------------------------------------------- - // Code snagged from ProjectUtils: this will have to be moved somewhere else - // but just trying to collect it all in one place right now. - // ---------------------------------------------------------------------------- + private org.apache.maven.project.MavenTools mavenTools; + /** + * @see org.apache.maven.project.MavenTools#buildArtifactRepositories(java.util.List) + */ public List buildArtifactRepositories( List repositories ) throws InvalidRepositoryException { - List repos = new ArrayList(); - - for ( Iterator i = repositories.iterator(); i.hasNext(); ) - { - Repository mavenRepo = (Repository) i.next(); - - ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo ); - - if ( !repos.contains( artifactRepo ) ) - { - repos.add( artifactRepo ); - } - } - return repos; - } - - public ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo ) - throws InvalidRepositoryException - { - if ( repo != null ) - { - String id = repo.getId(); - String url = repo.getUrl(); - - // TODO: make this a map inside the factory instead, so no lookup needed - ArtifactRepositoryLayout layout = getRepositoryLayout( repo ); - - return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, - repo.isUniqueVersion() ); - } - else - { - return null; - } + return getMavenTools().buildArtifactRepositories( repositories ); } + /** + * @see org.apache.maven.project.MavenTools#buildArtifactRepository(org.apache.maven.model.Repository) + */ public ArtifactRepository buildArtifactRepository( Repository repo ) throws InvalidRepositoryException { - if ( repo != null ) - { - String id = repo.getId(); - String url = repo.getUrl(); - - // TODO: make this a map inside the factory instead, so no lookup needed - ArtifactRepositoryLayout layout = getRepositoryLayout( repo ); - - ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); - - ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); - - return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases ); - } - else - { - return null; - } + return getMavenTools().buildArtifactRepository( repo ); } - public 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 ); - } - - private ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo ) + /** + * @see org.apache.maven.project.MavenTools#buildDeploymentArtifactRepository(org.apache.maven.model.DeploymentRepository) + */ + public ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo ) throws InvalidRepositoryException { - String layout = mavenRepo.getLayout(); - - ArtifactRepositoryLayout repositoryLayout; - try - { - repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout ); - } - catch ( ComponentLookupException e ) - { - throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout + - "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e ); - } - return repositoryLayout; + return getMavenTools().buildDeploymentArtifactRepository( repo ); } - // ---------------------------------------------------------------------------- - // Lifecycle - // ---------------------------------------------------------------------------- - - public void contextualize( Context context ) - throws ContextException + private org.apache.maven.project.MavenTools getMavenTools() { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + if ( mavenTools == null ) + { + mavenTools = new org.apache.maven.project.DefaultMavenTools(); + } + return mavenTools; } } diff --git a/maven-project/src/main/java/org/apache/maven/MavenTools.java b/maven-project/src/main/java/org/apache/maven/MavenTools.java index ad34776674..ae0aba404e 100644 --- a/maven-project/src/main/java/org/apache/maven/MavenTools.java +++ b/maven-project/src/main/java/org/apache/maven/MavenTools.java @@ -19,30 +19,11 @@ package org.apache.maven; * under the License. */ -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.model.DeploymentRepository; -import org.apache.maven.model.Repository; - -import java.util.List; /** + * @deprecated use {@link org.apache.maven.project.MavenTools} * @author Jason van Zyl */ -public interface MavenTools +public interface MavenTools extends org.apache.maven.project.MavenTools { - String ROLE = MavenTools.class.getName(); - - // ---------------------------------------------------------------------------- - // Methods taken from ProjectUtils - // ---------------------------------------------------------------------------- - - List buildArtifactRepositories( List repositories ) - throws InvalidRepositoryException; - - ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo ) - throws InvalidRepositoryException; - - ArtifactRepository buildArtifactRepository( Repository repo ) - throws InvalidRepositoryException; } diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 777c69a3d8..a28a051d97 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -19,7 +19,6 @@ package org.apache.maven.project; * under the License. */ -import org.apache.maven.MavenTools; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactStatus; import org.apache.maven.artifact.ArtifactUtils; diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenTools.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenTools.java new file mode 100644 index 0000000000..3906aec6db --- /dev/null +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenTools.java @@ -0,0 +1,174 @@ +package org.apache.maven.project; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.InvalidRepositoryException; +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.layout.ArtifactRepositoryLayout; +import org.apache.maven.model.DeploymentRepository; +import org.apache.maven.model.Repository; +import org.apache.maven.model.RepositoryBase; +import org.apache.maven.model.RepositoryPolicy; +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.ContextException; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Jason van Zyl + * @since 2.1 + */ +public class DefaultMavenTools + implements MavenTools, Contextualizable +{ + private ArtifactRepositoryLayout repositoryLayout; + + private ArtifactRepositoryFactory artifactRepositoryFactory; + + private PlexusContainer container; + + // ---------------------------------------------------------------------------- + // Code snagged from ProjectUtils: this will have to be moved somewhere else + // but just trying to collect it all in one place right now. + // ---------------------------------------------------------------------------- + + public List buildArtifactRepositories( List repositories ) + throws InvalidRepositoryException + { + List repos = new ArrayList(); + + for ( Iterator i = repositories.iterator(); i.hasNext(); ) + { + Repository mavenRepo = (Repository) i.next(); + + ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo ); + + if ( !repos.contains( artifactRepo ) ) + { + repos.add( artifactRepo ); + } + } + return repos; + } + + public ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo ) + throws InvalidRepositoryException + { + if ( repo != null ) + { + String id = repo.getId(); + String url = repo.getUrl(); + + // TODO: make this a map inside the factory instead, so no lookup needed + ArtifactRepositoryLayout layout = getRepositoryLayout( repo ); + + return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, + repo.isUniqueVersion() ); + } + else + { + return null; + } + } + + public ArtifactRepository buildArtifactRepository( Repository repo ) + throws InvalidRepositoryException + { + if ( repo != null ) + { + String id = repo.getId(); + String url = repo.getUrl(); + + // TODO: make this a map inside the factory instead, so no lookup needed + ArtifactRepositoryLayout layout = getRepositoryLayout( repo ); + + ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); + + ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); + + return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases ); + } + else + { + return null; + } + } + + public 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 ); + } + + private ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo ) + throws InvalidRepositoryException + { + String layout = mavenRepo.getLayout(); + + ArtifactRepositoryLayout repositoryLayout; + try + { + repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout ); + } + catch ( ComponentLookupException e ) + { + throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout + + "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e ); + } + return repositoryLayout; + } + + // ---------------------------------------------------------------------------- + // Lifecycle + // ---------------------------------------------------------------------------- + + public void contextualize( Context context ) + throws ContextException + { + container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + } +} diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenTools.java b/maven-project/src/main/java/org/apache/maven/project/MavenTools.java new file mode 100644 index 0000000000..8adf5105b1 --- /dev/null +++ b/maven-project/src/main/java/org/apache/maven/project/MavenTools.java @@ -0,0 +1,49 @@ +package org.apache.maven.project; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.InvalidRepositoryException; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.model.DeploymentRepository; +import org.apache.maven.model.Repository; + +import java.util.List; + +/** + * @author Jason van Zyl + * @since 2.1 + */ +public interface MavenTools +{ + String ROLE = MavenTools.class.getName(); + + // ---------------------------------------------------------------------------- + // Methods taken from ProjectUtils + // ---------------------------------------------------------------------------- + + List buildArtifactRepositories( List repositories ) + throws InvalidRepositoryException; + + ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo ) + throws InvalidRepositoryException; + + ArtifactRepository buildArtifactRepository( Repository repo ) + throws InvalidRepositoryException; +} diff --git a/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java b/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java index d3b8db49e5..8f33cfb1ac 100644 --- a/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java @@ -19,7 +19,6 @@ package org.apache.maven.project.build.model; * under the License. */ -import org.apache.maven.MavenTools; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -32,6 +31,7 @@ import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.profiles.ProfileManager; +import org.apache.maven.project.MavenTools; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.build.ProjectBuildCache; import org.apache.maven.project.build.profile.ProfileAdvisor; diff --git a/maven-project/src/main/java/org/apache/maven/project/build/profile/DefaultProfileAdvisor.java b/maven-project/src/main/java/org/apache/maven/project/build/profile/DefaultProfileAdvisor.java index 0b94a2728a..0d0aa1dfde 100644 --- a/maven-project/src/main/java/org/apache/maven/project/build/profile/DefaultProfileAdvisor.java +++ b/maven-project/src/main/java/org/apache/maven/project/build/profile/DefaultProfileAdvisor.java @@ -19,7 +19,6 @@ package org.apache.maven.project.build.profile; * under the License. */ -import org.apache.maven.MavenTools; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -32,6 +31,7 @@ import org.apache.maven.profiles.ProfileManager; import org.apache.maven.profiles.ProfilesConversionUtils; import org.apache.maven.profiles.ProfilesRoot; import org.apache.maven.profiles.activation.ProfileActivationException; +import org.apache.maven.project.MavenTools; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.injection.ProfileInjector; import org.codehaus.plexus.PlexusConstants; diff --git a/maven-project/src/main/resources/META-INF/plexus/components.xml b/maven-project/src/main/resources/META-INF/plexus/components.xml index a29821cde1..2cc949aefd 100644 --- a/maven-project/src/main/resources/META-INF/plexus/components.xml +++ b/maven-project/src/main/resources/META-INF/plexus/components.xml @@ -58,7 +58,7 @@ under the License. org.apache.maven.project.build.profile.DefaultProfileAdvisor - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools org.apache.maven.profiles.MavenProfilesBuilder @@ -85,7 +85,7 @@ under the License. org.apache.maven.artifact.factory.ArtifactFactory - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools org.apache.maven.artifact.resolver.ArtifactResolver @@ -188,7 +188,7 @@ under the License. org.apache.maven.artifact.manager.WagonManager - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools @@ -351,9 +351,20 @@ under the License. + org.apache.maven.MavenTools org.apache.maven.DefaultMavenTools + + + org.apache.maven.project.MavenTools + + + + + + org.apache.maven.project.MavenTools + org.apache.maven.project.DefaultMavenTools org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout diff --git a/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml b/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml index ecb2de7f00..dfeec9d0b6 100644 --- a/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml +++ b/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml @@ -44,7 +44,7 @@ under the License. org.apache.maven.project.build.profile.DefaultProfileAdvisor - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools org.apache.maven.profiles.MavenProfilesBuilder @@ -117,7 +117,7 @@ under the License. default - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools diff --git a/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml b/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml index 99e367931c..de7a3f00b0 100644 --- a/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml +++ b/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml @@ -62,7 +62,7 @@ under the License. org.apache.maven.project.build.profile.DefaultProfileAdvisor - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools org.apache.maven.profiles.MavenProfilesBuilder @@ -111,7 +111,7 @@ under the License. org.apache.maven.artifact.resolver.ArtifactResolver - org.apache.maven.MavenTools + org.apache.maven.project.MavenTools org.apache.maven.context.BuildContextManager