Skip to content
Merged
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
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 = clean package
95 changes: 95 additions & 0 deletions src/it/projects/mdep-592-addparentpoms-custom-repo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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.
-->

<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.its.dependency</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Test MDEP-592</name>
<description>
Test for MDEP-592: addParentPoms=true causes repositories to be ignored.

This test verifies that when using copy-dependencies with addParentPoms=true,
the plugin correctly uses the project's configured remote repositories to resolve
parent POMs. The test dependency (test-child) has a parent POM (test-parent) that
is only available in a custom repository (fake-remote-repository, not Maven Central).

CRITICAL: This test uses repository id "fake-remote-repository" which is explicitly
excluded from MRM mirroring in src/it/mrm/settings.xml. This ensures the repository
is ONLY available if properly propagated via setRemoteRepositories().

Without the fix, the parent POM resolution would fail because the custom repository
would not be propagated to the ProjectBuildingRequest.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>fake-remote-repository</id>
<url>file:///${basedir}/repo/</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.mdep592</groupId>
<artifactId>test-child</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>test-addparentpoms</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<phase>package</phase>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<useRepositoryLayout>true</useRepositoryLayout>
<copyPom>true</copyPom>
<addParentPoms>true</addParentPoms>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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.
-->

<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>org.apache.maven.its.mdep592</groupId>
<artifactId>test-parent</artifactId>
<version>1.0</version>
</parent>

<artifactId>test-child</artifactId>

<name>Test Child for MDEP-592</name>
<description>
Child artifact for testing MDEP-592. This artifact has a parent POM that is only
available in a custom repository. The test verifies that addParentPoms=true correctly
uses the configured repository to resolve the parent.
</description>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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.
-->

<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.its.mdep592</groupId>
<artifactId>test-parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<name>Test Parent for MDEP-592</name>
<description>
Minimal parent POM for testing MDEP-592: addParentPoms=true causes repositories to be ignored.
This parent POM is only available in a custom repository, not Maven Central.
</description>

</project>
44 changes: 44 additions & 0 deletions src/it/projects/mdep-592-addparentpoms-custom-repo/setup.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.
*/

import java.io.*;
import org.codehaus.plexus.util.*;

// Clean up test artifacts from local repository to ensure fresh test
// This forces Maven to download artifacts from the fake-remote-repository
// rather than using cached versions
String[] foldersToDelete = {
"org/apache/maven/its/mdep592/test-parent",
"org/apache/maven/its/mdep592/test-child"
};

try
{
for ( String folderToDelete : foldersToDelete )
{
FileUtils.deleteDirectory( new File( localRepositoryPath, folderToDelete ) );
}
}
catch( IOException e )
{
e.printStackTrace();
return false;
}

return true;
42 changes: 42 additions & 0 deletions src/it/projects/mdep-592-addparentpoms-custom-repo/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/

import java.io.*;

File outputDir = new File( basedir, "target/dependencies" );

String[] expectedFiles = {
"org/apache/maven/its/mdep592/test-child/1.0/test-child-1.0.jar",
"org/apache/maven/its/mdep592/test-child/1.0/test-child-1.0.pom",
// CRITICAL TEST for MDEP-592: Parent POM from custom repository
// Without the fix, this file would be missing because the custom repository
// would not be propagated to the ProjectBuildingRequest
"org/apache/maven/its/mdep592/test-parent/1.0/test-parent-1.0.pom"
};

for ( String expectedFile : expectedFiles )
{
File file = new File( outputDir, expectedFile );
if ( !file.isFile() )
{
throw new Exception( "Missing file " + file );
}
}

return true;
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ private MavenProject buildProjectFromArtifact(Artifact artifact) throws MojoExec
ProjectBuildingRequest buildingRequest =
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProcessPlugins(false);
buildingRequest.setRemoteRepositories(getProject().getRemoteArtifactRepositories());
return projectBuilder.build(artifact, buildingRequest).getProject();
} catch (ProjectBuildingException e) {
throw new MojoExecutionException("Coud not build project for " + artifact.getId(), e);
throw new MojoExecutionException("Could not build project for " + artifact.getId(), e);
}
}

Expand Down
Loading