mirror of https://github.com/apache/maven.git
[MNG-4648] NullPointerException thrown from DefaultPluginRealmCache#pluginHashCode method if project-level plugin dependency misses version
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@938410 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
809969a06b
commit
83389c3402
|
@ -253,12 +253,7 @@ public class DefaultModelValidator
|
||||||
validateBoolean( "build.plugins.plugin.extensions", problems, errOn30, p.getExtensions(),
|
validateBoolean( "build.plugins.plugin.extensions", problems, errOn30, p.getExtensions(),
|
||||||
p.getKey() );
|
p.getKey() );
|
||||||
|
|
||||||
for ( Dependency d : p.getDependencies() )
|
validateEffectivePluginDependencies( problems, p, request );
|
||||||
{
|
|
||||||
validateEnum( "build.plugins.plugin[" + p.getKey() + "].dependencies.dependency.scope",
|
|
||||||
problems, errOn30, d.getScope(), d.getManagementKey(),
|
|
||||||
"compile", "runtime", "system" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validateResources( problems, build.getResources(), "build.resources.resource", request );
|
validateResources( problems, build.getResources(), "build.resources.resource", request );
|
||||||
|
@ -365,24 +360,70 @@ public class DefaultModelValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateEffectiveDependencies( ModelProblemCollector problems, List<Dependency> dependencies,
|
private void validateEffectiveDependencies( ModelProblemCollector problems, List<Dependency> dependencies,
|
||||||
boolean managed, ModelBuildingRequest request )
|
boolean management, ModelBuildingRequest request )
|
||||||
{
|
{
|
||||||
Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
|
Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
|
||||||
|
|
||||||
String prefix = managed ? "dependencyManagement.dependencies.dependency." : "dependencies.dependency.";
|
String prefix = management ? "dependencyManagement.dependencies.dependency." : "dependencies.dependency.";
|
||||||
|
|
||||||
for ( Dependency d : dependencies )
|
for ( Dependency d : dependencies )
|
||||||
|
{
|
||||||
|
validateEffectiveDependency( problems, d, management, prefix, request );
|
||||||
|
|
||||||
|
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
||||||
|
{
|
||||||
|
validateBoolean( prefix + "optional", problems, errOn30, d.getOptional(), d.getManagementKey() );
|
||||||
|
|
||||||
|
if ( !management )
|
||||||
|
{
|
||||||
|
validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey() );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc. In
|
||||||
|
* order to don't break backward-compat with those, only warn but don't error out.
|
||||||
|
*/
|
||||||
|
validateEnum( prefix + "scope", problems, Severity.WARNING, d.getScope(), d.getManagementKey(),
|
||||||
|
"provided", "compile", "runtime", "test", "system" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateEffectivePluginDependencies( ModelProblemCollector problems, Plugin plugin,
|
||||||
|
ModelBuildingRequest request )
|
||||||
|
{
|
||||||
|
List<Dependency> dependencies = plugin.getDependencies();
|
||||||
|
|
||||||
|
if ( !dependencies.isEmpty() )
|
||||||
|
{
|
||||||
|
String prefix = "build.plugins.plugin[" + plugin.getKey() + "].dependencies.dependency.";
|
||||||
|
|
||||||
|
Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
|
||||||
|
|
||||||
|
for ( Dependency d : dependencies )
|
||||||
|
{
|
||||||
|
validateEffectiveDependency( problems, d, false, prefix, request );
|
||||||
|
|
||||||
|
validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey() );
|
||||||
|
|
||||||
|
validateEnum( prefix + "scope", problems, errOn30, d.getScope(), d.getManagementKey(), "compile",
|
||||||
|
"runtime", "system" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateEffectiveDependency( ModelProblemCollector problems, Dependency d, boolean management,
|
||||||
|
String prefix, ModelBuildingRequest request )
|
||||||
{
|
{
|
||||||
validateId( prefix + "artifactId", problems, d.getArtifactId(), d.getManagementKey() );
|
validateId( prefix + "artifactId", problems, d.getArtifactId(), d.getManagementKey() );
|
||||||
|
|
||||||
validateId( prefix + "groupId", problems, d.getGroupId(), d.getManagementKey() );
|
validateId( prefix + "groupId", problems, d.getGroupId(), d.getManagementKey() );
|
||||||
|
|
||||||
if ( !managed )
|
if ( !management )
|
||||||
{
|
{
|
||||||
validateStringNotEmpty( prefix + "type", problems, Severity.ERROR, d.getType(), d.getManagementKey() );
|
validateStringNotEmpty( prefix + "type", problems, Severity.ERROR, d.getType(), d.getManagementKey() );
|
||||||
|
|
||||||
validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, d.getVersion(),
|
validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, d.getVersion(), d.getManagementKey() );
|
||||||
d.getManagementKey() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( "system".equals( d.getScope() ) )
|
if ( "system".equals( d.getScope() ) )
|
||||||
|
@ -420,24 +461,6 @@ public class DefaultModelValidator
|
||||||
addViolation( problems, Severity.ERROR, prefix + "systemPath", d.getManagementKey(), "must be omitted."
|
addViolation( problems, Severity.ERROR, prefix + "systemPath", d.getManagementKey(), "must be omitted."
|
||||||
+ " This field may only be specified for a dependency with system scope." );
|
+ " This field may only be specified for a dependency with system scope." );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
|
||||||
{
|
|
||||||
validateBoolean( prefix + "optional", problems, errOn30, d.getOptional(), d.getManagementKey() );
|
|
||||||
|
|
||||||
if ( !managed )
|
|
||||||
{
|
|
||||||
validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey() );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc. In
|
|
||||||
* order to don't break backward-compat with those, only warn but don't error out.
|
|
||||||
*/
|
|
||||||
validateEnum( prefix + "scope", problems, Severity.WARNING, d.getScope(), d.getManagementKey(),
|
|
||||||
"provided", "compile", "runtime", "test", "system" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateRepositories( ModelProblemCollector problems, List<Repository> repositories, String prefix,
|
private void validateRepositories( ModelProblemCollector problems, List<Repository> repositories, String prefix,
|
||||||
|
|
|
@ -449,4 +449,44 @@ public class DefaultModelValidatorTest
|
||||||
"'distributionManagement.snapshotRepository.id' must not be 'local'" ) );
|
"'distributionManagement.snapshotRepository.id' must not be 'local'" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMissingPluginDependencyGroupId()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validate( "missing-plugin-dependency-groupId.xml" );
|
||||||
|
|
||||||
|
assertViolations( result, 0, 1, 0 );
|
||||||
|
|
||||||
|
assertTrue( result.getErrors().get( 0 ).contains( ":a:" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingPluginDependencyArtifactId()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validate( "missing-plugin-dependency-artifactId.xml" );
|
||||||
|
|
||||||
|
assertViolations( result, 0, 1, 0 );
|
||||||
|
|
||||||
|
assertTrue( result.getErrors().get( 0 ).contains( "test:" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingPluginDependencyVersion()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validate( "missing-plugin-dependency-version.xml" );
|
||||||
|
|
||||||
|
assertViolations( result, 0, 1, 0 );
|
||||||
|
|
||||||
|
assertTrue( result.getErrors().get( 0 ).contains( "test:a" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBadPluginDependencyVersion()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validate( "bad-plugin-dependency-version.xml" );
|
||||||
|
|
||||||
|
assertViolations( result, 0, 1, 0 );
|
||||||
|
|
||||||
|
assertTrue( result.getErrors().get( 0 ).contains( "test:b" ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!--
|
||||||
|
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>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-it-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>a</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>b</artifactId>
|
||||||
|
<version>${missing.property}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!--
|
||||||
|
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>1.0</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-it-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<!-- artifact id missing -->
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!--
|
||||||
|
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>1.0</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-it-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<!-- groupd id missing -->
|
||||||
|
<artifactId>a</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!--
|
||||||
|
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>1.0</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-it-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>a</artifactId>
|
||||||
|
<!-- version missing -->
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Loading…
Reference in New Issue