Skip to content

Commit

Permalink
[MINVOKER-313] Get rid of maven-artifact-transfer - InstallMojo refactor
Browse files Browse the repository at this point in the history
- refactor InstallMojo to use Resolver API
- add possibility to configure scope for installing artifacts
- remove maven-artifact-transfer and maven-common-artifact-filters from dependencies
  • Loading branch information
slawekjaranowski committed Jan 31, 2023
1 parent c06ec6c commit 74de493
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 546 deletions.
13 changes: 0 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,6 @@ under the License.
<version>1.4</version>
</dependency>

<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-artifact-transfer</artifactId>
<version>0.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>${beanshell-groupId}</groupId>
<artifactId>${beanshell-artifactId}</artifactId>
Expand Down Expand Up @@ -411,7 +399,6 @@ under the License.
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<mavenOpts>-Djava.io.tmpdir=${project.build.directory}</mavenOpts>
<streamLogsOnFailures>true</streamLogsOnFailures>
<properties>
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
Expand Down
18 changes: 18 additions & 0 deletions src/it/staging-dependencies-test-scope/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 = verify
71 changes: 71 additions & 0 deletions src/it/staging-dependencies-test-scope/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test</groupId>
<artifactId>staging-dependencies-test-scope</artifactId>
<version>1.0-SNAPSHOT</version>

<description>
Test to check for staging of test scope dependencies.
</description>

<dependencies>
<!-- compile scope -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>

<!-- test scope dependency -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<scope>test</scope>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
65 changes: 65 additions & 0 deletions src/it/staging-dependencies-test-scope/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 java.util.*;
import java.util.regex.*;

import org.codehaus.plexus.util.*;
import org.codehaus.plexus.util.xml.*;

try
{
File itRepoDir = new File( basedir, "target/it-repo" );
System.out.println( "Checking for existence of: " + itRepoDir );
if ( !itRepoDir.isDirectory() )
{
System.out.println( "FAILED!" );
return false;
}

String[] files = {
"org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar",
"org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom",
"org/slf4j/slf4j-api/maven-metadata-local.xml",
"org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom",
"org/slf4j/slf4j-parent/maven-metadata-local.xml",
"org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar",
"org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.pom",
"org/slf4j/slf4j-simple/maven-metadata-local.xml",
"test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.pom",
"test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.jar"
};
for ( String file : files )
{
File stagedFile = new File( itRepoDir, file );
System.out.println( "Checking for existence of: " + stagedFile );
if ( !stagedFile.isFile() )
{
throw new IllegalStateException( "Missing: " + stagedFile );
}
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;
6 changes: 6 additions & 0 deletions src/it/staging-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ under the License.
<artifactId>dep</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
Expand Down
8 changes: 8 additions & 0 deletions src/it/staging-dependencies/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ try
"org/apache/maven/its/dep/2.0/dep-2.0.pom",
"org/apache/maven/its/dep/2.0/dep-2.0.jar",
"org/apache/maven/its/dep/maven-metadata-local.xml",
"test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.jar",
"test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom"
};
for ( String file : files )
{
Expand All @@ -67,6 +69,12 @@ try
}
}

File stagedTestScope = new File(itRepoDir, "org/slf4j/slf4j-simple");
if ( stagedTestScope.exists() )
{
throw new IllegalStateException( "Test scope dependencies should not exists" );
}

Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) );
Xpp3Dom dom = Xpp3DomBuilder.build( reader );
IOUtil.close( reader );
Expand Down
11 changes: 11 additions & 0 deletions src/it/staging-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>39</version>
<relativePath />
</parent>

<groupId>test</groupId>
<artifactId>pom-packaging</artifactId>
<version>1.0-SNAPSHOT</version>
Expand All @@ -31,6 +38,10 @@ under the License.
Test to check for MINVOKER-51, i.e. NPE when packaging is pom.
</description>

<properties>
<spotless.check.skip>true</spotless.check.skip>
</properties>

<build>
<plugins>
<plugin>
Expand Down
3 changes: 3 additions & 0 deletions src/it/staging-pom/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ try

String[] files = {
"test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom",
"org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom",
"org/apache/maven/maven-parent/39/maven-parent-39.pom",
"org/apache/apache/29/apache-29.pom"
};
for ( String file : files )
{
Expand Down
1 change: 0 additions & 1 deletion src/it/staging-reactor/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ try
"test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml",
"test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom",
"test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar",
"test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT-sources.jar",
"test/mod2-parent/maven-metadata-local.xml",
"test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml",
"test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom",
Expand Down

0 comments on commit 74de493

Please sign in to comment.