Author: rfscholte Date: Sun Aug 7 19:49:56 2011 New Revision: 1154754 URL: http://svn.apache.org/viewvc?rev=1154754&view=rev Log: Fix MECLIPSE-676: linkedResources: <location> vs <locationURI>
Added: maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/ maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/invoker.properties maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/pom.xml maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/verify.bsh Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java Added: maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/invoker.properties?rev=1154754&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/invoker.properties (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/invoker.properties Sun Aug 7 19:49:56 2011 @@ -0,0 +1 @@ +invoker.goals = eclipse:clean eclipse:eclipse \ No newline at end of file Added: maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/pom.xml?rev=1154754&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/pom.xml (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/pom.xml Sun Aug 7 19:49:56 2011 @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.it</groupId> + <artifactId>meclipse-676</artifactId> + <version>0.1-SNAPSHOT</version> + <name>meclipse676</name> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <linkedResources> + <linkedResource> + <name>src/main/webapp/docroot/myfolder</name> + <type>2</type> + <locationURI>FOLDER_VAR/otherfolder/myfolder</locationURI> + </linkedResource> + </linkedResources> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Added: maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/verify.bsh?rev=1154754&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/verify.bsh (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/it/MECLIPSE-676/verify.bsh Sun Aug 7 19:49:56 2011 @@ -0,0 +1,56 @@ + +/* + * 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 java.io.*; +import java.util.*; +import java.util.jar.*; +import org.codehaus.plexus.util.*; + +boolean result = true; + +try +{ + File dotProject = new File( basedir, ".project"); + if( !dotProject.exists() ) + { + System.err.println( "Expected .project, but file doesn't exist" ); + return false; + } + + String dotProjectContent = FileUtils.fileRead( dotProject, "UTF-8" ); + if ( dotProjectContent.indexOf( "<locationURI>FOLDER_VAR/otherfolder/myfolder</locationURI>" ) < 0 ) + { + System.err.println( "Expected .project to contain '<locationURI>FOLDER_VAR/otherfolder/myfolder</locationURI>', but it didn't" ); + return false; + } + + if ( dotProjectContent.indexOf( "<location>" ) >= 0 ) + { + System.err.println( "Expected .project to not contain '<location>', but it did" ); + return false; + } + +} +catch ( Exception e) +{ + e.printStackTrace(); + result = false; +} +return result; \ No newline at end of file Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java?rev=1154754&r1=1154753&r2=1154754&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java Sun Aug 7 19:49:56 2011 @@ -38,6 +38,9 @@ public class LinkedResource /** Resource location */ private String location; + /** Resource localtionURI */ + private String locationURI; + public String getName() { return name; @@ -68,6 +71,16 @@ public class LinkedResource this.location = location; } + public String getLocationURI() + { + return locationURI; + } + + public void setLocationURI( String locationURI ) + { + this.locationURI = locationURI; + } + /** * Default constructor */ @@ -104,10 +117,15 @@ public class LinkedResource type = typeNode.getValue(); Xpp3Dom locationNode = node.getChild( "location" ); + Xpp3Dom locationURINode = node.getChild( "locationURI" ); - if ( locationNode == null ) + if ( locationNode == null && locationURINode == null ) { - throw new IllegalArgumentException( "No location node." ); + throw new IllegalArgumentException( "No location or locationURI node." ); + } + else if ( locationNode != null && locationURINode != null ) + { + throw new IllegalArgumentException( "Both location and locationURI nodes are set." ); } location = locationNode.getValue(); @@ -125,9 +143,18 @@ public class LinkedResource writer.writeText( type ); writer.endElement(); // type - writer.startElement( "location" ); - writer.writeText( location ); - writer.endElement(); // location + if ( location != null ) + { + writer.startElement( "location" ); + writer.writeText( location ); + writer.endElement(); // location + } + else if ( locationURI != null ) + { + writer.startElement( "locationURI" ); + writer.writeText( locationURI ); + writer.endElement(); // locationURI + } writer.endElement();// link } @@ -138,7 +165,8 @@ public class LinkedResource LinkedResource b = (LinkedResource) obj; return name.equals( b.name ) && ( type == null ? b.type == null : type.equals( b.type ) ) - && ( location == null ? b.location == null : location.equals( b.location ) ); + && ( location == null ? b.location == null : location.equals( b.location ) ) + && ( locationURI == null ? b.locationURI == null : locationURI.equals( b.locationURI ) ); } else { @@ -149,6 +177,7 @@ public class LinkedResource public int hashCode() { return name.hashCode() + ( type == null ? 0 : 13 * type.hashCode() ) - + ( location == null ? 0 : 17 * location.hashCode() ); + + ( location == null ? 0 : 17 * location.hashCode() ) + + ( locationURI == null ? 0 : 19 * locationURI.hashCode() ); } }