From 37f2a94bf2253bdb05f2fb7a9b83dadc2621dd81 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Thu, 6 Oct 2005 07:10:49 +0000 Subject: [PATCH] PR: MNG-1088 if plugin is not built yet, go to the repository git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@306547 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core-it-plugin/pom.xml | 2 +- maven-core-it/README.txt | 4 +- maven-core-it/integration-tests.txt | 1 + maven-core-it/it0042/goals.txt | 2 +- maven-core-it/it0082/expected-results.txt | 1 + maven-core-it/it0082/goals.txt | 1 + maven-core-it/it0082/pom.xml | 13 ++++ maven-core-it/it0082/test-component-c/pom.xml | 41 ++++++++++ .../test-component-c/src/main/java/C.java | 5 ++ .../src/main/webapp/WEB-INF/web.xml | 5 ++ maven-core-it/it0082/test-plugin/pom.xml | 21 +++++ .../maven/plugin/coreit/CoreItMojo.java | 77 +++++++++++++++++++ maven-core/pom.xml | 1 - .../maven/plugin/DefaultPluginManager.java | 11 ++- .../artifact/ActiveProjectArtifact.java | 2 +- 15 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 maven-core-it/it0082/expected-results.txt create mode 100644 maven-core-it/it0082/goals.txt create mode 100644 maven-core-it/it0082/pom.xml create mode 100644 maven-core-it/it0082/test-component-c/pom.xml create mode 100644 maven-core-it/it0082/test-component-c/src/main/java/C.java create mode 100644 maven-core-it/it0082/test-component-c/src/main/webapp/WEB-INF/web.xml create mode 100644 maven-core-it/it0082/test-plugin/pom.xml create mode 100644 maven-core-it/it0082/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java diff --git a/maven-core-it-plugin/pom.xml b/maven-core-it-plugin/pom.xml index 1897d973d7..463a3d1dc0 100644 --- a/maven-core-it-plugin/pom.xml +++ b/maven-core-it-plugin/pom.xml @@ -3,7 +3,7 @@ maven-plugin-parent org.apache.maven.plugins - 2.0-beta-3-SNAPSHOT + 2.0-beta-3 4.0.0 maven-core-it-plugin diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index dbc209c308..6225fcec1f 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -117,7 +117,6 @@ it0040: Test the use of a packaging from a plugin it0041: Test the use of a new type from a plugin it0042: Test that the reactor can establish the artifact location of known projects for dependencies - First test generate sources to see that it works even when they aren't compiled it0043: Test for repository inheritence - ensure using the same id overrides the defaults @@ -223,6 +222,9 @@ it0080: Test that depending on a WAR doesn't also get its dependencies it0081: Test per-plugin dependencies. +it0082: Test that the reactor can establish the artifact location of known projects for dependencies + using process-sources to see that it works even when they aren't compiled + ------------------------------------------------------------------------------- - generated sources diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 210df7f8a0..ccd717c43b 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,3 +1,4 @@ +it0082 it0081 it0080 it0079 diff --git a/maven-core-it/it0042/goals.txt b/maven-core-it/it0042/goals.txt index 302ef7d8f3..ba3bd78738 100644 --- a/maven-core-it/it0042/goals.txt +++ b/maven-core-it/it0042/goals.txt @@ -1 +1 @@ -generate-sources +package diff --git a/maven-core-it/it0082/expected-results.txt b/maven-core-it/it0082/expected-results.txt new file mode 100644 index 0000000000..9ec8f8a8d2 --- /dev/null +++ b/maven-core-it/it0082/expected-results.txt @@ -0,0 +1 @@ +test-component-c/target/my-test diff --git a/maven-core-it/it0082/goals.txt b/maven-core-it/it0082/goals.txt new file mode 100644 index 0000000000..a999afa6c0 --- /dev/null +++ b/maven-core-it/it0082/goals.txt @@ -0,0 +1 @@ +process-sources diff --git a/maven-core-it/it0082/pom.xml b/maven-core-it/it0082/pom.xml new file mode 100644 index 0000000000..aeecadbecf --- /dev/null +++ b/maven-core-it/it0082/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + test + test-components + 0.1 + Test Components + pom + + + test-component-c + test-plugin + + diff --git a/maven-core-it/it0082/test-component-c/pom.xml b/maven-core-it/it0082/test-component-c/pom.xml new file mode 100644 index 0000000000..6bf2a5cc43 --- /dev/null +++ b/maven-core-it/it0082/test-component-c/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + test-components + test + 0.1 + + + test + test-component-c + 0.1 + Test Component C + war + + + + + org.apache.maven.plugins + maven-core-it-plugin + 1.0-SNAPSHOT + + my-test + + + + + touch + + + + + + + + + snapshots + Maven Central Plugins Development Repository + http://snapshots.maven.codehaus.org/maven2 + + + diff --git a/maven-core-it/it0082/test-component-c/src/main/java/C.java b/maven-core-it/it0082/test-component-c/src/main/java/C.java new file mode 100644 index 0000000000..f7546a58a7 --- /dev/null +++ b/maven-core-it/it0082/test-component-c/src/main/java/C.java @@ -0,0 +1,5 @@ +public class C + extends A +{ +} + diff --git a/maven-core-it/it0082/test-component-c/src/main/webapp/WEB-INF/web.xml b/maven-core-it/it0082/test-component-c/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..92bb2e9825 --- /dev/null +++ b/maven-core-it/it0082/test-component-c/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/maven-core-it/it0082/test-plugin/pom.xml b/maven-core-it/it0082/test-plugin/pom.xml new file mode 100644 index 0000000000..6a1d4834be --- /dev/null +++ b/maven-core-it/it0082/test-plugin/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + test-components + test + 0.1 + + + org.apache.maven.plugins + maven-core-it-plugin + maven-plugin + 1.0-SNAPSHOT + Test Plugin + + + org.apache.maven + maven-plugin-api + 2.0-beta-1 + + + diff --git a/maven-core-it/it0082/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/maven-core-it/it0082/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java new file mode 100644 index 0000000000..ad958a7e66 --- /dev/null +++ b/maven-core-it/it0082/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java @@ -0,0 +1,77 @@ +package org.apache.maven.plugin.coreit; + +/* + * Copyright 2001-2004 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal test + * + * @phase process-sources + * + * @description Goal which cleans the build + */ +public class CoreItMojo + extends AbstractMojo +{ + /** + * @parameter expression="${project.build.directory}" + * @required + */ + private String outputDirectory; + + /** + * @parameter + * @required + */ + private String value; + + public void execute() + throws MojoExecutionException + { + touch( new File( outputDirectory ), value ); + } + + private static void touch( File dir, String file ) + throws MojoExecutionException + { + try + { + if ( !dir.exists() ) + { + dir.mkdirs(); + } + + File touch = new File( dir, file ); + + FileWriter w = new FileWriter( touch ); + + w.write( file ); + + w.close(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error touching file", e ); + } + } +} diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 9f9b22af65..8dacd49895 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -13,7 +13,6 @@ maven-assembly-plugin - 2.0-beta-1 src/assemble/bin.xml maven-${version} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index eefaf190a5..01134a43dc 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -268,7 +268,16 @@ public class DefaultPluginManager // TODO: if not matching, we should get the correct artifact from that project (attached) if ( ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) ) { - pluginArtifact = new ActiveProjectArtifact( ref, pluginArtifact ); + // if the project artifact doesn't exist, don't use it. We haven't built that far. + if ( project.getArtifact().getFile() != null && project.getArtifact().getFile().exists() ) + { + pluginArtifact = new ActiveProjectArtifact( ref, pluginArtifact ); + } + else + { + getLogger().warn( "Plugin found in the reactor has not been built when it's use was attempted" + + " - resolving from the repository instead" ); + } } } } diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java b/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java index 1e21b07bad..e469369dfd 100644 --- a/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java +++ b/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java @@ -259,7 +259,7 @@ public class ActiveProjectArtifact public void setRelease( boolean release ) { - artifact.setResolved( release ); + artifact.setRelease( release ); } public List getAvailableVersions()