mirror of https://github.com/apache/maven.git
[MNG-6342] Emit a WARNING about LATEST/RELEASE in parent
This commit is contained in:
parent
6285bb96c5
commit
5988085525
|
@ -105,6 +105,13 @@ public class DefaultModelValidator
|
||||||
+ ", the parent element cannot have the same groupId:artifactId as the project.",
|
+ ", the parent element cannot have the same groupId:artifactId as the project.",
|
||||||
parent );
|
parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( equals( "LATEST", parent.getVersion() ) || equals( "RELEASE", parent.getVersion() ) )
|
||||||
|
{
|
||||||
|
addViolation( problems, Severity.WARNING, Version.BASE, "parent.version", null,
|
||||||
|
"is either LATEST or RELEASE (both of them are being deprecated)", parent );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
|
||||||
|
|
|
@ -781,4 +781,19 @@ public class DefaultModelValidatorTest
|
||||||
assertEquals( "'version' contains an expression but should be a constant.", result.getWarnings().get( 0 ) );
|
assertEquals( "'version' contains an expression but should be a constant.", result.getWarnings().get( 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testParentVersionLATEST()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validateRaw( "raw-model/bad-parent-version-latest.xml" );
|
||||||
|
assertViolations( result, 0, 0, 1 );
|
||||||
|
assertEquals( "'parent.version' is either LATEST or RELEASE (both of them are being deprecated)", result.getWarnings().get( 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParentVersionRELEASE()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
SimpleProblemCollector result = validateRaw( "raw-model/bad-parent-version-release.xml" );
|
||||||
|
assertViolations( result, 0, 0, 1 );
|
||||||
|
assertEquals( "'parent.version' is either LATEST or RELEASE (both of them are being deprecated)", result.getWarnings().get( 0 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!--
|
||||||
|
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 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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.example.group</groupId>
|
||||||
|
<artifactId>com-parent</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>com.example.group</groupId>
|
||||||
|
<artifactId>valid-version-wrong</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
This will test if the validation for the parent version
|
||||||
|
is working correct in case of usage of LATEST
|
||||||
|
</description>
|
||||||
|
</project>
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!--
|
||||||
|
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 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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.example.group</groupId>
|
||||||
|
<artifactId>com-parent</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>com.example.group</groupId>
|
||||||
|
<artifactId>valid-version-wrong</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
This will test if the validation for the parent version
|
||||||
|
is working correct in case of usage of RELEASE
|
||||||
|
</description>
|
||||||
|
</project>
|
Loading…
Reference in New Issue