mirror of https://github.com/apache/maven.git
o Improving toString for Dependency in the 4.0.0 version codeSegment in maven.mdo
o Improving error messages for ResourceDoesNotExistException in the transformations o Adding specificity to the dependency validation stuff, to output which dependency is offending... o Added it1013 to show off the new dependency validation stuff. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@232399 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
155c0a69a7
commit
88d49cb04f
|
@ -98,7 +98,9 @@ public abstract class AbstractVersionTransformation
|
|||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
getLogger().debug( "Error resolving artifact version from metadata.", e );
|
||||
getLogger().debug(
|
||||
"Artifact version metadata for: " + artifact.getId()
|
||||
+ " could not be found on repository: " + repository.getId(), e );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ public class SnapshotTransformation
|
|||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Snapshot version metadata for: " + artifact.getId()
|
||||
+ " not found. Creating a new metadata instance.", e );
|
||||
|
||||
// ignore. We'll be creating this metadata if it doesn't exist...
|
||||
metadata = (SnapshotArtifactMetadata) createMetadata( artifact );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
target/classes/org/apache/maven/it0000/Person.class
|
||||
target/test-classes/org/apache/maven/it0000/PersonTest.class
|
||||
target/maven-core-it0000-1.0.jar
|
|
@ -0,0 +1 @@
|
|||
package
|
|
@ -0,0 +1,14 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-core-it1001</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
|
@ -0,0 +1,5 @@
|
|||
package org.apache.maven.it1000;
|
||||
|
||||
public class Dummy
|
||||
{
|
||||
}
|
|
@ -1265,7 +1265,7 @@
|
|||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>3.0.0+</version>
|
||||
<version>3.0.0</version>
|
||||
<code><![CDATA[
|
||||
public String toString()
|
||||
{
|
||||
|
@ -1273,6 +1273,15 @@
|
|||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
<codeSegment>
|
||||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
public String toString()
|
||||
{
|
||||
return "Dependency {groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version + ", type=" + type + "}";
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
<codeSegment>
|
||||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
|
|
|
@ -55,13 +55,13 @@ public class DefaultModelValidator
|
|||
{
|
||||
Dependency d = (Dependency) it.next();
|
||||
|
||||
validateStringNotEmpty( "dependencies.dependency.artifactId", result, d.getArtifactId() );
|
||||
validateSubElementStringNotEmpty( d, "dependencies.dependency.artifactId", result, d.getArtifactId() );
|
||||
|
||||
validateStringNotEmpty( "dependencies.dependency.groupId", result, d.getGroupId() );
|
||||
validateSubElementStringNotEmpty( d, "dependencies.dependency.groupId", result, d.getGroupId() );
|
||||
|
||||
validateStringNotEmpty( "dependencies.dependency.type", result, d.getType() );
|
||||
validateSubElementStringNotEmpty( d, "dependencies.dependency.type", result, d.getType() );
|
||||
|
||||
validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion() );
|
||||
validateSubElementStringNotEmpty( d, "dependencies.dependency.version", result, d.getVersion() );
|
||||
}
|
||||
|
||||
DependencyManagement mgmt = model.getDependencyManagement();
|
||||
|
@ -71,14 +71,11 @@ public class DefaultModelValidator
|
|||
{
|
||||
Dependency d = (Dependency) it.next();
|
||||
|
||||
validateStringNotEmpty( "dependencyManagement.dependencies.dependency.artifactId", result,
|
||||
validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.artifactId", result,
|
||||
d.getArtifactId() );
|
||||
|
||||
validateStringNotEmpty( "dependencyManagement.dependencies.dependency.groupId", result,
|
||||
validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.groupId", result,
|
||||
d.getGroupId() );
|
||||
|
||||
validateStringNotEmpty( "dependencyManagement.dependencies.dependency.version", result,
|
||||
d.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +161,32 @@ public class DefaultModelValidator
|
|||
return true;
|
||||
}
|
||||
|
||||
result.addMessage( "'" + fieldName + "' is empty." );
|
||||
result.addMessage( "'" + fieldName + "' is missing." );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts:
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li><code>string.length != null</code>
|
||||
* <li><code>string.length > 0</code>
|
||||
* </ul>
|
||||
*/
|
||||
private boolean validateSubElementStringNotEmpty( Object subElementInstance, String fieldName, ModelValidationResult result, String string )
|
||||
{
|
||||
if ( !validateSubElementNotNull( subElementInstance, fieldName, result, string ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( string.length() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -187,4 +209,23 @@ public class DefaultModelValidator
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts:
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li><code>string != null</code>
|
||||
* </ul>
|
||||
*/
|
||||
private boolean validateSubElementNotNull( Object subElementInstance, String fieldName, ModelValidationResult result, Object object )
|
||||
{
|
||||
if ( object != null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'packaging' is empty.", result.getMessage( 0 ) );
|
||||
assertEquals( "'packaging' is missing.", result.getMessage( 0 ) );
|
||||
}
|
||||
|
||||
public void testMissingVersion()
|
||||
|
@ -92,7 +92,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencies.dependency.artifactId' is missing.", result.getMessage( 0 ) );
|
||||
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.artifactId' is missing." ) > -1 );
|
||||
}
|
||||
|
||||
public void testMissingDependencyGroupId()
|
||||
|
@ -102,7 +102,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencies.dependency.groupId' is missing.", result.getMessage( 0 ) );
|
||||
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.groupId' is missing." ) > -1 );
|
||||
}
|
||||
|
||||
public void testMissingDependencyVersion()
|
||||
|
@ -112,7 +112,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencies.dependency.version' is missing.", result.getMessage( 0 ) );
|
||||
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.version' is missing." ) > -1 );
|
||||
}
|
||||
|
||||
public void testMissingDependencyManagementArtifactId()
|
||||
|
@ -122,7 +122,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencyManagement.dependencies.dependency.artifactId' is missing.", result.getMessage( 0 ) );
|
||||
assertTrue( result.getMessage( 0 ).indexOf( "'dependencyManagement.dependencies.dependency.artifactId' is missing." ) > -1 );
|
||||
}
|
||||
|
||||
public void testMissingDependencyManagementGroupId()
|
||||
|
@ -132,17 +132,7 @@ public class DefaultModelValidatorTest
|
|||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencyManagement.dependencies.dependency.groupId' is missing.", result.getMessage( 0 ) );
|
||||
}
|
||||
|
||||
public void testMissingDependencyManagementVersion()
|
||||
throws Exception
|
||||
{
|
||||
ModelValidationResult result = validate( "missing-dependency-mgmt-version-pom.xml" );
|
||||
|
||||
assertEquals( 1, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'dependencyManagement.dependencies.dependency.version' is missing.", result.getMessage( 0 ) );
|
||||
assertTrue( result.getMessage( 0 ).indexOf( "'dependencyManagement.dependencies.dependency.groupId' is missing." ) > -1 );
|
||||
}
|
||||
|
||||
public void testMissingAll()
|
||||
|
|
Loading…
Reference in New Issue