From fe4363a4c55b87516d00e680f309dc3e63f2141a Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Tue, 18 Dec 2007 05:36:03 +0000 Subject: [PATCH] Removing the build overlay, as it was causing problems with path translation, and doesn't serve any real purpose. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@605095 13f79535-47bb-0310-9956-ffa450edef68 --- ...luginParameterExpressionEvaluatorTest.java | 2 +- .../project/DefaultMavenProjectBuilder.java | 10 +- .../apache/maven/project/MavenProject.java | 10 +- .../maven/project/overlay/BuildOverlay.java | 330 ------------------ 4 files changed, 8 insertions(+), 344 deletions(-) delete mode 100644 maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index 25a34458be..cfa57c1578 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -261,7 +261,7 @@ public class PluginParameterExpressionEvaluatorTest Object value = expressionEvaluator.evaluate( "${project.build.directory}" + FS + "${project.build.finalName}" ); - assertEquals( new File( "expected-directory/expected-finalName" ).getCanonicalPath(), value ); + assertEquals( "expected-directory/expected-finalName", value ); } public void testShouldExtractPluginArtifacts() 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 d9fb1e1d8c..5315d09e9f 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 @@ -706,15 +706,17 @@ public class DefaultMavenProjectBuilder if ( fromSourceTree ) { + Build build = project.getBuild(); + + // NOTE: setting this script-source root before path translation, because + // the plugin tools compose basedir and scriptSourceRoot into a single file. + project.addScriptSourceRoot( build.getScriptSourceDirectory() ); + getLogger().debug( "Aligning project: " + project.getId() + " to base directory: " + projectDescriptor.getParentFile() ); pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor.getParentFile() ); - Build build = project.getBuild(); - project.addCompileSourceRoot( build.getSourceDirectory() ); - project.addScriptSourceRoot( build.getScriptSourceDirectory() ); - project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); // Only track the file of a POM in the source tree diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java index d0cba1b57d..7c4865a20b 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java @@ -51,7 +51,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.project.artifact.ActiveProjectArtifact; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.MavenMetadataSource; -import org.apache.maven.project.overlay.BuildOverlay; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; @@ -1038,19 +1037,12 @@ public class MavenProject public void setBuild( Build build ) { - buildOverlay = new BuildOverlay( build ); - model.setBuild( build ); } public Build getBuild() { - if ( buildOverlay == null ) - { - buildOverlay = new BuildOverlay( getModelBuild() ); - } - - return buildOverlay; + return getModelBuild(); } public List getResources() diff --git a/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java b/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java deleted file mode 100644 index 829bff390a..0000000000 --- a/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java +++ /dev/null @@ -1,330 +0,0 @@ -package org.apache.maven.project.overlay; - -/* - * 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.model.Build; -import org.apache.maven.model.Extension; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginManagement; -import org.apache.maven.model.Resource; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @todo why delegate? this is asking for trouble when there are additions. - */ -public class BuildOverlay - extends Build -{ - - private final Build build; - - private List resources; - - private List testResources; - - public BuildOverlay( Build build ) - { - if ( build == null ) - { - this.build = new Build(); - - resources = new ArrayList(); - - testResources = new ArrayList(); - } - else - { - this.build = build; - - resources = new ArrayList( build.getResources() ); - - testResources = new ArrayList( build.getTestResources() ); - } - } - - public void addExtension( Extension extension ) - { - build.addExtension( extension ); - } - - public void addPlugin( Plugin plugin ) - { - build.addPlugin( plugin ); - } - - public void addResource( Resource resource ) - { - resources.add( resource ); - } - - public void addTestResource( Resource resource ) - { - testResources.add( resource ); - } - - public boolean equals( Object obj ) - { - return build.equals( obj ); - } - - public void flushPluginMap() - { - build.flushPluginMap(); - } - - public String getDefaultGoal() - { - return build.getDefaultGoal(); - } - - public String getDirectory() - { - String path = build.getDirectory(); - File file = new File( build.getDirectory() ); - try - { - path = file.getCanonicalPath(); - } - catch ( IOException e ) - { - handleCanonicalException( path, e ); - } - return path; - } - - public List getExtensions() - { - return build.getExtensions(); - } - - public String getFinalName() - { - return build.getFinalName(); - } - - public String getOutputDirectory() - { - String path = build.getDirectory(); - File file = new File( build.getOutputDirectory() ); - try - { - path = file.getCanonicalPath(); - } - catch ( IOException e ) - { - handleCanonicalException( path, e ); - } - return path; - } - - public PluginManagement getPluginManagement() - { - return build.getPluginManagement(); - } - - public List getPlugins() - { - return build.getPlugins(); - } - - public Map getPluginsAsMap() - { - return build.getPluginsAsMap(); - } - - public List getResources() - { - return resources; - } - - public String getScriptSourceDirectory() - { - String path = build.getDirectory(); - File file = new File( build.getScriptSourceDirectory() ); - try - { - path = file.getCanonicalPath(); - } - catch ( IOException e ) - { - handleCanonicalException( path, e ); - } - return path; - } - - private void handleCanonicalException( String path, IOException e ) - { - IllegalStateException error = new IllegalStateException( "Cannot compute canonical path for: " + path - + ". Reason: " + e.getMessage() ); - error.initCause( e ); - - throw error; - } - - public String getSourceDirectory() - { - return build.getSourceDirectory(); - } - - public String getTestOutputDirectory() - { - return build.getTestOutputDirectory(); - } - - public List getTestResources() - { - return testResources; - } - - public String getTestSourceDirectory() - { - String path = build.getDirectory(); - File file = new File( build.getTestSourceDirectory() ); - try - { - path = file.getCanonicalPath(); - } - catch ( IOException e ) - { - handleCanonicalException( path, e ); - } - return path; - } - - public int hashCode() - { - return build.hashCode(); - } - - public void removeExtension( Extension extension ) - { - build.removeExtension( extension ); - } - - public void removePlugin( Plugin plugin ) - { - build.removePlugin( plugin ); - } - - public void removeResource( Resource resource ) - { - resources.remove( resource ); - } - - public void removeTestResource( Resource resource ) - { - testResources.remove( resource ); - } - - public void setDefaultGoal( String defaultGoal ) - { - build.setDefaultGoal( defaultGoal ); - } - - public void setDirectory( String directory ) - { - build.setDirectory( directory ); - } - - public void setExtensions( List extensions ) - { - build.setExtensions( extensions ); - } - - public void setFinalName( String finalName ) - { - build.setFinalName( finalName ); - } - - public void setOutputDirectory( String outputDirectory ) - { - build.setOutputDirectory( outputDirectory ); - } - - public void setPluginManagement( PluginManagement pluginManagement ) - { - build.setPluginManagement( pluginManagement ); - } - - public void setPlugins( List plugins ) - { - build.setPlugins( plugins ); - } - - public void setResources( List resources ) - { - this.resources = resources; - } - - public void setScriptSourceDirectory( String scriptSourceDirectory ) - { - build.setScriptSourceDirectory( scriptSourceDirectory ); - } - - public void setSourceDirectory( String sourceDirectory ) - { - build.setSourceDirectory( sourceDirectory ); - } - - public void setTestOutputDirectory( String testOutputDirectory ) - { - build.setTestOutputDirectory( testOutputDirectory ); - } - - public void setTestResources( List testResources ) - { - this.testResources = testResources; - } - - public void setTestSourceDirectory( String testSourceDirectory ) - { - build.setTestSourceDirectory( testSourceDirectory ); - } - - public String toString() - { - return build.toString(); - } - - public void addFilter( String string ) - { - build.addFilter( string ); - } //-- void addFilter(String) - - public List getFilters() - { - return build.getFilters(); - } //-- java.util.List getFilters() - - public void removeFilter( String string ) - { - build.removeFilter( string ); - } //-- void removeFilter(String) - - public void setFilters( List filters ) - { - build.setFilters( filters ); - } //-- void setFilters(java.util.List) -}