add an it test.
add a flag to prevent error when using only annotations: no descriptors found extraction is bind to generate-sources in maven core for maven-plugin packaging so at this stage no classes available for scanning annotations git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/branches/MPLUGIN-189@1333847 13f79535-47bb-0310-9956-ffa450edef68master
parent
5e3bc49bf1
commit
5da55eb1be
|
|
@ -62,6 +62,7 @@
|
|||
<mavenVersion>2.0.6</mavenVersion>
|
||||
<doxiaVersion>1.2</doxiaVersion>
|
||||
<doxia-sitetoolsVersion>1.2</doxia-sitetoolsVersion>
|
||||
<it.debug>true</it.debug>
|
||||
</properties>
|
||||
|
||||
<!-- Copy from project up -->
|
||||
|
|
@ -292,6 +293,7 @@
|
|||
<configuration>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<debug>${it.debug}</debug>
|
||||
<filterProperties>
|
||||
<sitePluginVersion>3.0</sitePluginVersion>
|
||||
</filterProperties>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
invoker.goals.1 = install
|
||||
invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0:it0014
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?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.basic-java-annotations</groupId>
|
||||
<artifactId>maven-it-basic-java-annotations</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>Maven Integration Test :: basic-java-annotations</name>
|
||||
<description>
|
||||
Test plugin-plugin, which tests maven-plugin-tools-api and
|
||||
maven-plugin-tools-java. This will generate a plugin descriptor from
|
||||
java-based mojo sources, install the plugin, and then use it.
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>@project.version@</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>descriptor</goal>
|
||||
</goals>
|
||||
<id>mojo-descriptor</id>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
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 org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Touches a test file.
|
||||
*
|
||||
*/
|
||||
@Mojo( name = "it0014")
|
||||
public class CoreIt0014Mojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
@Parameter(expression ="${project.build.directory}", required = true)
|
||||
private String outputDirectory;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
getLog().info( "outputDirectory = " + outputDirectory );
|
||||
|
||||
File f = new File( outputDirectory );
|
||||
|
||||
if ( !f.exists() )
|
||||
{
|
||||
f.mkdirs();
|
||||
}
|
||||
|
||||
File touch = new File( f, "touch.txt" );
|
||||
|
||||
try
|
||||
{
|
||||
touch.createNewFile();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error writing verification file.", e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
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 org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Component;
|
||||
import org.apache.maven.plugins.annotations.Execute;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Touches a test file.
|
||||
*
|
||||
* @since 1.2
|
||||
* @deprecated Don't use!
|
||||
*/
|
||||
@Mojo( name = "first", requiresDependencyResolution = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST )
|
||||
@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
|
||||
public class FirstMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
@Parameter( defaultValue = "${basedir}", readonly = true )
|
||||
private File basedir;
|
||||
|
||||
@Parameter( expression = "${first.touchFile}", defaultValue = "${project.build.directory}/touch.txt",
|
||||
required = true )
|
||||
private File touchFile;
|
||||
|
||||
/**
|
||||
* @since 0.1
|
||||
* @deprecated As of 0.2
|
||||
*/
|
||||
@Parameter( alias = "alias" )
|
||||
private String aliasedParam;
|
||||
|
||||
@Component( role = "org.apache.maven.project.MavenProjectHelper", roleHint = "test" )
|
||||
private Object projectHelper;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
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 org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
|
||||
/**
|
||||
* Does nothing special.
|
||||
*
|
||||
*/
|
||||
@Mojo( name = "second",requiresDependencyCollection = "compile", threadSafe = true)
|
||||
public class SecondMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
public void execute()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
File touchFile = new File( basedir, "target/touch.txt" )
|
||||
assert touchFile.isFile()
|
||||
|
||||
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
|
||||
assert descriptorFile.isFile()
|
||||
|
||||
def pluginDescriptor = new XmlParser().parse( descriptorFile );
|
||||
|
||||
def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first"}[0]
|
||||
|
||||
assert mojo.goal.text() == 'first'
|
||||
assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
|
||||
assert mojo.language.text() == 'java'
|
||||
assert mojo.description.text() == 'Touches a test file.'
|
||||
assert mojo.deprecated.text() == "Don't use!"
|
||||
assert mojo.requiresDependencyResolution.text() == 'test'
|
||||
assert mojo.requiresDependencyCollection.text() == ''
|
||||
assert mojo.requiresProject.text() == 'true'
|
||||
assert mojo.requiresOnline.text() == 'false'
|
||||
assert mojo.requiresDirectInvocation.text() == 'false'
|
||||
assert mojo.aggregator.text() == 'false'
|
||||
assert mojo.threadSafe.text() == 'false'
|
||||
assert mojo.phase.text() == 'integration-test'
|
||||
assert mojo.executePhase.text() == 'generate-sources'
|
||||
assert mojo.executeLifecycle.text() == 'cobertura'
|
||||
|
||||
assert mojo.configuration.basedir[0].text() == ''
|
||||
assert mojo.configuration.basedir[0].'@implementation' == 'java.io.File'
|
||||
assert mojo.configuration.basedir[0].'@default-value' == '${basedir}'
|
||||
|
||||
assert mojo.configuration.touchFile[0].text() == '${first.touchFile}'
|
||||
assert mojo.configuration.touchFile[0].'@implementation' == 'java.io.File'
|
||||
assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.directory}/touch.txt'
|
||||
|
||||
assert mojo.requirements.requirement.size() == 1
|
||||
|
||||
assert mojo.requirements.requirement[0].role.text() == 'org.apache.maven.project.MavenProjectHelper'
|
||||
assert mojo.requirements.requirement[0].'role-hint'.text() == 'test'
|
||||
assert mojo.requirements.requirement[0].'field-name'.text() == 'projectHelper'
|
||||
|
||||
assert mojo.parameters.parameter.size() == 3
|
||||
|
||||
assert mojo.parameters.parameter[0].name.text() == 'aliasedParam'
|
||||
assert mojo.parameters.parameter[0].alias.text() == 'alias'
|
||||
assert mojo.parameters.parameter[0].type.text() == 'java.lang.String'
|
||||
assert mojo.parameters.parameter[0].deprecated.text() == 'As of 0.2'
|
||||
assert mojo.parameters.parameter[0].required.text() == 'false'
|
||||
assert mojo.parameters.parameter[0].editable.text() == 'true'
|
||||
assert mojo.parameters.parameter[0].description.text() == ''
|
||||
|
||||
assert mojo.parameters.parameter[1].name.text() == 'basedir'
|
||||
assert mojo.parameters.parameter[1].alias.isEmpty()
|
||||
assert mojo.parameters.parameter[1].type.text() == 'java.io.File'
|
||||
assert mojo.parameters.parameter[1].deprecated.isEmpty()
|
||||
assert mojo.parameters.parameter[1].required.text() == 'false'
|
||||
assert mojo.parameters.parameter[1].editable.text() == 'false'
|
||||
assert mojo.parameters.parameter[1].description.text() == 'Project directory.'
|
||||
|
||||
assert mojo.parameters.parameter[2].name.text() == 'touchFile'
|
||||
assert mojo.parameters.parameter[2].alias.isEmpty()
|
||||
assert mojo.parameters.parameter[2].type.text() == 'java.io.File'
|
||||
assert mojo.parameters.parameter[2].deprecated.isEmpty()
|
||||
assert mojo.parameters.parameter[2].required.text() == 'true'
|
||||
assert mojo.parameters.parameter[2].editable.text() == 'true'
|
||||
assert mojo.parameters.parameter[2].description.text() == ''
|
||||
|
||||
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]
|
||||
|
||||
assert mojo.requiresDependencyCollection.text() == 'compile'
|
||||
assert mojo.threadSafe.text() == 'true'
|
||||
|
||||
return true;
|
||||
|
|
@ -79,6 +79,15 @@ public abstract class AbstractGeneratorMojo
|
|||
*/
|
||||
protected String goalPrefix;
|
||||
|
||||
/**
|
||||
* By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
|
||||
* descriptor generator mojo is bound to generate-resources phase.
|
||||
* But for annotations, the compiled classes are needed, so skip error
|
||||
* @parameter expression="${maven.plugin.skipErrorNoDescriptorsFound}" default-value="false"
|
||||
* @since 3.0
|
||||
*/
|
||||
protected boolean skipErrorNoDescriptorsFound;
|
||||
|
||||
/**
|
||||
* The role names of mojo extractors to use.
|
||||
* <p/>
|
||||
|
|
@ -193,6 +202,7 @@ public abstract class AbstractGeneratorMojo
|
|||
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
|
||||
request.setEncoding( encoding );
|
||||
request.setSkipErrorNoDescriptorsFound( skipErrorNoDescriptorsFound );
|
||||
|
||||
mojoScanner.populatePluginDescriptor( request );
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import java.io.File;
|
|||
* @version $Id$
|
||||
* @since 2.0
|
||||
* @goal descriptor
|
||||
* @phase generate-resources
|
||||
* @phase process-classes
|
||||
* @requiresDependencyResolution runtime
|
||||
*/
|
||||
public class DescriptorGeneratorMojo
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
|
|||
* @version $Id$
|
||||
* @since 2.4
|
||||
* @goal helpmojo
|
||||
* @phase generate-sources
|
||||
* @phase process-classes
|
||||
*/
|
||||
public class HelpGeneratorMojo
|
||||
extends AbstractGeneratorMojo
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
List<MojoAnnotatedClass> mojoAnnotatedClasses =
|
||||
mojoAnnotationsScanner.scan( mojoAnnotationsScannerRequest );
|
||||
|
||||
return toMojoDescriptors( mojoAnnotatedClasses );
|
||||
return toMojoDescriptors( mojoAnnotatedClasses, request );
|
||||
}
|
||||
catch ( DependencyResolutionRequiredException e )
|
||||
{
|
||||
|
|
@ -101,7 +101,8 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
return files;
|
||||
}
|
||||
|
||||
private List<MojoDescriptor> toMojoDescriptors( List<MojoAnnotatedClass> mojoAnnotatedClasses )
|
||||
private List<MojoDescriptor> toMojoDescriptors( List<MojoAnnotatedClass> mojoAnnotatedClasses,
|
||||
PluginToolsRequest request )
|
||||
throws DuplicateParameterException
|
||||
{
|
||||
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
|
||||
|
|
@ -109,17 +110,25 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
{
|
||||
MojoDescriptor mojoDescriptor = new MojoDescriptor();
|
||||
|
||||
//mojoDescriptor.setRole( mojoAnnotatedClass.getClassName() );
|
||||
//mojoDescriptor.setRoleHint( "default" );
|
||||
mojoDescriptor.setImplementation( mojoAnnotatedClass.getClassName() );
|
||||
|
||||
MojoAnnotationContent mojo = mojoAnnotatedClass.getMojo();
|
||||
ExecuteAnnotationContent execute = mojoAnnotatedClass.getExecute();
|
||||
|
||||
mojoDescriptor.setAggregator( mojo.aggregator() );
|
||||
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
|
||||
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
|
||||
mojoDescriptor.setDeprecated( mojo.getDeprecated() );
|
||||
|
||||
mojoDescriptor.setExecuteGoal( execute.goal() );
|
||||
mojoDescriptor.setExecuteLifecycle( execute.lifecycle() );
|
||||
mojoDescriptor.setExecutePhase( execute.phase().id() );
|
||||
ExecuteAnnotationContent execute = mojoAnnotatedClass.getExecute();
|
||||
|
||||
if ( execute != null )
|
||||
{
|
||||
mojoDescriptor.setExecuteGoal( execute.goal() );
|
||||
mojoDescriptor.setExecuteLifecycle( execute.lifecycle() );
|
||||
mojoDescriptor.setExecutePhase( execute.phase().id() );
|
||||
}
|
||||
|
||||
mojoDescriptor.setExecutionStrategy( mojo.executionStrategy() );
|
||||
// FIXME olamy wtf ?
|
||||
|
|
@ -157,6 +166,8 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
mojoDescriptor.addParameter( parameter );
|
||||
}
|
||||
|
||||
mojoDescriptor.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
|
||||
mojoDescriptors.add( mojoDescriptor );
|
||||
}
|
||||
return mojoDescriptors;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class ComponentAnnotationContent
|
|||
|
||||
public String role()
|
||||
{
|
||||
return role;
|
||||
return role == null ? "" : role;
|
||||
}
|
||||
|
||||
public void role( String role )
|
||||
|
|
@ -59,7 +59,7 @@ public class ComponentAnnotationContent
|
|||
|
||||
public String roleHint()
|
||||
{
|
||||
return roleHint;
|
||||
return roleHint == null ? "" : roleHint;
|
||||
}
|
||||
|
||||
public void roleHint( String roleHint )
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public class DefaultPluginToolsRequest
|
|||
|
||||
private String encoding = DEFAULT_ENCODING;
|
||||
|
||||
private boolean skipErrorNoDescriptorsFound;
|
||||
|
||||
public DefaultPluginToolsRequest( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
this.project = project;
|
||||
|
|
@ -109,4 +111,20 @@ public class DefaultPluginToolsRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isSkipErrorNoDescriptorsFound()
|
||||
{
|
||||
return skipErrorNoDescriptorsFound;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PluginToolsRequest setSkipErrorNoDescriptorsFound( boolean skipErrorNoDescriptorsFound )
|
||||
{
|
||||
this.skipErrorNoDescriptorsFound = skipErrorNoDescriptorsFound;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,23 +26,23 @@ import org.apache.maven.project.MavenProject;
|
|||
/**
|
||||
* Request that encapsulates all information relevant to the process of extracting {@link MojoDescriptor}
|
||||
* instances from metadata for a certain type of mojo.
|
||||
*
|
||||
*
|
||||
* @author jdcasey
|
||||
* @since 2.5
|
||||
*/
|
||||
public interface PluginToolsRequest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Return the current {@link MavenProject} instance in use.
|
||||
*/
|
||||
MavenProject getProject();
|
||||
|
||||
|
||||
/**
|
||||
* @see PluginToolsRequest#getProject()
|
||||
*/
|
||||
PluginToolsRequest setProject( MavenProject project );
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@link PluginDescriptor} currently being populated as part of the build of the
|
||||
* current plugin project.
|
||||
|
|
@ -53,21 +53,37 @@ public interface PluginToolsRequest
|
|||
* @see PluginToolsRequest#getPluginDescriptor()
|
||||
*/
|
||||
PluginToolsRequest setPluginDescriptor( PluginDescriptor pluginDescriptor );
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file encoding of the source files.
|
||||
*
|
||||
*
|
||||
* @return The file encoding of the source files, never <code>null</code>.
|
||||
*/
|
||||
String getEncoding();
|
||||
|
||||
/**
|
||||
* Sets the file encoding of the source files.
|
||||
*
|
||||
*
|
||||
* @param encoding The file encoding of the source files, may be empty or <code>null</code> to use the platform's
|
||||
* default encoding.
|
||||
* default encoding.
|
||||
* @return This request.
|
||||
*/
|
||||
PluginToolsRequest setEncoding( String encoding );
|
||||
|
||||
/**
|
||||
* By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
|
||||
* descriptor generator mojo is bound to generate-resources phase.
|
||||
* But for annotations, the compiled classes are needed, so skip error
|
||||
* @since 3.0
|
||||
*/
|
||||
PluginToolsRequest setSkipErrorNoDescriptorsFound( boolean skipErrorNoDescriptorsFound );
|
||||
|
||||
/**
|
||||
* @since 3.0
|
||||
* @return
|
||||
*/
|
||||
boolean isSkipErrorNoDescriptorsFound();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ package org.apache.maven.tools.plugin.scanner;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
|
|
@ -36,6 +31,11 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
|
|
@ -71,14 +71,18 @@ public class DefaultMojoScanner
|
|||
// nop
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void populatePluginDescriptor( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
|
|
@ -103,7 +107,7 @@ public class DefaultMojoScanner
|
|||
List<MojoDescriptor> extractorDescriptors = extractor.execute( request );
|
||||
|
||||
logger.info( "Mojo extractor for language: " + language + " found " + extractorDescriptors.size()
|
||||
+ " mojo descriptors." );
|
||||
+ " mojo descriptors." );
|
||||
numMojoDescriptors += extractorDescriptors.size();
|
||||
|
||||
for ( MojoDescriptor descriptor : extractorDescriptors )
|
||||
|
|
@ -116,10 +120,11 @@ public class DefaultMojoScanner
|
|||
}
|
||||
}
|
||||
|
||||
if ( numMojoDescriptors == 0 )
|
||||
if ( numMojoDescriptors == 0 && !request.isSkipErrorNoDescriptorsFound() )
|
||||
{
|
||||
throw new InvalidPluginDescriptorException( "No mojo definitions were found for plugin: "
|
||||
+ request.getPluginDescriptor().getPluginLookupKey() + "." );
|
||||
throw new InvalidPluginDescriptorException(
|
||||
"No mojo definitions were found for plugin: " + request.getPluginDescriptor().getPluginLookupKey()
|
||||
+ "." );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue