extended IT for annotations
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1343181 13f79535-47bb-0310-9956-ffa450edef68master
parent
404aeb03b5
commit
8409babf38
|
|
@ -0,0 +1,76 @@
|
|||
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.Component;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.apache.maven.plugins.annotations.Execute;
|
||||
import org.apache.maven.plugins.annotations.InstanciationStrategy;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProjectHelper;
|
||||
|
||||
/**
|
||||
* Checks maximum annotations with non-default values.
|
||||
*
|
||||
* @since since-text
|
||||
* @deprecated deprecated-text
|
||||
*/
|
||||
@Mojo( name = "maximal",
|
||||
aggregator = true,
|
||||
configurator = "configurator-hint",
|
||||
requiresDependencyResolution = ResolutionScope.TEST,
|
||||
requiresDependencyCollection = ResolutionScope.COMPILE,
|
||||
defaultPhase = LifecyclePhase.PACKAGE,
|
||||
executionStrategy = "always",
|
||||
instantiationStrategy = InstanciationStrategy.SINGLETON,
|
||||
inheritByDefault = false,
|
||||
requiresDirectInvocation = true,
|
||||
requiresOnline = true,
|
||||
requiresProject = false,
|
||||
requiresReports = true,
|
||||
threadSafe = true )
|
||||
@Execute( phase = LifecyclePhase.COMPILE )
|
||||
public class Maximal
|
||||
extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* Parameter description.
|
||||
*
|
||||
* @since since-text
|
||||
* @deprecated deprecated-text
|
||||
*/
|
||||
@Parameter( alias = "myAlias",
|
||||
property = "aProperty",
|
||||
defaultValue = "${anExpression}",
|
||||
readonly = true,
|
||||
required = true )
|
||||
private String param;
|
||||
|
||||
@Component( role = MavenProjectHelper.class, hint = "test" )
|
||||
private Object projectHelper;
|
||||
|
||||
public void execute()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,17 +20,21 @@ package org.apache.maven.plugin.coreit;
|
|||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.apache.maven.plugins.annotations.Component;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProjectHelper;
|
||||
|
||||
/**
|
||||
* Does nothing special.
|
||||
*
|
||||
*/
|
||||
@Mojo( name = "second", requiresDependencyCollection = ResolutionScope.COMPILE, threadSafe = true )
|
||||
public class SecondMojo
|
||||
// minimum annotations => default values
|
||||
@Mojo( name = "minimal" )
|
||||
public class Minimal
|
||||
extends AbstractMojo
|
||||
{
|
||||
@Parameter
|
||||
private String param;
|
||||
|
||||
@Component
|
||||
private MavenProjectHelper projectHelper;
|
||||
|
||||
public void execute()
|
||||
{
|
||||
|
|
@ -132,9 +132,76 @@ assert parameter.required.text() == 'true'
|
|||
assert parameter.editable.text() == 'true'
|
||||
assert parameter.description.text() == ''
|
||||
|
||||
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second" }[0]
|
||||
// check default values
|
||||
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "minimal"}[0]
|
||||
|
||||
assert mojo.requiresDependencyCollection.text() == 'compile'
|
||||
assert mojo.goal.text() == 'minimal'
|
||||
assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.Minimal'
|
||||
assert mojo.language.text() == 'java'
|
||||
assert mojo.description.text() == ''
|
||||
assert mojo.deprecated.text() == ''
|
||||
assert mojo.requiresDependencyResolution.text() == ''
|
||||
assert mojo.requiresDependencyCollection.text() == ''
|
||||
assert mojo.requiresProject.text() == 'true'
|
||||
assert mojo.requiresOnline.text() == 'false'
|
||||
assert mojo.requiresDirectInvocation.text() == 'false'
|
||||
assert mojo.requiresReports.text() == 'false'
|
||||
assert mojo.aggregator.text() == 'false'
|
||||
assert mojo.threadSafe.text() == 'false'
|
||||
assert mojo.phase.text() == ''
|
||||
assert mojo.executePhase.text() == ''
|
||||
assert mojo.executeLifecycle.text() == ''
|
||||
assert mojo.executionStrategy.text() == 'once-per-session'
|
||||
assert mojo.inheritedByDefault.text() == 'true'
|
||||
assert mojo.instantiationStrategy.text() == 'per-lookup'
|
||||
|
||||
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "param" }[0]
|
||||
assert parameter.name.text() == 'param'
|
||||
assert parameter.alias.text() == ''
|
||||
assert parameter.type.text() == 'java.lang.String'
|
||||
assert parameter.deprecated.text() == ''
|
||||
assert parameter.required.text() == 'false'
|
||||
assert parameter.editable.text() == 'true'
|
||||
assert parameter.description.text() == ''
|
||||
|
||||
def requirement = mojo.requirements.requirement.findAll{ it.'field-name'.text() == "projectHelper" }[0]
|
||||
assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper'
|
||||
|
||||
// check values set by every annotation
|
||||
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "maximal"}[0]
|
||||
|
||||
assert mojo.goal.text() == 'maximal'
|
||||
assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.Maximal'
|
||||
assert mojo.language.text() == 'java'
|
||||
assert mojo.description.text() == 'Checks maximum annotations with non-default values.'
|
||||
assert mojo.deprecated.text() == 'deprecated-text'
|
||||
assert mojo.requiresDependencyResolution.text() == 'compile'
|
||||
assert mojo.requiresDependencyCollection.text() == 'test'
|
||||
assert mojo.requiresProject.text() == 'false'
|
||||
assert mojo.requiresOnline.text() == 'true'
|
||||
assert mojo.requiresDirectInvocation.text() == 'true'
|
||||
assert mojo.requiresReports.text() == 'true'
|
||||
assert mojo.aggregator.text() == 'true'
|
||||
assert mojo.configurator.text() == 'configurator-hint'
|
||||
assert mojo.threadSafe.text() == 'true'
|
||||
assert mojo.phase.text() == 'package'
|
||||
assert mojo.executePhase.text() == 'compile'
|
||||
assert mojo.executeLifecycle.text() == ''
|
||||
assert mojo.executionStrategy.text() == 'always'
|
||||
assert mojo.inheritedByDefault.text() == 'false'
|
||||
assert mojo.instantiationStrategy.text() == 'singleton'
|
||||
|
||||
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "param" }[0]
|
||||
assert parameter.name.text() == 'param'
|
||||
assert parameter.alias.text() == 'myAlias'
|
||||
assert parameter.type.text() == 'java.lang.String'
|
||||
assert parameter.since.text() == 'since-text'
|
||||
assert parameter.deprecated.text() == 'deprecated-text'
|
||||
assert parameter.required.text() == 'true'
|
||||
assert parameter.editable.text() == 'false'
|
||||
assert parameter.description.text() == 'Parameter description.'
|
||||
|
||||
requirement = mojo.requirements.requirement.findAll{ it.'field-name'.text() == "projectHelper" }[0]
|
||||
assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper'
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue