diff --git a/its/core-integration-testing-plugins/maven-it-plugin-configuration/pom.xml b/its/core-integration-testing-plugins/maven-it-plugin-configuration/pom.xml new file mode 100644 index 0000000000..ffaa0417d7 --- /dev/null +++ b/its/core-integration-testing-plugins/maven-it-plugin-configuration/pom.xml @@ -0,0 +1,54 @@ + + + + + + + maven-it-plugins + org.apache.maven.its.plugins + 1-SNAPSHOT + + 4.0.0 + maven-it-plugin-configuration + maven-plugin + Maven Integration Test Plugin :: Configuration + + A plugin that allows any configuration in the form of a DOM which allows inspection after + configuration processing inside Maven's core. + + 1.0-SNAPSHOT + 2001 + + + org.apache.maven + maven-plugin-api + 2.0 + + + org.codehaus.plexus + plexus-utils + 1.4 + + + org.codehaus.plexus + plexus-container-default + 1.0-alpha-9 + + + + diff --git a/its/core-integration-testing-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/its/core-integration-testing-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java new file mode 100644 index 0000000000..87832671c1 --- /dev/null +++ b/its/core-integration-testing-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java @@ -0,0 +1,72 @@ +package org.apache.maven.plugin.coreit; + +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +//MAPI: This is a canidate for the internal state dump (ISD). This is probably similar to what is in the help plugin. + +/** + * @goal config + * @phase generate-resources + * @description Goal produces a raw string with contains full interpolated plugin configurations. + */ +public class CoreItMojo + extends AbstractMojo +{ + /** @parameter expression="${dom}" */ + private PlexusConfiguration dom; + + /** @parameter expression="${outputDirectory}" default-value="${project.build.directory}" */ + private File outputDirectory; + + /** @parameter expression="${fileName}" default-value="plugin-configuration.txt" */ + private String fileName; + + public void execute() + throws MojoExecutionException + { + try + { + File file = new File( outputDirectory, fileName ); + + if ( !outputDirectory.exists() ) + { + outputDirectory.mkdirs(); + } + + Writer writer = new FileWriter( file ); + + writer.write( dom.toString() ); + + writer.close(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error writing out plugin configuration.", e ); + } + } +}