o Converted "unit" test into full-blown IT (e.g. to support repo managers)
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@700413 13f79535-47bb-0310-9956-ffa450edef68master
parent
ef52310e90
commit
ab8736ed17
|
|
@ -54,8 +54,8 @@
|
||||||
<property>
|
<property>
|
||||||
<name>java.vendor</name>
|
<name>java.vendor</name>
|
||||||
<value>Sun Microsystems Inc.</value>
|
<value>Sun Microsystems Inc.</value>
|
||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun</groupId>
|
<groupId>com.sun</groupId>
|
||||||
|
|
@ -63,106 +63,41 @@
|
||||||
<version>1.4.2</version>
|
<version>1.4.2</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${java.home}/../lib/tools.jar</systemPath>
|
<systemPath>${java.home}/../lib/tools.jar</systemPath>
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>unit-tests</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<name>maven.test.skip</name>
|
|
||||||
<value>!true</value>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.plugin-testing</groupId>
|
|
||||||
<artifactId>maven-plugin-testing-harness</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
|
||||||
<artifactId>plexus-container-default</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>run-its</id>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>maven-invoker-plugin</artifactId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<version>1.3</version>
|
||||||
<version>1.1</version>
|
<configuration>
|
||||||
<executions>
|
<debug>true</debug>
|
||||||
<execution>
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
<id>it-test</id>
|
<preBuildHookScript>setup.bsh</preBuildHookScript>
|
||||||
<phase>process-test-resources</phase>
|
<postBuildHookScript>verify.bsh</postBuildHookScript>
|
||||||
<goals>
|
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||||
<goal>run</goal>
|
<settingsFile>src/it/settings.xml</settingsFile>
|
||||||
</goals>
|
<addTestClassPath>true</addTestClassPath>
|
||||||
<configuration>
|
<goals>
|
||||||
<tasks>
|
<goal>clean</goal>
|
||||||
<copy todir="${project.build.testOutputDirectory}/unit" encoding="UTF-8" overwrite="true">
|
<goal>javadoc:javadoc</goal>
|
||||||
<fileset dir="${basedir}/src/test/resources/unit" includes="**/*.xml" />
|
</goals>
|
||||||
<filterset>
|
</configuration>
|
||||||
<filter token="project.version" value="${project.version}" />
|
|
||||||
</filterset>
|
|
||||||
</copy>
|
|
||||||
</tasks>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>it-test</id>
|
|
||||||
<phase>process-test-classes</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.build.finalName}-it</finalName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
|
||||||
<version>2.2</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>it-test</id>
|
<id>integration-test</id>
|
||||||
<phase>process-test-classes</phase>
|
|
||||||
<goals>
|
<goals>
|
||||||
<goal>install-file</goal>
|
<goal>install</goal>
|
||||||
|
<goal>run</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<file>${project.build.directory}/${project.build.finalName}-it.jar</file>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>${project.artifactId}</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<packaging>${project.packaging}</packaging>
|
|
||||||
<pomFile>${basedir}/pom.xml</pomFile>
|
|
||||||
<createChecksum>true</createChecksum>
|
|
||||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
|
||||||
<localRepositoryId>it-local-repo</localRepositoryId>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an
|
||||||
|
|
@ -24,8 +24,9 @@ under the License.
|
||||||
|
|
||||||
<groupId>org.apache.maven.tools.plugin.javadoc</groupId>
|
<groupId>org.apache.maven.tools.plugin.javadoc</groupId>
|
||||||
<artifactId>test</artifactId>
|
<artifactId>test</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<inceptionYear>2008</inceptionYear>
|
<inceptionYear>2008</inceptionYear>
|
||||||
<name>Test Mojo Tags</name>
|
<name>Test Mojo Tags</name>
|
||||||
|
|
||||||
|
|
@ -35,12 +36,6 @@ under the License.
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
@ -50,9 +45,7 @@ under the License.
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>2.3</version>
|
<version>2.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<project implementation="org.apache.maven.tools.plugin.javadoc.stubs.DefaultMavenProjectStub"/>
|
<outputDirectory>${basedir}/target/site/apidocs</outputDirectory>
|
||||||
<localRepository>${localRepository}</localRepository>
|
|
||||||
<outputDirectory>${basedir}/target/test/unit/javadoc/target/site/apidocs</outputDirectory>
|
|
||||||
|
|
||||||
<debug>true</debug>
|
<debug>true</debug>
|
||||||
<show>private</show>
|
<show>private</show>
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.*;
|
||||||
|
|
||||||
|
import org.apache.maven.tools.plugin.javadoc.*;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.util.*;
|
||||||
|
|
||||||
|
setAccessibility( true );
|
||||||
|
|
||||||
|
File docsDir = new File( basedir, "target/site/apidocs" );
|
||||||
|
System.out.println( "Checking for existence of: " + docsDir );
|
||||||
|
if ( !docsDir.exists() )
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException( docsDir + " was not created" );
|
||||||
|
}
|
||||||
|
|
||||||
|
File docFile = new File( docsDir, "org/apache/maven/plugin/my/MyMojo.html" );
|
||||||
|
System.out.println( "Checking for existence of: " + docFile );
|
||||||
|
if ( !docFile.isFile() )
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException( docFile + " was not created" );
|
||||||
|
}
|
||||||
|
|
||||||
|
String html = FileUtils.fileRead( docFile, "ISO-8859-1").replaceAll( "(\r\n)|(\r)|(\n)", "" );
|
||||||
|
|
||||||
|
System.out.println( "Checking for documentation of mojo type" );
|
||||||
|
String mojoType = "<dl><dt><b>" + MojoAggregatorTypeTaglet.HEADER + "</b></dt><dd></dd><dt><b>"
|
||||||
|
+ MojoConfiguratorTypeTaglet.HEADER + ":</b></dt><dd>roleHint</dd><dt><b>" + MojoExecuteTypeTaglet.HEADER
|
||||||
|
+ ":</b></dt><dd><dl><dt><b>phase:</b></dt><dd>validate</dd>"
|
||||||
|
+ "<dt><b>lifecycle:</b></dt><dd>default</dd></dl></dd><dt><b>" + MojoExecutionStrategyTypeTaglet.HEADER
|
||||||
|
+ ":</b></dt><dd>always</dd>" + "<dt><b>" + MojoGoalTypeTaglet.HEADER + ":</b></dt><dd>touch</dd>"
|
||||||
|
+ "<dt><b>" + MojoInheritByDefaultTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
||||||
|
+ MojoInstantiationStrategyTypeTaglet.HEADER + ":</b></dt><dd>per-lookup</dd><dt><b>"
|
||||||
|
+ MojoPhaseTypeTaglet.HEADER + ":</b></dt><dd>phaseName</dd><dt><b>"
|
||||||
|
+ MojoRequiresDependencyResolutionTypeTaglet.HEADER + ":</b></dt><dd>compile</dd><dt><b>"
|
||||||
|
+ MojoRequiresDirectInvocationTypeTaglet.HEADER + ":</b></dt><dd>false</dd><dt><b>"
|
||||||
|
+ MojoRequiresOnLineTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
||||||
|
+ MojoRequiresProjectTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
||||||
|
+ MojoRequiresReportsTypeTaglet.HEADER + ":</b></dt><dd>false</dd></dl>";
|
||||||
|
if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoType ).toLowerCase( Locale.ENGLISH ) ) < 0 )
|
||||||
|
{
|
||||||
|
throw new IllegalStateException( "Mojo type doc wrong" );
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println( "Checking for documentation of mojo fields" );
|
||||||
|
String mojoField = "<dl><dt><b>" + MojoParameterFieldTaglet.HEADER
|
||||||
|
+ ":</b></dt><dd><dl><dt><b>default-value:</b></dt>"
|
||||||
|
+ "<dd>value</dd><dt><b>expression:</b></dt><dd>${project.build.directory}</dd><dt><b>alias:</b>"
|
||||||
|
+ "</dt><dd>myAlias</dd></dl></dd><dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd></dd><dt><b>"
|
||||||
|
+ MojoRequiredFieldTaglet.HEADER + "</b></dt><dd>" + "</dd></dl>";
|
||||||
|
if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoField ).toLowerCase( Locale.ENGLISH ) ) < 0 )
|
||||||
|
{
|
||||||
|
throw new IllegalStateException( "Mojo field doc wrong" );
|
||||||
|
}
|
||||||
|
|
||||||
|
mojoField = "<dl><dt><b>" + MojoComponentFieldTaglet.HEADER + ":</b></dt><dd><dl><dt><b>role:</b>"
|
||||||
|
+ "</dt><dd>org.apacha.maven.MyComponent</dd><dt><b>roleHint:</b></dt><dd>default</dd></dl></dd>"
|
||||||
|
+ "<dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd></dd><dt><b>" + MojoRequiredFieldTaglet.HEADER
|
||||||
|
+ "</b></dt><dd>" + "</dd></dl>";
|
||||||
|
if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoField ).toLowerCase( Locale.ENGLISH ) ) < 0 )
|
||||||
|
{
|
||||||
|
throw new IllegalStateException( "Mojo field doc wrong" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<settings>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>it-repo</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>local.central</id>
|
||||||
|
<url>@localRepositoryUrl@</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>apache.snapshots</id>
|
||||||
|
<name>Apache Snapshot Repository</name>
|
||||||
|
<url>http://people.apache.org/repo/m2-snapshot-repository</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>local.central</id>
|
||||||
|
<url>@localRepositoryUrl@</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</settings>
|
||||||
|
|
@ -1,165 +0,0 @@
|
||||||
package org.apache.maven.tools.plugin.javadoc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
|
||||||
import org.apache.maven.plugin.javadoc.JavadocReport;
|
|
||||||
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
|
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the taglets by running Maven Javadoc Plugin.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class JavadocReportTest
|
|
||||||
extends AbstractMojoTestCase
|
|
||||||
{
|
|
||||||
private static final String LINE_SEPARATOR = "";
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
protected void setUp()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
// required for mojo lookups to work
|
|
||||||
super.setUp();
|
|
||||||
createTestRepo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
protected void tearDown()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create test repository in target directory.
|
|
||||||
*/
|
|
||||||
private void createTestRepo()
|
|
||||||
{
|
|
||||||
File f = new File( getBasedir(), "target/local-repo/" );
|
|
||||||
f.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method that reads the contents of the specified file object into a string with a
|
|
||||||
* <code>""</code> as line separator.
|
|
||||||
*
|
|
||||||
* @see #LINE_SEPARATOR
|
|
||||||
* @param file the file to be read
|
|
||||||
* @return a String object that contains the contents of the file
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static String readFile( File file )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
String str = "", strTmp = "";
|
|
||||||
BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "ISO-8859-1" ) );
|
|
||||||
|
|
||||||
while ( ( strTmp = in.readLine() ) != null )
|
|
||||||
{
|
|
||||||
str = str + LINE_SEPARATOR + strTmp;
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the default javadoc renderer using the Maven plugin
|
|
||||||
* <code>org.apache.maven.plugins:maven-javadoc-plugin:2.3</code>
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void testMojoTaglets()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
File testPom = new File( getBasedir(), "target/test-classes/unit/javadoc/javadoc-plugin-config.xml" );
|
|
||||||
PlexusConfiguration pluginConfiguration = extractPluginConfiguration( "maven-javadoc-plugin", testPom );
|
|
||||||
|
|
||||||
JavadocReport mojo = (JavadocReport) lookupMojo( "org.apache.maven.plugins", "maven-javadoc-plugin", "2.3",
|
|
||||||
"javadoc", pluginConfiguration );
|
|
||||||
|
|
||||||
// Don't know why we need to specify that
|
|
||||||
ArtifactRepository remoteRepositories = new DefaultArtifactRepository( "central",
|
|
||||||
"http://repo1.maven.org/maven2",
|
|
||||||
new DefaultRepositoryLayout() );
|
|
||||||
setVariableValueToObject( mojo, "remoteRepositories", Collections.singletonList( remoteRepositories ) );
|
|
||||||
|
|
||||||
ArtifactRepository localRepository = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
|
|
||||||
ArtifactResolver resolver = (ArtifactResolver) getVariableValueFromObject( mojo, "resolver" );
|
|
||||||
ArtifactFactory factory = (ArtifactFactory) getVariableValueFromObject( mojo, "factory" );
|
|
||||||
Artifact artifact = factory.createArtifact( "org.apache.maven", "maven-plugin-api", "2.0", "compile", "jar" );
|
|
||||||
resolver.resolve( artifact, Collections.singletonList( remoteRepositories ), localRepository );
|
|
||||||
|
|
||||||
mojo.execute();
|
|
||||||
|
|
||||||
File generatedFile = new File( getBasedir(),
|
|
||||||
"target/test/unit/javadoc/target/site/apidocs/org/apache/maven/plugin/my/MyMojo.html" );
|
|
||||||
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
|
|
||||||
|
|
||||||
String str = readFile( generatedFile );
|
|
||||||
|
|
||||||
// Verify mojo type
|
|
||||||
String mojoType = "<dl><dt><b>" + MojoAggregatorTypeTaglet.HEADER + "</b></dt><dd></dd><dt><b>"
|
|
||||||
+ MojoConfiguratorTypeTaglet.HEADER + ":</b></dt><dd>roleHint</dd><dt><b>" + MojoExecuteTypeTaglet.HEADER
|
|
||||||
+ ":</b></dt><dd><dl><dt><b>phase:</b></dt><dd>validate</dd>"
|
|
||||||
+ "<dt><b>lifecycle:</b></dt><dd>default</dd></dl></dd><dt><b>" + MojoExecutionStrategyTypeTaglet.HEADER
|
|
||||||
+ ":</b></dt><dd>always</dd>" + "<dt><b>" + MojoGoalTypeTaglet.HEADER + ":</b></dt><dd>touch</dd>"
|
|
||||||
+ "<dt><b>" + MojoInheritByDefaultTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
|
||||||
+ MojoInstantiationStrategyTypeTaglet.HEADER + ":</b></dt><dd>per-lookup</dd><dt><b>"
|
|
||||||
+ MojoPhaseTypeTaglet.HEADER + ":</b></dt><dd>phaseName</dd><dt><b>"
|
|
||||||
+ MojoRequiresDependencyResolutionTypeTaglet.HEADER + ":</b></dt><dd>compile</dd><dt><b>"
|
|
||||||
+ MojoRequiresDirectInvocationTypeTaglet.HEADER + ":</b></dt><dd>false</dd><dt><b>"
|
|
||||||
+ MojoRequiresOnLineTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
|
||||||
+ MojoRequiresProjectTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>"
|
|
||||||
+ MojoRequiresReportsTypeTaglet.HEADER + ":</b></dt><dd>false</dd></dl>";
|
|
||||||
assertTrue( str.toLowerCase().indexOf( ( mojoType ).toLowerCase() ) != -1 );
|
|
||||||
|
|
||||||
// Verify mojo fields
|
|
||||||
String mojoField = "<dl><dt><b>" + MojoParameterFieldTaglet.HEADER
|
|
||||||
+ ":</b></dt><dd><dl><dt><b>default-value:</b></dt>"
|
|
||||||
+ "<dd>value</dd><dt><b>expression:</b></dt><dd>${project.build.directory}</dd><dt><b>alias:</b>"
|
|
||||||
+ "</dt><dd>myAlias</dd></dl></dd><dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd></dd><dt><b>"
|
|
||||||
+ MojoRequiredFieldTaglet.HEADER + "</b></dt><dd>" + "</dd></dl>";
|
|
||||||
assertTrue( str.toLowerCase().indexOf( ( mojoField ).toLowerCase() ) != -1 );
|
|
||||||
|
|
||||||
mojoField = "<dl><dt><b>" + MojoComponentFieldTaglet.HEADER + ":</b></dt><dd><dl><dt><b>role:</b>"
|
|
||||||
+ "</dt><dd>org.apacha.maven.MyComponent</dd><dt><b>roleHint:</b></dt><dd>default</dd></dl></dd>"
|
|
||||||
+ "<dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd></dd><dt><b>" + MojoRequiredFieldTaglet.HEADER
|
|
||||||
+ "</b></dt><dd>" + "</dd></dl>";
|
|
||||||
assertTrue( str.toLowerCase().indexOf( ( mojoField ).toLowerCase() ) != -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
package org.apache.maven.tools.plugin.javadoc.stubs;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
|
||||||
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
import org.apache.maven.model.Build;
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.Resource;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class DefaultMavenProjectStub
|
|
||||||
extends MavenProjectStub
|
|
||||||
{
|
|
||||||
private Build build;
|
|
||||||
|
|
||||||
public DefaultMavenProjectStub()
|
|
||||||
{
|
|
||||||
MavenXpp3Reader pomReader = new MavenXpp3Reader();
|
|
||||||
Model model = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File pomFile = new File( getBasedir(), "javadoc-plugin-config.xml" );
|
|
||||||
model = pomReader.read( ReaderFactory.newXmlReader( pomFile ) );
|
|
||||||
setModel( model );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
throw new RuntimeException( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
setGroupId( model.getGroupId() );
|
|
||||||
setArtifactId( model.getArtifactId() );
|
|
||||||
setVersion( model.getVersion() );
|
|
||||||
setName( model.getName() );
|
|
||||||
setUrl( model.getUrl() );
|
|
||||||
setPackaging( model.getPackaging() );
|
|
||||||
|
|
||||||
Build build = new Build();
|
|
||||||
|
|
||||||
build.setFinalName( model.getArtifactId() );
|
|
||||||
build.setSourceDirectory( getBasedir() + "/src/main/java" );
|
|
||||||
|
|
||||||
Resource resource = new Resource();
|
|
||||||
resource.setDirectory( getBasedir() + "/src/main/resources" );
|
|
||||||
build.setResources( Collections.singletonList( resource ) );
|
|
||||||
build.setDirectory( super.getBasedir() + "/target/test/unit/javadoc/target" );
|
|
||||||
build.setOutputDirectory( super.getBasedir() + "/target/test/unit/javadoc/target/classes" );
|
|
||||||
|
|
||||||
build.setTestSourceDirectory( getBasedir() + "/src/test/java" );
|
|
||||||
resource = new Resource();
|
|
||||||
resource.setDirectory( getBasedir() + "/src/test/resources" );
|
|
||||||
build.setTestResources( Collections.singletonList( resource ) );
|
|
||||||
build.setTestOutputDirectory( super.getBasedir() + "/target/test/unit/javadoc/target/test-classes" );
|
|
||||||
|
|
||||||
setBuild( build );
|
|
||||||
|
|
||||||
List compileSourceRoots = new ArrayList();
|
|
||||||
compileSourceRoots.add( getBasedir() + "/src/main/java" );
|
|
||||||
setCompileSourceRoots( compileSourceRoots );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public Build getBuild()
|
|
||||||
{
|
|
||||||
return build;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public void setBuild( Build build )
|
|
||||||
{
|
|
||||||
this.build = build;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public File getBasedir()
|
|
||||||
{
|
|
||||||
return new File( super.getBasedir() + "/src/test/resources/unit/javadoc" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public List getRemoteArtifactRepositories()
|
|
||||||
{
|
|
||||||
ArtifactRepository repository = new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
|
|
||||||
new DefaultRepositoryLayout() );
|
|
||||||
|
|
||||||
return Collections.singletonList( repository );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public List getCompileArtifacts()
|
|
||||||
{
|
|
||||||
Artifact art = new DefaultArtifact( "org.apache.maven", "maven-plugin-api", VersionRange.createFromVersion( "2.0" ),
|
|
||||||
Artifact.SCOPE_COMPILE, "jar", null, new DefaultArtifactHandler( "jar" ), false );
|
|
||||||
art.setFile( new File( super.getBasedir() + "/target/local-repo/org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar" ) );
|
|
||||||
return Collections.singletonList( art );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue