added DependencyScope enumeration

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1337586 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2012-05-12 16:14:40 +00:00
parent 1d5f6f7c7d
commit c9063cbb83
6 changed files with 69 additions and 13 deletions

View File

@ -31,4 +31,11 @@
<name>Maven Plugin Java 5 Annotations</name> <name>Maven Plugin Java 5 Annotations</name>
<description>Java 5 annotations to use in Mojos.</description> <description>Java 5 annotations to use in Mojos.</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project> </project>

View File

@ -0,0 +1,46 @@
package org.apache.maven.plugins.annotations;
/*
* 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.artifact.Artifact;
/**
* @author Hervé Boutemy
* @since 3.0
*/
public enum DependencyScope
{
COMPILE( Artifact.SCOPE_COMPILE ),
COMPILE_PLUS_RUNTIME( Artifact.SCOPE_COMPILE_PLUS_RUNTIME ),
RUNTIME( Artifact.SCOPE_RUNTIME ),
TEST( Artifact.SCOPE_TEST );
private final String id;
DependencyScope( String id )
{
this.id = id;
}
public String id()
{
return this.id;
}
}

View File

@ -40,9 +40,9 @@ public @interface Mojo
LifecyclePhase defaultPhase() default LifecyclePhase.NONE; LifecyclePhase defaultPhase() default LifecyclePhase.NONE;
String requiresDependencyResolution() default "runtime"; DependencyScope requiresDependencyResolution() default DependencyScope.RUNTIME;
String requiresDependencyCollection() default ""; DependencyScope requiresDependencyCollection() default DependencyScope.RUNTIME;
String instantiationStrategy() default "per-lookup"; String instantiationStrategy() default "per-lookup";

View File

@ -454,8 +454,8 @@ public class JavaAnnotationsMojoDescriptorExtractor
mojo.setDeprecated( mojo.getDeprecated() ); mojo.setDeprecated( mojo.getDeprecated() );
mojoDescriptor.setAggregator( mojo.aggregator() ); mojoDescriptor.setAggregator( mojo.aggregator() );
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() ); mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution().toString() );
mojoDescriptor.setDependencyCollectionRequired( mojo.requiresDependencyCollection() ); mojoDescriptor.setDependencyCollectionRequired( mojo.requiresDependencyCollection().toString() );
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() ); mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
mojoDescriptor.setDeprecated( mojo.getDeprecated() ); mojoDescriptor.setDeprecated( mojo.getDeprecated() );

View File

@ -19,6 +19,7 @@ package org.apache.maven.tools.plugin.annotations.datamodel;
* under the License. * under the License.
*/ */
import org.apache.maven.plugins.annotations.DependencyScope;
import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Mojo;
@ -36,9 +37,9 @@ public class MojoAnnotationContent
private LifecyclePhase defaultPhase = LifecyclePhase.NONE; private LifecyclePhase defaultPhase = LifecyclePhase.NONE;
private String requiresDependencyResolution = "runtime"; private DependencyScope requiresDependencyResolution = DependencyScope.RUNTIME;
private String requiresDependencyCollection; private DependencyScope requiresDependencyCollection = DependencyScope.RUNTIME;
private String instantiationStrategy = "per-lookup"; private String instantiationStrategy = "per-lookup";
@ -75,22 +76,22 @@ public class MojoAnnotationContent
this.defaultPhase = LifecyclePhase.valueOf( phase ); this.defaultPhase = LifecyclePhase.valueOf( phase );
} }
public String requiresDependencyResolution() public DependencyScope requiresDependencyResolution()
{ {
return requiresDependencyResolution; return requiresDependencyResolution;
} }
public void requiresDependencyResolution( String requiresDependencyResolution ) public void requiresDependencyResolution( DependencyScope requiresDependencyResolution )
{ {
this.requiresDependencyResolution = requiresDependencyResolution; this.requiresDependencyResolution = requiresDependencyResolution;
} }
public String requiresDependencyCollection() public DependencyScope requiresDependencyCollection()
{ {
return requiresDependencyCollection == null ? "" : requiresDependencyCollection; return requiresDependencyCollection;
} }
public void requiresDependencyCollection( String requiresDependencyCollection ) public void requiresDependencyCollection( DependencyScope requiresDependencyCollection )
{ {
this.requiresDependencyCollection = requiresDependencyCollection; this.requiresDependencyCollection = requiresDependencyCollection;
} }

View File

@ -36,6 +36,8 @@ Maven Plugin Tool for Annotations
+---------+ +---------+
import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.DependencyScope;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Mojo;
@ -53,8 +55,8 @@ import org.apache.maven.plugins.annotations.Parameter;
inheritByDefault = <true|false>, inheritByDefault = <true|false>,
instantiationStrategy = "<per-lookup|singleton|keep-alive|poolable>", instantiationStrategy = "<per-lookup|singleton|keep-alive|poolable>",
defaultPhase = "<phaseName>", defaultPhase = "<phaseName>",
requiresDependencyResolution = "<compile|runtime|compile+runtime|test>", requiresDependencyResolution = DependencyScope.<scope>,
requiresDependencyCollection = "<compile|runtime|compile+runtime|test>", // (since Maven 3.0) requiresDependencyCollection = DependencyScope.<scope>, // (since Maven 3.0)
requiresDirectInvocation = <false|true>, requiresDirectInvocation = <false|true>,
requiresOnline = <false|true>, requiresOnline = <false|true>,
requiresProject = <true|false>, requiresProject = <true|false>,