Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] Require maven 3.1.1 #6

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 6 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</distributionManagement>

<properties>
<mavenVersion>3.0</mavenVersion>
<mavenVersion>3.1.1</mavenVersion>
<javaVersion>7</javaVersion>
<project.build.outputTimestamp>2020-02-07T09:03:59Z</project.build.outputTimestamp>
</properties>
Expand All @@ -70,36 +70,13 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.4</version>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.13.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand All @@ -115,14 +92,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/DefaultDependencyTreeBuilderTest*</exclude><!-- FIXME: conflict on DefaultArtifactFactory between maven-core 3.x and maven-artifact 2.x -->
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
Expand All @@ -140,11 +109,8 @@
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<pomExcludes> <!-- Tree ITs, must be transformed to graph ITs -->
<pomExclude>maven-version/pom.xml</pomExclude>
<pomExclude>mshared-167/pom.xml</pomExclude>
<pomExclude>reactor/pom.xml</pomExclude>
<pomExclude>verbose/pom.xml</pomExclude>
<pomExcludes>
<pomExclude>verbose/pom.xml</pomExclude><!-- no verbose option for 3.x yet -->
</pomExcludes>
<properties>
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
Expand Down Expand Up @@ -173,7 +139,8 @@
These files contains the expected output of this component and can not contain a license header.
-->
<exclude>src/it/*/expected*.txt</exclude>
</excludes>
<exclude>src/it/**/*.iml</exclude>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should really .gitignore these

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right!

</excludes>
</configuration>
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion src/it/maven-version/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.1.2</version>
<configuration>
<outputFile>target/tree.txt</outputFile>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/it/mshared-167/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.1.2</version>
<configuration>
<outputFile>${outputFile}</outputFile>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/it/reactor/module-z-deps-y/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
Expand Down
1 change: 1 addition & 0 deletions src/it/verbose/expected-verbose.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ org.apache.maven.its.dependency-tree:verbose:jar:1.0-SNAPSHOT
| \- (org.apache.xmlgraphics:batik-xml:jar:1.7:compile - omitted for duplicate)
+- (org.apache.xmlgraphics:batik-bridge:jar:1.7:compile - omitted for cycle)
+- org.apache.xmlgraphics:batik-script:jar:1.7:compile
| \- org.apache.xmlgraphics:batik-js:jar:1.7:compile
+- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
| +- (org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile - omitted for cycle)
| +- (org.apache.xmlgraphics:batik-anim:jar:1.7:compile - omitted for duplicate)
Expand Down
2 changes: 1 addition & 1 deletion src/it/verbose/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Collection;

/**
* Maven project dependency graph builder API, neutral against Maven 2 or Maven 3.
* Maven project dependency graph builder API, based on Maven 3.1+.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this specifically the point of this API? i.e. to bridge between 2 and 3? or was that a different artifact?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was for maven-artifact-transfer. Yes initially that was a bridge but because now prerequisite is maven 3.1.1, no longer need old stuff here
@rfscholte

*
* @author Hervé Boutemy
* @since 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,122 +19,19 @@
* under the License.
*/

import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
import org.apache.maven.shared.dependency.graph.DependencyNode;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;

import java.util.Collection;

/**
* Default dependency graph builder that detects current Maven version to delegate to either Maven 3.0 or 3.1+ specific
* code.
* Default dependency graph builder based on Maven 3.1+ specific implementation code.
*
* @see Maven3DependencyGraphBuilder
* @see Maven31DependencyGraphBuilder
* @author Hervé Boutemy
* @since 2.0
*/
@Component( role = DependencyGraphBuilder.class )
public class DefaultDependencyGraphBuilder
extends AbstractLogEnabled
implements DependencyGraphBuilder, Contextualizable
extends Maven31DependencyGraphBuilder
{
protected PlexusContainer container;

/**
* Builds a dependency graph.
*
* @param buildingRequest the buildingRequest
* @param filter artifact filter (can be <code>null</code>)
* @return DependencyNode containing the dependency graph.
* @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
*/
@Override
public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter )
throws DependencyGraphBuilderException
{
return buildDependencyGraph( buildingRequest, filter, null );
}

/**
* Builds a dependency graph.
*
* @param filter artifact filter (can be <code>null</code>)
* @param reactorProjects Collection of those projects contained in the reactor (can be <code>null</code>)
* @return DependencyNode containing the dependency graph.
* @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
*/
@Override
public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter filter,
Collection<MavenProject> reactorProjects )
throws DependencyGraphBuilderException
{
try
{
String hint = isMaven31() ? "maven31" : "maven3";

DependencyGraphBuilder effectiveGraphBuilder =
(DependencyGraphBuilder) container.lookup( DependencyGraphBuilder.class.getCanonicalName(), hint );

if ( getLogger().isDebugEnabled() )
{
MavenProject project = buildingRequest.getProject();

getLogger().debug( "building " + hint + " dependency graph for " + project.getId() + " with "
+ effectiveGraphBuilder.getClass().getSimpleName() );
}

return effectiveGraphBuilder.buildDependencyGraph( buildingRequest, filter, reactorProjects );
}
catch ( ComponentLookupException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
}
}

/**
* @return true if the current Maven version is Maven 3.1.
*/
protected static boolean isMaven31()
{
return canFindCoreClass( "org.eclipse.aether.artifact.Artifact" ); // Maven 3.1 specific
}

private static boolean canFindCoreClass( String className )
{
try
{
Thread.currentThread().getContextClassLoader().loadClass( className );

return true;
}
catch ( ClassNotFoundException e )
{
return false;
}
}

/**
* Injects the Plexus content.
*
* @param context Plexus context to inject.
* @throws ContextException if the PlexusContainer could not be located.
*/
@Override
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}

This file was deleted.