Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MNG-5783 test plugin.artifacts can include slf4j
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
- Loading branch information
1 parent
638261b
commit be0edcf
Showing
5 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5783PluginDependencyFiltering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.apache.maven.it; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.maven.it.util.ResourceExtractor; | ||
|
||
public class MavenITmng5783PluginDependencyFiltering | ||
extends AbstractMavenIntegrationTestCase | ||
{ | ||
|
||
public MavenITmng5783PluginDependencyFiltering() | ||
{ | ||
super( "[3.0,)" ); | ||
} | ||
|
||
public void testSLF4j() | ||
throws Exception | ||
{ | ||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5783-plugin-dependency-filtering" ); | ||
Verifier verifier = newVerifier( new File( testDir, "plugin" ).getAbsolutePath() ); | ||
verifier.executeGoal( "install" ); | ||
verifier.verifyErrorFreeLog(); | ||
verifier.resetStreams(); | ||
|
||
verifier = newVerifier( new File( testDir, "slf4j" ).getAbsolutePath(), "remote" ); | ||
verifier.executeGoal( "validate" ); | ||
verifier.verifyErrorFreeLog(); | ||
verifier.resetStreams(); | ||
|
||
// Note that plugin dependencies always include plugin itself and plexus-utils | ||
|
||
List<String> dependencies = verifier.loadLines( "target/dependencies.txt", "UTF-8" ); | ||
assertEquals( 3, dependencies.size() ); | ||
assertEquals( "mng-5783-plugin-dependency-filtering:mng-5783-plugin-dependency-filtering-plugin:maven-plugin:0.1", | ||
dependencies.get( 0 ) ); | ||
assertEquals( "org.slf4j:slf4j-api:jar:1.7.5", dependencies.get( 1 ) ); | ||
assertEquals( "org.codehaus.plexus:plexus-utils:jar:1.1", dependencies.get( 2 ) ); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
core-it-suite/src/test/resources/mng-5783-plugin-dependency-filtering/plugin/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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>mng-5783-plugin-dependency-filtering</groupId> | ||
<artifactId>mng-5783-plugin-dependency-filtering-plugin</artifactId> | ||
<version>0.1</version> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<properties> | ||
<maven-version>3.2.5</maven-version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>${maven-version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>${maven-version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-core</artifactId> | ||
<version>${maven-version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
72 changes: 72 additions & 0 deletions
72
...pendency-filtering/plugin/src/main/java/org/apache/maven/its/mng5783/plugin/TestMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.apache.maven.its.mng5783.plugin; | ||
|
||
/* | ||
* 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.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStreamWriter; | ||
import java.util.List; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
|
||
/** | ||
* @goal test | ||
*/ | ||
public class TestMojo | ||
extends AbstractMojo | ||
{ | ||
/** @parameter property="project.build.directory" */ | ||
private File outputDirectory; | ||
|
||
/** @parameter property="plugin.artifacts" */ | ||
private List<Artifact> artifacts; | ||
|
||
public void execute() | ||
throws MojoExecutionException | ||
{ | ||
try | ||
{ | ||
File file = new File( outputDirectory, "dependencies.txt" ); | ||
file.getParentFile().mkdirs(); | ||
BufferedWriter w = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) ); | ||
try | ||
{ | ||
for ( Artifact artifact : artifacts ) | ||
{ | ||
w.write( artifact.getId() ); | ||
w.newLine(); | ||
} | ||
} | ||
finally | ||
{ | ||
w.close(); | ||
} | ||
} | ||
catch ( IOException e ) | ||
{ | ||
throw new MojoExecutionException( e.getMessage(), e ); | ||
} | ||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
core-it-suite/src/test/resources/mng-5783-plugin-dependency-filtering/slf4j/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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>mng-5783-plugin-dependency-filtering</groupId> | ||
<artifactId>mng-5783-plugin-dependency-filtering-slf4j</artifactId> | ||
<version>0.1</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>mng-5783-plugin-dependency-filtering</groupId> | ||
<artifactId>mng-5783-plugin-dependency-filtering-plugin</artifactId> | ||
<version>0.1</version> | ||
<executions> | ||
<execution> | ||
<id>test</id> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<phase>validate</phase> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.5</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |