Author: aheritier Date: Mon Feb 18 08:09:11 2008 New Revision: 628794 URL: http://svn.apache.org/viewvc?rev=628794&view=rev Log: MECLIPSE-379 : When downloading sources and javadocs dependency classifier is not respected.
Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/ maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/ maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath (with props) maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project (with props) maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml (with props) Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java?rev=628794&r1=628793&r2=628794&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java Mon Feb 18 08:09:11 2008 @@ -950,7 +950,7 @@ * artifacts (depending on the <code>classifier</code>) are attached to the dependency. * * @param deps resolved dependencies - * @param classifier the classifier we are looking for (either <code>sources</code> or <code>javadoc</code>) + * @param inClassifier the classifier we are looking for (either <code>sources</code> or <code>javadoc</code>) * @param includeRemoteRepositories flag whether we should search remote repositories for the artifacts or not * @param unavailableArtifactsCache cache of unavailable artifacts * @return the list of dependencies for which the required artifact was not found @@ -975,39 +975,38 @@ continue; } - // MECLIPSE-151 - if the dependency is a test, get the correct classifier for it. (ignore for javadocs) - String classifier = inClassifier; - if ( "sources".equals( classifier ) && "tests".equals( dependency.getClassifier() ) ) - { - classifier = "test-sources"; - } - if ( getLog().isDebugEnabled() ) { getLog().debug( "Searching for sources for " + dependency.getId() + ":" + dependency.getClassifier() + - " at " + dependency.getId() + ":" + classifier ); + " at " + dependency.getId() + ":" + inClassifier ); } - if ( !unavailableArtifactsCache.containsKey( dependency.getId() + ":" + classifier ) ) + + String key = + dependency.getClassifier() == null ? dependency.getId() + ":" + inClassifier : dependency.getId() + + ":" + inClassifier + ":" + dependency.getClassifier(); + + if ( !unavailableArtifactsCache.containsKey( key ) ) { Artifact artifact = IdeUtils.resolveArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion(), classifier, localRepository, - artifactResolver, artifactFactory, remoteRepos, getLog() ); + dependency.getVersion(), dependency.getClassifier(), + inClassifier, localRepository, artifactResolver, + artifactFactory, remoteRepos, getLog() ); if ( artifact.isResolved() ) { - if ( "sources".equals( classifier ) || "test-sources".equals( classifier ) ) + if ( "sources".equals( inClassifier ) ) { dependency.setSourceAttachment( artifact.getFile() ); } - else if ( "javadoc".equals( classifier ) ) + else if ( "javadoc".equals( inClassifier ) ) { dependency.setJavadocAttachment( artifact.getFile() ); } } else { - unavailableArtifactsCache.put( dependency.getId() + ":" + classifier, Boolean.TRUE.toString() ); + unavailableArtifactsCache.put( key, Boolean.TRUE.toString() ); // add the dependencies to the list // of those lacking the required // artifact Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java?rev=628794&r1=628793&r2=628794&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java Mon Feb 18 08:09:11 2008 @@ -304,21 +304,41 @@ } public static Artifact resolveArtifactWithClassifier( String groupId, String artifactId, String version, - String classifier, ArtifactRepository localRepository, + String depClassifier, String inClassifier, + ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactFactory artifactFactory, List remoteRepos, Log log ) { - String type = classifier; + String type = null; // the "sources" classifier maps to the "java-source" type - if ( "sources".equals( type ) || "test-sources".equals( type ) ) //$NON-NLS-1$ + if ( "sources".equals( inClassifier ) ) { - type = "java-source"; //$NON-NLS-1$ + type = "java-source"; + } + else + { + type = inClassifier; + } + + String finalClassifier = null; + if ( depClassifier == null ) + { + finalClassifier = inClassifier; + } + else if ( "sources".equals( inClassifier ) && "tests".equals( depClassifier ) ) + { + // MECLIPSE-151 - if the dependency is a test, get the correct classifier for it. (ignore for javadocs) + finalClassifier = "test-sources"; + } + else + { + finalClassifier = depClassifier + "-" + inClassifier; } Artifact resolvedArtifact = - artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); + artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, finalClassifier ); try { @@ -330,8 +350,9 @@ } catch ( ArtifactResolutionException e ) { - String message = Messages.getString( "errorresolving", new Object[] { //$NON-NLS-1$ - classifier, resolvedArtifact.getId(), e.getMessage() } ); + String message = + Messages.getString( "errorresolving", new Object[] { finalClassifier, resolvedArtifact.getId(), + e.getMessage() } ); log.warn( message ); } @@ -347,11 +368,11 @@ version = IdeUtils.getCompilerSourceVersion( project ); } - if ( "1.5".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$ + if ( "1.5".equals( version ) ) //$NON-NLS-1$ { - version = IdeUtils.JAVA_5_0;// see MECLIPSE-47 eclipse only accept 5.0 as a valid version //$NON-NLS-1$ + version = IdeUtils.JAVA_5_0;// see MECLIPSE-47 eclipse only accept 5.0 as a valid version } - else if ( "1.6".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$ + else if ( "1.6".equals( version ) ) //$NON-NLS-1$ { version = IdeUtils.JAVA_6_0; } @@ -360,7 +381,7 @@ version = version + ".0";// 5->5.0 6->6.0 7->7.0 //$NON-NLS-1$ } - return version == null ? IdeUtils.JAVA_1_4 : version; //$NON-NLS-1$ + return version == null ? IdeUtils.JAVA_1_4 : version; } public static String toRelativeAndFixSeparator( File basedir, File fileToAdd, boolean replaceSlashesWithDashes ) Modified: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java?rev=628794&r1=628793&r2=628794&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Mon Feb 18 08:09:11 2008 @@ -522,6 +522,18 @@ testProject( "project-44" ); } + /** + * [MECLIPSE-379] When downloading sources and javadocs dependency classifier is not respected. + * + * @since 2.5 + * @throws Exception + */ + public void testProject45() + throws Exception + { + testProject( "project-45" ); + } + public void testJeeSimple() throws Exception { Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath?rev=628794&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath Mon Feb 18 08:09:11 2008 @@ -0,0 +1,10 @@ +<classpath> + <classpathentry kind="output" path="target/classes"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/net/sf/ezmorph/ezmorph/1.0.4/ezmorph-1.0.4.jar" sourcepath="M2_REPO/net/sf/ezmorph/ezmorph/1.0.4/ezmorph-1.0.4-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/net/sf/json-lib/json-lib/2.2/json-lib-2.2-jdk15.jar" sourcepath="M2_REPO/net/sf/json-lib/json-lib/2.2/json-lib-2.2-jdk15-sources.jar"/> +</classpath> \ No newline at end of file Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.classpath ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project?rev=628794&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project Mon Feb 18 08:09:11 2008 @@ -0,0 +1,13 @@ +<projectDescription> + <name>maven-eclipse-plugin-test-project-45</name> + <comment/> + <projects/> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> \ No newline at end of file Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/expected/.project ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml?rev=628794&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml Mon Feb 18 08:09:11 2008 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>eclipse</groupId> + <artifactId>maven-eclipse-plugin-test-project-45</artifactId> + <version>88.0</version> + <name>Maven</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>test</version> + <configuration> + <downloadSources>true</downloadSources> + <!-- We cannot test with javadocs because it creates absolute paths to be compatible with oldest eclipse releases --> + <downloadJavadocs>false</downloadJavadocs> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>net.sf.json-lib</groupId> + <artifactId>json-lib</artifactId> + <version>2.2</version> + <classifier>jdk15</classifier> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-45/pom.xml ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"