Skip to content

Commit

Permalink
MNG-5783 test plugin.artifacts can include slf4j
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
  • Loading branch information
ifedorenko committed Mar 10, 2015
1 parent 638261b commit be0edcf
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 0 deletions.
Expand Up @@ -106,6 +106,7 @@ public static Test suite()
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137

suite.addTestSuite( MavenITmng5783PluginDependencyFiltering.class );
suite.addTestSuite( MavenITmng5774ConfigurationProcessorsTest.class );
suite.addTestSuite( MavenITmng5771CoreExtensionsTest.class );
suite.addTestSuite( MavenITmng5768CliExecutionIdTest.class );
Expand Down
@@ -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 ) );
}
}
@@ -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>
@@ -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 );
}

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

0 comments on commit be0edcf

Please sign in to comment.