[MPLUGIN-189] add a datamodel parent class with description,since and deprecated which need to parse with qdox
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/branches/MPLUGIN-189@1333839 13f79535-47bb-0310-9956-ffa450edef68master
parent
7575a48961
commit
e2512e1859
|
|
@ -25,10 +25,16 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotatedClass;
|
||||
import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScanner;
|
||||
import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScannerRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -39,6 +45,11 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
implements MojoDescriptorExtractor
|
||||
{
|
||||
|
||||
/**
|
||||
* @requirement
|
||||
*/
|
||||
MojoAnnotationsScanner mojoAnnotationsScanner;
|
||||
|
||||
public List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
|
|
@ -50,12 +61,50 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
|||
{
|
||||
try
|
||||
{
|
||||
List<String> classpathElements = request.getProject().getCompileClasspathElements();
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
MojoAnnotationsScannerRequest mojoAnnotationsScannerRequest = new MojoAnnotationsScannerRequest();
|
||||
List<File> classesDirectories = toFiles( request.getProject().getCompileClasspathElements() );
|
||||
mojoAnnotationsScannerRequest.setClassesDirectories( classesDirectories );
|
||||
|
||||
List<MojoAnnotatedClass> mojoAnnotatedClasses =
|
||||
mojoAnnotationsScanner.scan( mojoAnnotationsScannerRequest );
|
||||
|
||||
return toMojoDescriptors( mojoAnnotatedClasses );
|
||||
}
|
||||
catch ( DependencyResolutionRequiredException e )
|
||||
{
|
||||
throw new ExtractionException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> toFiles( List<String> directories )
|
||||
{
|
||||
if ( directories == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<File> files = new ArrayList<File>( directories.size() );
|
||||
for ( String directory : directories )
|
||||
{
|
||||
files.add( new File( directory ) );
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
private List<MojoDescriptor> toMojoDescriptors( List<MojoAnnotatedClass> mojoAnnotatedClasses )
|
||||
{
|
||||
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
|
||||
for ( MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses )
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = new MojoDescriptor();
|
||||
|
||||
Mojo mojo = mojoAnnotatedClass.getMojo();
|
||||
|
||||
mojoDescriptor.setAggregator( mojo.aggregator() );
|
||||
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
|
||||
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
|
||||
|
||||
mojoDescriptors.add( mojoDescriptor );
|
||||
}
|
||||
return mojoDescriptors;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package org.apache.maven.tools.plugin.annotations.datamodel;
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
*/
|
||||
public class AnnotatedContent
|
||||
{
|
||||
private String description;
|
||||
|
||||
private String since;
|
||||
|
||||
private String deprecated;
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription( String description )
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSince()
|
||||
{
|
||||
return since;
|
||||
}
|
||||
|
||||
public void setSince( String since )
|
||||
{
|
||||
this.since = since;
|
||||
}
|
||||
|
||||
public String getDeprecated()
|
||||
{
|
||||
return deprecated;
|
||||
}
|
||||
|
||||
public void setDeprecated( String deprecated )
|
||||
{
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ package org.apache.maven.tools.plugin.annotations.datamodel;
|
|||
* @author Olivier Lamy
|
||||
*/
|
||||
public class AnnotatedField
|
||||
extends AnnotatedContent
|
||||
{
|
||||
private String fieldName;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.Annotation;
|
|||
* @author Olivier Lamy
|
||||
*/
|
||||
public class MojoAnnotationContent
|
||||
extends AnnotatedContent
|
||||
implements Mojo
|
||||
{
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@
|
|||
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
|
||||
<role-hint>java-annotations</role-hint>
|
||||
<implementation>org.apache.maven.tools.plugin.annotations.JavaAnnotationsMojoDescriptorExtractor</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScanner</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
|
|
|||
Loading…
Reference in New Issue