Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ under the License.
<slf4jVersion>1.7.36</slf4jVersion>
<jettyVersion>9.4.58.v20250814</jettyVersion>
<mockito.version>4.11.0</mockito.version>
<domtripVersion>0.6.0</domtripVersion>
<plexus-archiver.version>4.11.0</plexus-archiver.version>
<pluginTestingVersion>3.5.1</pluginTestingVersion>

Expand Down Expand Up @@ -198,6 +199,18 @@ under the License.
<version>1.1.0</version>
</dependency>

<!-- domtrip -->
<dependency>
<groupId>eu.maveniverse.maven.domtrip</groupId>
<artifactId>domtrip-core</artifactId>
<version>${domtripVersion}</version>
</dependency>
<dependency>
<groupId>eu.maveniverse.maven.domtrip</groupId>
<artifactId>domtrip-maven</artifactId>
<version>${domtripVersion}</version>
</dependency>

<!-- shared -->
<dependency>
<groupId>org.apache.maven.shared</groupId>
Expand Down Expand Up @@ -319,7 +332,6 @@ under the License.
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
Expand Down
18 changes: 18 additions & 0 deletions src/it/projects/add-dependency-align-properties/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:add
62 changes: 62 additions & 0 deletions src/it/projects/add-dependency-align-properties/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
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.
-->

<!-- Test project that uses version properties but NO managed dependencies.
When align=true (default), adding a new dependency should detect the
property naming convention (.version suffix) and create a property,
but should NOT use managed dependencies. -->

<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>

<groupId>org.apache.maven.plugins.dependency.its</groupId>
<artifactId>add-dependency-align-properties</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<junit.version>4.13.2</junit.version>
<slf4j.version>2.0.9</slf4j.version>
<commons-io.version>2.15.0</commons-io.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>

</project>
18 changes: 18 additions & 0 deletions src/it/projects/add-dependency-align-properties/test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

gav=com.google.guava:guava:33.0.0-jre
45 changes: 45 additions & 0 deletions src/it/projects/add-dependency-align-properties/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.
*/

def pomText = new File( basedir, "pom.xml" ).text
def pom = new groovy.xml.XmlSlurper().parse( new File( basedir, "pom.xml" ) )

// Align should detect that all 3 existing deps use .version property convention
// and create a guava.version property for the new dependency
assert pomText.contains( '<guava.version>33.0.0-jre</guava.version>' ) :
"Should have created guava.version property (matching existing .version suffix convention)"
assert pomText.contains( '${guava.version}' ) :
"Dependency version should reference \${guava.version}"

// Align should NOT use managed dependencies (all existing deps have explicit versions)
def managedDeps = pom.dependencyManagement.dependencies.dependency
assert managedDeps.isEmpty() :
"Should NOT have created dependencyManagement (existing deps all have versions)"

// Verify the dependency was added to regular dependencies
def dep = pom.dependencies.dependency.find { it.artifactId == 'guava' }
assert dep != null : "guava should be in dependencies"

// Verify existing deps are preserved
assert pom.dependencies.dependency.size() == 4 : "Should have 4 dependencies total"
assert pomText.contains( '${junit.version}' ) : "Existing junit property ref preserved"
assert pomText.contains( '${slf4j.version}' ) : "Existing slf4j property ref preserved"
assert pomText.contains( '${commons-io.version}' ) : "Existing commons-io property ref preserved"

return true
18 changes: 18 additions & 0 deletions src/it/projects/add-dependency-align/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:add
81 changes: 81 additions & 0 deletions src/it/projects/add-dependency-align/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
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.
-->

<!-- Test project that already uses managed dependencies with version properties.
When align=true (default), adding a new dependency should follow the same conventions:
- version property with .version suffix
- managed dependency in dependencyManagement
- version-less entry in dependencies -->

<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>

<groupId>org.apache.maven.plugins.dependency.its</groupId>
<artifactId>add-dependency-align</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<junit.version>4.13.2</junit.version>
<slf4j.version>2.0.9</slf4j.version>
<commons-io.version>2.15.0</commons-io.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- All version-less: project uses managed deps pattern -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>

</project>
18 changes: 18 additions & 0 deletions src/it/projects/add-dependency-align/test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

gav=com.google.guava:guava:33.0.0-jre
52 changes: 52 additions & 0 deletions src/it/projects/add-dependency-align/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.
*/

def pomText = new File( basedir, "pom.xml" ).text
def pom = new groovy.xml.XmlSlurper().parse( new File( basedir, "pom.xml" ) )

// Verify auto-detection created a version property following the .version convention
assert pomText.contains( '<guava.version>33.0.0-jre</guava.version>' ) :
"Should have created guava.version property (matching existing .version suffix pattern)"

// Verify managed dependency was added with property reference
def managedDeps = pom.dependencyManagement.dependencies.dependency
def managedGuava = managedDeps.find { it.artifactId == 'guava' }
assert managedGuava != null : "guava should be in dependencyManagement"
assert pomText.contains( '${guava.version}' ) :
"Managed dependency version should reference \${guava.version}"

// Verify version-less dependency was added to regular dependencies
def deps = pom.dependencies.dependency
def guava = deps.find { it.artifactId == 'guava' }
assert guava != null : "guava should be in dependencies"

// Verify the regular dependency is version-less (version comes from managed deps)
// In the raw XML, the dependency entry should NOT have a <version> element
def depsSection = pomText.substring( pomText.lastIndexOf( '<dependencies>' ) )
def guavaBlock = depsSection.substring( depsSection.indexOf( 'guava' ) )
guavaBlock = guavaBlock.substring( 0, guavaBlock.indexOf( '</dependency>' ) )
assert !guavaBlock.contains( '<version>' ) :
"Regular dependency should be version-less (managed by dependencyManagement)"

// Verify existing dependencies are preserved
assert deps.find { it.artifactId == 'junit' } != null
assert deps.find { it.artifactId == 'slf4j-api' } != null
assert deps.find { it.artifactId == 'commons-io' } != null

return true
18 changes: 18 additions & 0 deletions src/it/projects/add-dependency-managed/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:add
Loading