diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 8799a87b4c..160f108d3e 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -88,6 +88,7 @@ public class IntegrationTestSuite // suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class ); // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng3877BasedirAlignedModelTest.class ); suite.addTestSuite( MavenITmng3866PluginConfigInheritanceTest.class ); suite.addTestSuite( MavenITmng3864PerExecPluginConfigTest.class ); suite.addTestSuite( MavenITmng3863AutoPluginGroupIdTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3475BaseAlignedDirTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3475BaseAlignedDirTest.java index 27f8320547..2e124a3e9c 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3475BaseAlignedDirTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3475BaseAlignedDirTest.java @@ -42,7 +42,7 @@ public class MavenITmng3475BaseAlignedDirTest } /** - * Verify that project directories are basedir aligned when inspected by plugins. + * Verify that project directories are basedir aligned when queried by plugin parameter expressions. */ public void testitMNG3475() throws Exception @@ -56,46 +56,33 @@ public class MavenITmng3475BaseAlignedDirTest verifier.verifyErrorFreeLog(); verifier.resetStreams(); - /* - * NOTE: The script source directory is deliberately excluded from the checks due to MNG-3741. - */ - Properties configProps = verifier.loadProperties( "target/config.properties" ); - Properties modelProps = verifier.loadProperties( "target/model.properties" ); assertPathEquals( testDir, "target", configProps.getProperty( "mapParam.buildDirectory" ) ); - assertPathEquals( testDir, "target", modelProps.getProperty( "project.build.directory" ) ); assertPathEquals( testDir, "target/classes", configProps.getProperty( "mapParam.buildOutputDirectory" ) ); - assertPathEquals( testDir, "target/classes", modelProps.getProperty( "project.build.outputDirectory" ) ); assertPathEquals( testDir, "target/test-classes", configProps.getProperty( "mapParam.buildTestOutputDirectory" ) ); - assertPathEquals( testDir, "target/test-classes", modelProps.getProperty( "project.build.testOutputDirectory" ) ); assertPathEquals( testDir, "src/main/java", configProps.getProperty( "mapParam.buildSourceDirectory" ) ); - assertPathEquals( testDir, "src/main/java", modelProps.getProperty( "project.build.sourceDirectory" ) ); assertPathEquals( testDir, "src/test/java", configProps.getProperty( "mapParam.buildTestSourceDirectory" ) ); - assertPathEquals( testDir, "src/test/java", modelProps.getProperty( "project.build.testSourceDirectory" ) ); if ( matchesVersionRange( "[2.1.0-M1,)" ) ) { assertPathEquals( testDir, "target/site", configProps.getProperty( "mapParam.reportingOutputDirectory" ) ); - assertPathEquals( testDir, "target/site", modelProps.getProperty( "project.reporting.outputDirectory" ) ); } - assertPathEquals( testDir, "src/main/resources", modelProps.getProperty( "project.build.resources.0.directory" ) ); - - assertPathEquals( testDir, "src/test/resources", modelProps.getProperty( "project.build.testResources.0.directory" ) ); - - assertPathEquals( testDir, "src/main/filters/it.properties", modelProps.getProperty( "project.build.filters.0" ) ); + /* + * NOTE: The script source directory is deliberately excluded from the checks due to MNG-3741. + */ } - private void assertPathEquals( File basedir, String subdir, String path ) + private void assertPathEquals( File basedir, String expected, String actual ) { - File actual = new File( path ); - assertTrue( "path not absolute: " + actual, actual.isAbsolute() ); - assertEquals( new File( basedir, subdir ), actual ); + File actualFile = new File( actual ); + assertTrue( "path not absolute: " + actualFile, actualFile.isAbsolute() ); + assertEquals( new File( basedir, expected ), actualFile ); } } diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3877BasedirAlignedModelTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3877BasedirAlignedModelTest.java new file mode 100644 index 0000000000..383f169965 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3877BasedirAlignedModelTest.java @@ -0,0 +1,95 @@ +package org.apache.maven.it; + +/* + * 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.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.Properties; + +/** + * This is a test set for MNG-3877. + * + * @author Benjamin Bentmann + * @version $Id$ + */ +public class MavenITmng3877BasedirAlignedModelTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng3877BasedirAlignedModelTest() + { + } + + /** + * Verify that project directories are basedir aligned when inspected by plugins via the MavenProject instance. + */ + public void testitMNG3877() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3877" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + Properties modelProps = verifier.loadProperties( "target/model.properties" ); + + assertPathEquals( testDir, "target", modelProps.getProperty( "project.build.directory" ) ); + + assertPathEquals( testDir, "target/classes", modelProps.getProperty( "project.build.outputDirectory" ) ); + + assertPathEquals( testDir, "target/test-classes", modelProps.getProperty( "project.build.testOutputDirectory" ) ); + + assertPathEquals( testDir, "src/main/java", modelProps.getProperty( "project.build.sourceDirectory" ) ); + assertPathEquals( testDir, "src/main/java", modelProps.getProperty( "project.compileSourceRoots.0" ) ); + + assertPathEquals( testDir, "src/test/java", modelProps.getProperty( "project.build.testSourceDirectory" ) ); + assertPathEquals( testDir, "src/test/java", modelProps.getProperty( "project.testCompileSourceRoots.0" ) ); + + assertPathEquals( testDir, "src/main/resources", modelProps.getProperty( "project.build.resources.0.directory" ) ); + + assertPathEquals( testDir, "src/test/resources", modelProps.getProperty( "project.build.testResources.0.directory" ) ); + + assertPathEquals( testDir, "src/main/filters/it.properties", modelProps.getProperty( "project.build.filters.0" ) ); + + /* + * NOTE: The script source directory is deliberately excluded from the checks due to MNG-3741. + */ + + // FIXME: MNG-3877 + if ( matchesVersionRange( "(4,)" ) ) + { + assertPathEquals( testDir, "target/site", modelProps.getProperty( "project.reporting.outputDirectory" ) ); + } + } + + private void assertPathEquals( File basedir, String expected, String actual ) + { + File actualFile = new File( actual ); + assertTrue( "path not absolute: " + actualFile, actualFile.isAbsolute() ); + assertEquals( new File( basedir, expected ), actualFile ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-3475/pom.xml b/its/core-it-suite/src/test/resources/mng-3475/pom.xml index c4c09955ef..f273dc34a8 100644 --- a/its/core-it-suite/src/test/resources/mng-3475/pom.xml +++ b/its/core-it-suite/src/test/resources/mng-3475/pom.xml @@ -29,16 +29,23 @@ under the License. Maven Integration Test :: MNG-3475 - Verify that project directories are basedir aligned when inspected by plugins. + Verify that project directories are basedir aligned when queried by plugin parameter expressions. - - src/main/filters/it.properties - + + src/main/java + src/test/java + src/main/scripts + target + target/classes + target/test-classes + - org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT @@ -64,36 +71,14 @@ under the License. - - - org.apache.maven.its.plugins - maven-it-plugin-expression - 2.1-SNAPSHOT - - target/model.properties - - project/build/directory - project/build/outputDirectory - project/build/testOutputDirectory - project/build/sourceDirectory - project/build/testSourceDirectory - project/build/scriptSourceDirectory - project/build/resources/0/directory - project/build/testResources/0/directory - project/build/filters/0 - project/reporting/outputDirectory - - - - - effective-model - validate - - eval - - - - + + + + target/site + diff --git a/its/core-it-suite/src/test/resources/mng-3877/pom.xml b/its/core-it-suite/src/test/resources/mng-3877/pom.xml new file mode 100644 index 0000000000..3fa3d9ab75 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3877/pom.xml @@ -0,0 +1,103 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng3877 + mng3877 + 1.0 + pom + + Maven Integration Test :: MNG-3877 + + Verify that project directories are basedir aligned when inspected by plugins. + + + + + src/main/java + src/test/java + src/main/scripts + + + src/main/resources + + + + + src/test/resources + + + target + target/classes + target/test-classes + + src/main/filters/it.properties + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + target/model.properties + + project/build/directory + project/build/outputDirectory + project/build/testOutputDirectory + project/build/sourceDirectory + project/build/testSourceDirectory + project/build/scriptSourceDirectory + project/build/resources/0/directory + project/build/testResources/0/directory + project/build/filters/0 + project/reporting/outputDirectory + project/compileSourceRoots + project/testCompileSourceRoots + project/scriptSourceRoots + + + + + effective-model + validate + + eval + + + + + + + + + + target/site + +