Author: epunzalan
Date: Mon Jul 31 08:49:33 2006
New Revision: 427149

URL: http://svn.apache.org/viewvc?rev=427149&view=rev
Log:
PR: MIDEA-62
Submitted by: Roald Bankras

- Removed provided artifacts from IntelliJ Idea package.
- Added missing unit test
- fixed some license headers appearing in a line

Added:
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java
   (with props)
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml
   (with props)
Modified:
    
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/IdeaModuleTest.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/IdeaArtifactStub.java
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/general-plugin-config.xml
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/module-plugin-config.xml
    
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/war-plugin-config.xml

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaModuleMojo.java?rev=427149&r1=427148&r2=427149&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
 Mon Jul 31 08:49:33 2006
@@ -763,7 +763,14 @@
                 containerElement.addAttribute( "level", "module" );
                 Element methodAttribute = createElement( containerElement, 
"attribute" );
                 methodAttribute.addAttribute( "name", "method" );
-                methodAttribute.addAttribute( "value", "1" ); // IntelliJ 
5.0.2 is bugged and doesn't read it
+                if ( Artifact.SCOPE_PROVIDED.equalsIgnoreCase( 
artifact.getScope() ) )
+                {
+                    methodAttribute.addAttribute( "value", "0" ); // If scope 
is provided, do not package.
+                }
+                else
+                {
+                    methodAttribute.addAttribute( "value", "1" ); // IntelliJ 
5.0.2 is bugged and doesn't read it
+                }
                 Element uriAttribute = createElement( containerElement, 
"attribute" );
                 uriAttribute.addAttribute( "name", "URI" );
                 uriAttribute.addAttribute( "value", "/WEB-INF/lib/" + 
artifact.getFile().getName() );
@@ -955,4 +962,4 @@
 
         return deploymentDescriptor;
     }
-}
\ No newline at end of file
+}

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java?rev=427149&r1=427148&r2=427149&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/IdeaModuleTest.java
 Mon Jul 31 08:49:33 2006
@@ -38,6 +38,12 @@
         executeMojo( "src/test/module-plugin-configs/min-plugin-config.xml" );
     }
 
+    public void testProvidedDependencies()
+        throws Exception
+    {
+        executeMojo( 
"src/test/module-plugin-configs/provided-dep-plugin-config.xml" );
+    }
+
     public void testExcludeDirectoryConfig()
         throws Exception
     {
@@ -120,6 +126,70 @@
 
             attribute = findElementByNameAttribute( containerElement, 
"attribute", "URI" );
             String attributeValue = attribute.attributeValue( "value" );
+            assertTrue( "Test library URI", expectedLibs.contains( 
attributeValue ) );
+            expectedLibs.remove( attributeValue );
+        }
+
+        assertTrue( "All libraries are present", expectedLibs.size() == 0 );
+    }
+
+    public void testWarConfigWithProvidedDependency()
+        throws Exception
+    {
+        List expectedLibs = new ArrayList();
+        expectedLibs.add( "/WEB-INF/lib/maven-model-2.0.1.jar" );
+        expectedLibs.add( "/WEB-INF/lib/junit-3.8.1.jar" );
+
+        Document imlDocument = executeMojo( 
"src/test/module-plugin-configs/provided-dep-plugin-config.xml" );
+
+        Element root = imlDocument.getRootElement();
+
+        assertEquals( "Test Project type", "J2EE_WEB_MODULE", 
root.attributeValue( "type" ) );
+
+        Element component = findComponent( root, "WebModuleBuildComponent" );
+
+        Element setting = findElement( component, "setting" );
+        assertTrue( "Test exploded url setting", "EXPLODED_URL".equals( 
setting.attributeValue( "name" ) ) );
+        assertTrue( "Test exploded url value",
+                    setting.attributeValue( "value" ).startsWith( 
"file://$MODULE_DIR$/target/" ) );
+
+        component = findComponent( root, "WebModuleProperties" );
+
+        Element deployDescriptor = component.element( "deploymentDescriptor" );
+        assertEquals( "Test deployment descriptor version", "2.3", 
deployDescriptor.attributeValue( "version" ) );
+        assertEquals( "Test deployment descriptor name", "web.xml", 
deployDescriptor.attributeValue( "name" ) );
+        assertEquals( "Test deployment descriptor optional", "false", 
deployDescriptor.attributeValue( "optional" ) );
+        assertEquals( "Test deployment descriptor file", 
"file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml",
+                      deployDescriptor.attributeValue( "url" ) );
+
+        Element webroots = component.element( "webroots" );
+        Element webroot = webroots.element( "root" );
+        assertEquals( "Test webroot relative location", "/", 
webroot.attributeValue( "relative" ) );
+        assertEquals( "Test webroot url", 
"file://$MODULE_DIR$/src/main/webapp", webroot.attributeValue( "url" ) );
+
+        List containerElementList = findElementsByName( component, 
"containerElement" );
+        for ( Iterator containerElements = containerElementList.iterator(); 
containerElements.hasNext(); )
+        {
+            Element containerElement = (Element) containerElements.next();
+
+            assertEquals( "Test container element type", "library", 
containerElement.attributeValue( "type" ) );
+            assertEquals( "Test container element level", "module", 
containerElement.attributeValue( "level" ) );
+            assertTrue( "Test library url", containerElement.element( "url" 
).getText().startsWith( "jar://" ) );
+
+            Element attribute = findElementByNameAttribute( containerElement, 
"attribute", "URI" );
+            String attributeValue = attribute.attributeValue( "value" );
+
+            attribute = findElementByNameAttribute( containerElement, 
"attribute", "method" );
+
+            if ( "/WEB-INF/lib/maven-model-2.0.1.jar".equals( attributeValue ) 
)
+            {
+                assertEquals( "Test library method", "0", 
attribute.attributeValue( "value" ) );
+            }
+            else
+            {
+                assertEquals( "Test library method", "1", 
attribute.attributeValue( "value" ) );
+            }
+
             assertTrue( "Test library URI", expectedLibs.contains( 
attributeValue ) );
             expectedLibs.remove( attributeValue );
         }

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/IdeaArtifactStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/IdeaArtifactStub.java?rev=427149&r1=427148&r2=427149&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/IdeaArtifactStub.java
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/IdeaArtifactStub.java
 Mon Jul 31 08:49:33 2006
@@ -37,6 +37,8 @@
 
     private File file;
 
+    private String scope;
+
 
     public void setGroupId( String groupId )
     {
@@ -92,5 +94,20 @@
     public String getId()
     {
         return getGroupId() + ":" + getArtifactId() + ":" + getVersion();
+    }
+
+    public void setScope( String scope )
+    {
+        this.scope = scope;
+    }
+
+    public String getScope()
+    {
+        if ( scope == null )
+        {
+            scope = super.getScope();
+        }
+
+        return scope;
     }
 }

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java?rev=427149&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java
 Mon Jul 31 08:49:33 2006
@@ -0,0 +1,68 @@
+package org.apache.maven.plugin.idea.stubs;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.artifact.Artifact;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/*
+ *
+ *  Copyright 2005-2006 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.
+ *
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class WarMavenProjectWithProvidedDependencyStub
+    extends WarMavenProjectStub
+{
+    public List getTestArtifacts()
+    {
+        List testArtifacts = new ArrayList();
+
+        Artifact artifact = createArtifact( "org.apache.maven", "maven-model", 
"2.0.1" );
+
+        artifact.setScope( Artifact.SCOPE_PROVIDED );
+
+        testArtifacts.add( artifact );
+
+        testArtifacts.add( createArtifact( "junit", "junit", "3.8.1" ) );
+
+        return testArtifacts;
+    }
+
+    public List getDependencies()
+    {
+        List dependencies = new ArrayList();
+
+        Dependency dep = new Dependency();
+        dep.setGroupId( "org.apache.maven" );
+        dep.setArtifactId( "maven-model" );
+        dep.setVersion( "2.0.1" );
+        dep.setScope( Artifact.SCOPE_PROVIDED );
+        dependencies.add( dep );
+
+        dep = new Dependency();
+        dep.setGroupId( "junit" );
+        dep.setArtifactId( "junit" );
+        dep.setVersion( "3.8.1" );
+        dep.setScope( Artifact.SCOPE_TEST );
+        dependencies.add( dep );
+
+        return dependencies;
+    }
+}

Propchange: 
maven/plugins/trunk/maven-idea-plugin/src/test/java/org/apache/maven/plugin/idea/stubs/WarMavenProjectWithProvidedDependencyStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/general-plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/general-plugin-config.xml?rev=427149&r1=427148&r2=427149&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/general-plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/general-plugin-config.xml
 Mon Jul 31 08:49:33 2006
@@ -1,5 +1,19 @@
 <!--
-  ~  Copyright 2005-2006 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.
+  ~
+  ~  Copyright 2005-2006 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.
+  ~
   -->
 
 <project>

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/module-plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/module-plugin-config.xml?rev=427149&r1=427148&r2=427149&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/module-plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/module-plugin-config.xml
 Mon Jul 31 08:49:33 2006
@@ -1,5 +1,19 @@
 <!--
-  ~  Copyright 2005-2006 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.
+  ~
+  ~  Copyright 2005-2006 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.
+  ~
   -->
 
 <project>

Added: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml?rev=427149&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml
 (added)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml
 Mon Jul 31 08:49:33 2006
@@ -0,0 +1,44 @@
+<!--
+  ~
+  ~  Copyright 2005-2006 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.
+  ~
+  -->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-idea-plugin</artifactId>
+        <configuration>
+          <executedProject 
implementation="org.apache.maven.plugin.idea.stubs.WarMavenProjectWithProvidedDependencyStub"/>
+          <localRepo>${localRepository}</localRepo>
+          <overwrite>false</overwrite>
+          <reactorProjects>
+            <reactorProject 
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+            <reactorProject 
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+            <reactorProject 
implementation="org.apache.maven.plugin.idea.stubs.ReactorMavenProjectStub"/>
+          </reactorProjects>
+          <linkModules>true</linkModules>
+          <useFullNames>false</useFullNames>
+          <downloadSources>false</downloadSources>
+          <sourceClassifier>sources</sourceClassifier>
+          <downloadJavadocs>false</downloadJavadocs>
+          <javadocClassifier>javadoc</javadocClassifier>
+          <dependenciesAsLibraries>false</dependenciesAsLibraries>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/provided-dep-plugin-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/war-plugin-config.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/war-plugin-config.xml?rev=427149&r1=427148&r2=427149&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/war-plugin-config.xml
 (original)
+++ 
maven/plugins/trunk/maven-idea-plugin/src/test/module-plugin-configs/war-plugin-config.xml
 Mon Jul 31 08:49:33 2006
@@ -1,5 +1,19 @@
 <!--
-  ~  Copyright 2005-2006 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.
+  ~
+  ~  Copyright 2005-2006 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.
+  ~
   -->
 
 <project>


Reply via email to