
t3.plugin.annotations.replacement.HandleParameterReplacement Maven / Gradle / Ivy
/**
* (C) Copyright 2016-2019 teecube
* (https://teecu.be) and others.
*
* Licensed 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.
*/
package t3.plugin.annotations.replacement;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import org.kohsuke.MetaInfServices;
import t3.plugin.annotations.Parameter;
import java.util.ArrayList;
import java.util.List;
/**
*
* This class will add a {@link org.apache.maven.plugins.annotations.Parameter}
* annotation wherever a {@link t3.plugin.annotations.Parameter} is found.
*
* The annotation created is a duplicate.
*
* It allows to have both annotations: one is the standard Maven one (used by
* Maven core and to generate Maven site for instance), the other is a copy with
* a RUNTIME retention policy.
*
*
* @author Mathieu Debove <[email protected]>
*
*/
@MetaInfServices(JavacAnnotationHandler.class)
@HandlerPriority(1024)
public class HandleParameterReplacement extends JavacAnnotationHandler {
public String getAnnotationCanonicalName() {
return Parameter.class.getCanonicalName();
}
public List getReplacementClassElements() {
List result = new ArrayList();
result.add("org");
result.add("apache");
result.add("maven");
result.add("plugins");
result.add("annotations");
result.add("Parameter");
return result;
}
@Override
public void handle(final AnnotationValues annotation, final JCAnnotation ast, final JavacNode annotationNode) {
List fieldsToIgnore = new ArrayList<>();
fieldsToIgnore.add("description");
fieldsToIgnore.add("requiredForPackagings");
fieldsToIgnore.add("hideDocumentation");
// no inheritance possible
AnnotationReplacementHelper.duplicateAnnotationWithAnother(annotation, ast, annotationNode, getAnnotationCanonicalName(), getReplacementClassElements(), fieldsToIgnore);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy