Author: brett
Date: Tue May 9 01:37:31 2006
New Revision: 405342
URL: http://svn.apache.org/viewcvs?rev=405342&view=rev
Log:
[MIDEA-30] read warSourceDirectory from plugin configuration if present
Submitted by: Johann Reyes
Modified:
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
Modified:
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java?rev=405342&r1=405341&r2=405342&view=diff
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
(original)
+++
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/AbstractIdeaMojo.java
Tue May 9 01:37:31 2006
@@ -31,12 +31,14 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
+import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -286,6 +288,26 @@
getLog().warn( msg );
}
+ }
+
+ /*
+ * @todo we need a more permanent feature that does this properly
+ */
+ protected String getPluginSetting( String artifactId, String optionName,
String defaultValue )
+ {
+ for ( Iterator it = executedProject.getBuildPlugins().iterator();
it.hasNext(); )
+ {
+ Plugin plugin = (Plugin) it.next();
+ if ( plugin.getArtifactId().equals( artifactId ) )
+ {
+ Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
+ if ( o != null && o.getChild( optionName ) != null )
+ {
+ return o.getChild( optionName ).getValue();
+ }
+ }
+ }
+ return defaultValue;
}
private Set getProjectArtifacts()
Modified:
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java?rev=405342&r1=405341&r2=405342&view=diff
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
(original)
+++
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
Tue May 9 01:37:31 2006
@@ -673,7 +673,7 @@
// grab stuff from the mojo
String warWebapp = executedProject.getBuild().getDirectory() + "/" +
executedProject.getArtifactId();
- String warSrc = "src/main/webapp";
+ String warSrc = getPluginSetting( "maven-war-plugin",
"warSourceDirectory", "src/main/webapp" );
String webXml = warSrc + "/WEB-INF/web.xml";
module.addAttribute( "type", "J2EE_WEB_MODULE" );
Modified:
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
URL:
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java?rev=405342&r1=405341&r2=405342&view=diff
==============================================================================
---
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
(original)
+++
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/SimpleMavenProjectStub.java
Tue May 9 01:37:31 2006
@@ -208,10 +208,15 @@
artifact.setGroupId( groupId );
artifact.setArtifactId( artifactId );
artifact.setVersion( version );
- artifact.setFile( new File( PlexusTestCase.getBasedir(),
"target/local-repo/" + artifact.getGroupId().replace( '.', '/' ) +
- "/" + artifact.getArtifactId() + "/" +
artifact.getVersion() +
- "/" + artifact.getArtifactId() + "-" +
artifact.getVersion() + ".jar" ) );
+ artifact.setFile( new File( PlexusTestCase.getBasedir(),
"target/local-repo/" +
+ artifact.getGroupId().replace( '.', '/' ) + "/" +
artifact.getArtifactId() + "/" + artifact.getVersion() +
+ "/" + artifact.getArtifactId() + "-" + artifact.getVersion() +
".jar" ) );
return artifact;
+ }
+
+ public List getBuildPlugins()
+ {
+ return build.getPlugins();
}
}