You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/11/20 20:05:34 UTC

svn commit: r882677 - in /maven/maven-3/trunk/maven-model-builder/src: main/java/org/apache/maven/model/validation/ test/java/org/apache/maven/model/validation/ test/resources/poms/validation/

Author: bentmann
Date: Fri Nov 20 19:05:13 2009
New Revision: 882677

URL: http://svn.apache.org/viewvc?rev=882677&view=rev
Log:
[MNG-4456] Deprecate fully qualified pathnames in system path

Added:
    maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml   (with props)
Modified:
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
    maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java

Modified: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java?rev=882677&r1=882676&r2=882677&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java (original)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java Fri Nov 20 19:05:13 2009
@@ -367,6 +367,15 @@
             {
                 addViolation( problems, Severity.ERROR, "'" + prefix + ".classifier' must be empty for imported POM: " + key );
             }
+            else if ( "system".equals( dependency.getScope() ) )
+            {
+                String sysPath = dependency.getSystemPath();
+                if ( StringUtils.isNotEmpty( sysPath ) && !hasExpression( sysPath ) )
+                {
+                    addViolation( problems, Severity.WARNING, "'" + prefix
+                        + ".systemPath' should use a variable instead of a hard-coded path: " + key + " -> " + sysPath );
+                }
+            }
 
             Dependency existing = index.get( key );
 

Modified: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java?rev=882677&r1=882676&r2=882677&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java (original)
+++ maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java Fri Nov 20 19:05:13 2009
@@ -403,4 +403,14 @@
         assertTrue( result.getFatals().get( 2 ).contains( "parent.version" ) );
     }
 
+    public void testHardCodedSystemPath()
+        throws Exception
+    {
+        SimpleProblemCollector result = validateRaw( "hard-coded-system-path.xml" );
+
+        assertViolations( result, 0, 0, 1 );
+
+        assertTrue( result.getWarnings().get( 0 ).contains( "test:a:jar" ) );
+    }
+
 }

Added: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml?rev=882677&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml (added)
+++ maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml Fri Nov 20 19:05:13 2009
@@ -0,0 +1,42 @@
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>aid</artifactId>
+  <groupId>gid</groupId>
+  <version>0.1</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>test</groupId>
+      <artifactId>a</artifactId>
+      <version>0.2</version>
+      <scope>system</scope>
+      <systemPath>should-use-variables-and-not-hard-code-this-path</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>test</groupId>
+      <artifactId>b</artifactId>
+      <version>0.1</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/good.jar</systemPath>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/validation/hard-coded-system-path.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision