Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7667] Fix Bootstrap IT #230

Merged
merged 4 commits into from
Jan 12, 2023
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
Expand Up @@ -57,7 +57,10 @@ public void testBootstrap()
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
verifier.addCliOption( "-Dbootstrap=" + getClass().getResource( "/bootstrap.txt" ).toURI().getPath() );
verifier.addCliArgument( "install" );

// bootstrap plugin is bound to this phase, do not go further
// important: maven-plugin packaging will fail at package phase, as there is no Mojo present!
verifier.addCliArgument( "process-resources" );
verifier.execute();
verifier.verifyErrorFreeLog();
}
Expand Down
40 changes: 40 additions & 0 deletions core-it-suite/src/test/resources/bootstrap/bootstrap/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.its.bootstrap</groupId>
<artifactId>maven-it-boostrap</artifactId>
<version>1.0</version>
</parent>

<artifactId>bootstrap</artifactId>
<packaging>pom</packaging>

<name>Maven Integration Test :: Boostrap :: boostrap</name>

<!-- We do want the file here -->
<properties>
<file>${bootstrap}</file>
</properties>
</project>
35 changes: 35 additions & 0 deletions core-it-suite/src/test/resources/bootstrap/packaging-jar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.its.bootstrap</groupId>
<artifactId>maven-it-boostrap</artifactId>
<version>1.0</version>
</parent>

<artifactId>packaging-jar</artifactId>
<packaging>jar</packaging>

<name>Maven Integration Test :: Boostrap :: packaging-jar</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.its.bootstrap</groupId>
<artifactId>maven-it-boostrap</artifactId>
<version>1.0</version>
</parent>

<artifactId>packaging-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>Maven Integration Test :: Boostrap :: packaging-maven-plugin</name>
</project>
35 changes: 35 additions & 0 deletions core-it-suite/src/test/resources/bootstrap/packaging-war/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.its.bootstrap</groupId>
<artifactId>maven-it-boostrap</artifactId>
<version>1.0</version>
</parent>

<artifactId>packaging-war</artifactId>
<packaging>war</packaging>

<name>Maven Integration Test :: Boostrap :: packaging-war</name>
</project>
17 changes: 12 additions & 5 deletions core-it-suite/src/test/resources/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ under the License.
plugins cannot be downloaded by Maven from non-default repositories configured in the POM if the plugin is invoked
directly from the command line. Also, having this in a central place spares us from copying the snapshot repo
config all around in the IT POMs.

Each module does:
- boostrap - resolves all artifacts provided in bootstrap file
- packaging-* - resolves build plugins provided by tested Maven default lifecycle(s)
</description>

<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<modules>
<module>bootstrap</module>
<module>packaging-jar</module>
<module>packaging-maven-plugin</module>
<module>packaging-war</module>
</modules>

<build>
<!-- This merely locks the plugin versions to disable auto-update -->
<plugins>
<!-- This merely locks the plugin versions to disable auto-update -->
<plugin>
<groupId>org.apache.maven.its</groupId>
<artifactId>maven-it-plugin-bootstrap</artifactId>
Expand All @@ -53,7 +60,7 @@ under the License.
<goal>download</goal>
</goals>
<configuration>
<file>${bootstrap}</file>
<file>${file}</file>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
Expand All @@ -45,7 +48,8 @@
import org.eclipse.aether.resolution.DependencyRequest;

/**
* Boostrap plugin to download all required dependencies
* Boostrap plugin to download all required dependencies (provided in file) or to collect lifecycle bound build plugin
* versions.
*/
@Mojo( name = "download" )
public class DownloadMojo
Expand All @@ -56,13 +60,13 @@ public class DownloadMojo
* A list of artifacts coordinates.
*/
@Parameter
private List<Dependency> dependencies = new ArrayList<>();
private Set<Dependency> dependencies = new HashSet<>();

/**
* A list of string of the form groupId:artifactId:version[:packaging[:classifier]].
*/
@Parameter
private List<String> artifacts = new ArrayList<>();
private Set<String> artifacts = new HashSet<>();

/**
* A file containing lines of the form groupId:artifactId:version[:packaging[:classifier]].
Expand All @@ -82,8 +86,10 @@ public class DownloadMojo
@Override
public void execute() throws MojoFailureException
{
// this or that: either resolver file listed artifacts or collect lifecycle packaging plugins
if ( file != null && file.exists() )
{
System.out.println( "Collecting artifacts from file: " + file );
slawekjaranowski marked this conversation as resolved.
Show resolved Hide resolved
try ( BufferedReader reader = new BufferedReader( new FileReader( file ) ) )
{
reader.lines()
Expand All @@ -96,6 +102,16 @@ public void execute() throws MojoFailureException
throw new MojoFailureException( "Unable to read dependencies: " + file, e );
}
}
else
{
MavenProject project = session.getCurrentProject();
System.out.println( "Collecting build plugins from packaging: " + project.getPackaging() );
for ( Plugin plugin : project.getBuildPlugins() )
{
artifacts.add( plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() );
}
}

for ( String artifact : artifacts )
{
if ( artifact != null )
Expand Down