mirror of https://github.com/apache/maven.git
PR: MNG-1147
validate that resources have a directory git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f70dc8165c
commit
ac0cc23521
|
@ -25,6 +25,7 @@ import org.apache.maven.model.Plugin;
|
|||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@ -116,6 +117,20 @@ public class DefaultModelValidator
|
|||
|
||||
validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() );
|
||||
}
|
||||
|
||||
for ( Iterator it = build.getResources().iterator(); it.hasNext(); )
|
||||
{
|
||||
Resource r = (Resource) it.next();
|
||||
|
||||
validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() );
|
||||
}
|
||||
|
||||
for ( Iterator it = build.getTestResources().iterator(); it.hasNext(); )
|
||||
{
|
||||
Resource r = (Resource) it.next();
|
||||
|
||||
validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() );
|
||||
}
|
||||
}
|
||||
|
||||
Reporting reporting = model.getReporting();
|
||||
|
|
|
@ -191,6 +191,18 @@ public class DefaultModelValidatorTest
|
|||
assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) );
|
||||
}
|
||||
|
||||
public void testMissingResourceDirectory()
|
||||
throws Exception
|
||||
{
|
||||
ModelValidationResult result = validate( "missing-resource-directory-pom.xml" );
|
||||
|
||||
assertEquals( 2, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'build.resources.resource.directory' is missing.", result.getMessage( 0 ) );
|
||||
|
||||
assertEquals( "'build.testResources.testResource.directory' is missing.", result.getMessage( 1 ) );
|
||||
}
|
||||
|
||||
private ModelValidationResult validate( String testName )
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>foo</artifactId>
|
||||
<groupId>foo</groupId>
|
||||
<version>99.44</version>
|
||||
<packaging>bleh</packaging>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue