mirror of https://github.com/apache/maven.git
[MNG-4381] Allow extension plugins to contribute non-core components to be reused by other plugins
o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@819539 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
018a20043d
commit
2f2954db6e
|
@ -85,6 +85,7 @@ public class IntegrationTestSuite
|
|||
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng4381ExtensionSingletonComponentTest.class );
|
||||
suite.addTestSuite( MavenITmng4367LayoutAwareMirrorSelectionTest.class );
|
||||
suite.addTestSuite( MavenITmng4365XmlMarkupInAttributeValueTest.class );
|
||||
suite.addTestSuite( MavenITmng4363DynamicAdditionOfDependencyArtifactTest.class );
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4381">MNG-4381</a>.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng4381ExtensionSingletonComponentTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
public MavenITmng4381ExtensionSingletonComponentTest()
|
||||
{
|
||||
super( "[3.0-alpha-3,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that extension plugins can contribute non-core components that can be accessed by other plugins in the same
|
||||
* project and in projects with the same extension.
|
||||
*/
|
||||
public void testit()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4381" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "sub-a/target" );
|
||||
verifier.deleteDirectory( "sub-b/target" );
|
||||
verifier.executeGoal( "initialize" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "sub-b/target/singleton.properties" );
|
||||
assertEquals( "called", props.getProperty( "sub-a-provider" ) );
|
||||
assertEquals( "called", props.getProperty( "sub-a-consumer" ) );
|
||||
assertEquals( "called", props.getProperty( "sub-b-provider" ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -115,6 +115,18 @@ under the License.
|
|||
<version>${itPluginVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension-consumer</artifactId>
|
||||
<version>${itPluginVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension-provider</artifactId>
|
||||
<version>${itPluginVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension1</artifactId>
|
||||
|
|
|
@ -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>
|
||||
|
||||
<groupId>org.apache.maven.its.mng4381</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4381</name>
|
||||
<description>
|
||||
Test that extension plugins can contribute non-core components that can be accessed by other plugins in the same
|
||||
project and in projects with the same extension.
|
||||
</description>
|
||||
|
||||
<modules>
|
||||
<module>sub-a</module>
|
||||
<module>sub-b</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -0,0 +1,80 @@
|
|||
<?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>
|
||||
|
||||
<groupId>org.apache.maven.its.mng4381</groupId>
|
||||
<artifactId>sub-a</artifactId>
|
||||
<version>0.1</version>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4381</name>
|
||||
<description>
|
||||
Test that extension plugins can contribute non-core components that can be accessed by other plugins in the same
|
||||
project and in projects with the same extension.
|
||||
</description>
|
||||
|
||||
<build>
|
||||
<!--
|
||||
NOTE: We intentionally invoke the extension consumer first to check the singleton gets loaded from the
|
||||
proper class realm, i.e. the extension realm and not the plugin realm.
|
||||
-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension-consumer</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<key>sub-a-consumer</key>
|
||||
<value>called</value>
|
||||
<propertiesFile>target/singleton.properties</propertiesFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>update-singleton</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension-provider</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<key>sub-a-provider</key>
|
||||
<value>called</value>
|
||||
<propertiesFile>target/singleton.properties</propertiesFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>update-singleton</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,58 @@
|
|||
<?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>
|
||||
|
||||
<groupId>org.apache.maven.its.mng4381</groupId>
|
||||
<artifactId>sub-b</artifactId>
|
||||
<version>0.1</version>
|
||||
|
||||
<name>Maven Integration Test :: MNG-4381</name>
|
||||
<description>
|
||||
Test that extension plugins can contribute non-core components that can be accessed by other plugins in the same
|
||||
project and in projects with the same extension.
|
||||
</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-extension-provider</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<key>sub-b-provider</key>
|
||||
<value>called</value>
|
||||
<propertiesFile>target/singleton.properties</propertiesFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>update-singleton</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||
<?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</groupId>
|
||||
<artifactId>core-integration-testing</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>core-it-component</artifactId>
|
||||
|
||||
<name>Maven Integration Test Component</name>
|
||||
</project>
|
|
@ -0,0 +1,59 @@
|
|||
package org.apache.maven.coreit.component;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DefaultStatefulSingleton
|
||||
implements StatefulSingleton
|
||||
{
|
||||
|
||||
private Properties properties = new Properties();
|
||||
|
||||
public String getProperty( String key )
|
||||
{
|
||||
return properties.getProperty( key );
|
||||
}
|
||||
|
||||
public void setProperty( String key, String value )
|
||||
{
|
||||
properties.setProperty( key, value );
|
||||
}
|
||||
|
||||
public void saveProperties( File propertiesFile )
|
||||
throws IOException
|
||||
{
|
||||
propertiesFile.getParentFile().mkdirs();
|
||||
|
||||
FileOutputStream os = new FileOutputStream( propertiesFile );
|
||||
try
|
||||
{
|
||||
properties.store( os, "MAVEN-CORE-IT" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.apache.maven.coreit.component;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface StatefulSingleton
|
||||
{
|
||||
|
||||
void setProperty( String key, String value );
|
||||
|
||||
String getProperty( String key );
|
||||
|
||||
void saveProperties( File propertiesFile )
|
||||
throws IOException;
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.coreit.component.StatefulSingleton</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.coreit.component.DefaultStatefulSingleton</implementation>
|
||||
<instantiation-strategy>singleton</instantiation-strategy>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -0,0 +1,56 @@
|
|||
<?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>
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-it-plugins</artifactId>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maven-it-plugin-extension-consumer</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>Maven Integration Test Plugin :: Extension Consumer</name>
|
||||
<description>
|
||||
A test plugin that reuses a component provided by the extension-provider.
|
||||
</description>
|
||||
<inceptionYear>2009</inceptionYear>
|
||||
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>core-it-component</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,91 @@
|
|||
package org.apache.maven.plugin.coreit;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.maven.coreit.component.StatefulSingleton;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Updates the state of the singleton component and optionally dumps the updated state to a properties file.
|
||||
*
|
||||
* @goal update-singleton
|
||||
* @phase initialize
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class UpdateSingletonMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @parameter default-value="consumer"
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* @parameter default-value="passed"
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private StatefulSingleton singleton;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Instance: " + System.identityHashCode( singleton ) );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Class Loader: " + singleton.getClass().getClassLoader() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Setting property " + key + " = " + value );
|
||||
|
||||
singleton.setProperty( key, value );
|
||||
|
||||
if ( propertiesFile != null )
|
||||
{
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Saving properties to " + propertiesFile );
|
||||
|
||||
try
|
||||
{
|
||||
singleton.saveProperties( propertiesFile );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to save properties to " + propertiesFile, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?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>
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-it-plugins</artifactId>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maven-it-plugin-extension-provider</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>Maven Integration Test Plugin :: Extension Provider</name>
|
||||
<description>
|
||||
A test plugin that will be used as a build extension and should contribute a stateful singleton component for reuse
|
||||
by other plugins in the same project and other projects that use the same extension plugin.
|
||||
</description>
|
||||
<inceptionYear>2009</inceptionYear>
|
||||
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>core-it-component</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,91 @@
|
|||
package org.apache.maven.plugin.coreit;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.maven.coreit.component.StatefulSingleton;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Updates the state of the singleton component and optionally dumps the updated state to a properties file.
|
||||
*
|
||||
* @goal update-singleton
|
||||
* @phase initialize
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class UpdateSingletonMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @parameter default-value="provider"
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* @parameter default-value="passed"
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
private File propertiesFile;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private StatefulSingleton singleton;
|
||||
|
||||
/**
|
||||
* Runs this mojo.
|
||||
*
|
||||
* @throws MojoExecutionException If the output file could not be created.
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Instance: " + System.identityHashCode( singleton ) );
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Singleton Class Loader: " + singleton.getClass().getClassLoader() );
|
||||
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Setting property " + key + " = " + value );
|
||||
|
||||
singleton.setProperty( key, value );
|
||||
|
||||
if ( propertiesFile != null )
|
||||
{
|
||||
getLog().info( "[MAVEN-CORE-IT-LOG] Saving properties to " + propertiesFile );
|
||||
|
||||
try
|
||||
{
|
||||
singleton.saveProperties( propertiesFile );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to save properties to " + propertiesFile, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?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.
|
||||
-->
|
||||
|
||||
<extension>
|
||||
<!-- the packages to share with build plugins -->
|
||||
<exportedPackages>
|
||||
<exportedPackage>org.apache.maven.coreit.component</exportedPackage>
|
||||
</exportedPackages>
|
||||
|
||||
<!-- the ids of artifacts to exclude from the class realms of build plugins because the extension provides them -->
|
||||
<exportedArtifacts>
|
||||
<exportedArtifact>core-it-component</exportedArtifact>
|
||||
</exportedArtifacts>
|
||||
</extension>
|
|
@ -42,6 +42,8 @@ under the License.
|
|||
<module>maven-it-plugin-dependency-resolution</module>
|
||||
<module>maven-it-plugin-expression</module>
|
||||
<module>maven-it-plugin-error</module>
|
||||
<module>maven-it-plugin-extension-consumer</module>
|
||||
<module>maven-it-plugin-extension-provider</module>
|
||||
<module>maven-it-plugin-fork</module>
|
||||
<module>maven-it-plugin-invalid-descriptor</module>
|
||||
<module>maven-it-plugin-log-file</module>
|
||||
|
|
|
@ -36,6 +36,7 @@ under the License.
|
|||
|
||||
<modules>
|
||||
<module>core-it-plugins</module>
|
||||
<module>core-it-component</module>
|
||||
<module>core-it-wagon</module>
|
||||
<module>core-it-support-artifacts</module>
|
||||
<module>maven-it-helper</module>
|
||||
|
|
Loading…
Reference in New Issue