Index: C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/Messages.java =================================================================== --- C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/Messages.java (revision 0) +++ C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/Messages.java (revision 0) @@ -0,0 +1,67 @@ +package org.apache.maven.plugin.idea; + +/* + * Copyright 2001-2005 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 java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Copied from maven-eclipse-plugin + * @author Fabrizio Giustina + * @version $Id: Messages.java 359477 2005-12-28 10:51:19Z fgiust $ + */ +public class Messages +{ + + private static final String BUNDLE_NAME = "org.apache.maven.plugin.idea.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + + private Messages() + { + } + + public static String getString( String key ) + { + try + { + return RESOURCE_BUNDLE.getString( key ); + } + catch ( MissingResourceException e ) + { + return '!' + key + '!'; + } + } + + public static String getString( String key, Object[] params ) + { + try + { + return MessageFormat.format( RESOURCE_BUNDLE.getString( key ), params ); + } + catch ( MissingResourceException e ) + { + return '!' + key + '!'; + } + } + + public static String getString( String key, Object param ) + { + return getString( key, new Object[] { param } ); + } +} Index: C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java =================================================================== --- C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java (revision 385659) +++ C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java (working copy) @@ -52,6 +52,7 @@ /** * @author Edwin Punzalan + * @author Aleksandr Tarutin * @goal module * @execute phase="generate-sources" * @todo use dom4j or something. Xpp3Dom can't cope properly with entities and so on @@ -59,6 +60,8 @@ public class IdeaModuleMojo extends AbstractIdeaMojo { + + private static final String M2_REPO = "$M2_REPO$/"; /** * The Maven Project. * @@ -247,6 +250,10 @@ { addEjbModule( module ); } + else if ( "ear".equals( project.getPackaging() ) ) + { + addEarModule( module ); + } Xpp3Dom component = findComponent( module, "NewModuleRootManager" ); Xpp3Dom output = findElement( component, "output" ); @@ -401,8 +408,8 @@ else { el = createElement( el, "root" ); - File file = a.getFile(); - el.setAttribute( "url", "jar://" + file.getAbsolutePath().replace( '\\', '/' ) + "!/" ); + String fileLocation = M2_REPO + localRepo.pathOf(a); + el.setAttribute( "url", "jar://" + fileLocation + "!/" ); } boolean usedSources = false; @@ -460,7 +467,12 @@ } } - private void addEjbModule( Xpp3Dom module ) + private void addEarModule(Xpp3Dom module) { + // TODO Auto-generated method stub + + } + + private void addEjbModule( Xpp3Dom module ) { module.setAttribute( "type", "J2EE_EJB_MODULE" ); Index: C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaProjectMojo.java =================================================================== --- C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaProjectMojo.java (revision 385659) +++ C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaProjectMojo.java (working copy) @@ -127,6 +127,8 @@ } rewriteProject(); + + getLog().warn(Messages.getString("IdeaPlugin.variable.warning")); } public void rewriteProject() @@ -186,16 +188,16 @@ if ( project.getCollectedProjects().size() > 0 ) { - Xpp3Dom m = createElement( modules, "module" ); - String projectPath = - new File( project.getBasedir(), project.getArtifactId() + ".iml" ).getAbsolutePath(); - m.setAttribute( "filepath", "$PROJECT_DIR$/" + toRelative( project.getBasedir(), projectPath ) ); +// Xpp3Dom m = createElement( modules, "module" ); +// String projectPath = +// new File( project.getBasedir(), project.getArtifactId() + ".iml" ).getAbsolutePath(); +// m.setAttribute( "filepath", "$PROJECT_DIR$/" + toRelative( project.getBasedir(), projectPath ) ); for ( Iterator i = project.getCollectedProjects().iterator(); i.hasNext(); ) { MavenProject p = (MavenProject) i.next(); - m = createElement( modules, "module" ); + Xpp3Dom m = createElement( modules, "module" ); String modulePath = new File( p.getBasedir(), p.getArtifactId() + ".iml" ).getAbsolutePath(); m.setAttribute( "filepath", "$PROJECT_DIR$/" + toRelative( project.getBasedir(), modulePath ) ); } Index: C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/resources/org/apache/maven/plugin/idea/messages.properties =================================================================== --- C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/resources/org/apache/maven/plugin/idea/messages.properties (revision 0) +++ C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/src/main/resources/org/apache/maven/plugin/idea/messages.properties (revision 0) @@ -0,0 +1 @@ +IdeaPlugin.variable.varning=This plugin uses M2_REPO variable.\nIn future releases a goal will be added to the plugin to add the variable to IDEA.\nMeanwhile you should take care of that yourself. \ No newline at end of file Index: C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/pom.xml =================================================================== --- C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/pom.xml (revision 385659) +++ C:/Development/Tools.src/Maven-2/plugins/maven-idea-plugin/pom.xml (working copy) @@ -1,4 +1,5 @@ - + maven-plugins org.apache.maven.plugins @@ -8,7 +9,7 @@ maven-idea-plugin maven-plugin Maven IDEA Plugin - 2.0-beta-2-SNAPSHOT + 2.0-beta-2 2.0.1