org.apache.maven.plugin.descriptor.Parameter Java Examples
The following examples show how to use
org.apache.maven.plugin.descriptor.Parameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 6 votes |
/** * * @param parameterList * @return */ private List<Parameter> filterParameters(List<Parameter> parameterList) { List<Parameter> filtered = new ArrayList<Parameter>(); if (parameterList != null) { for (Parameter parameter : parameterList) { if (parameter.isEditable()) { String expression = parameter.getExpression(); if (expression == null || !expression.startsWith("${component.")) { filtered.add(parameter); } } } } return filtered; }
Example #2
Source File: LegacyPluginDescriptors.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
private static MojoParameter toMojoParameter(Parameter parameter) { MojoParameter result = new MojoParameter(); result.setName(parameter.getName()); result.setAlias(parameter.getAlias()); result.setType(parameter.getType()); result.setRequired(parameter.isRequired()); result.setEditable(parameter.isEditable()); result.setDescription(parameter.getDescription()); result.setDeprecated(parameter.getDeprecated()); result.setSince(parameter.getSince()); result.setImplementation(parameter.getImplementation()); result.setDefaultValue(parameter.getDefaultValue()); result.setExpression(parameter.getExpression()); return result; }
Example #3
Source File: PluginExtractor.java From wisdom with Apache License 2.0 | 6 votes |
/** * Extracts the subset of the given configuration containing only the values accepted by the plugin/goal. The * configuration is modified in-place. The the extraction fail the configuration stays unchanged. * * @param mojo the Wisdom mojo * @param plugin the plugin object * @param goal the goal / mojo * @param configuration the global configuration */ public static void extractEligibleConfigurationForGoal(AbstractWisdomMojo mojo, Plugin plugin, String goal, Xpp3Dom configuration) { try { MojoDescriptor descriptor = mojo.pluginManager.getMojoDescriptor(plugin, goal, mojo.remoteRepos, mojo.repoSession); final List<Parameter> parameters = descriptor.getParameters(); Xpp3Dom[] children = configuration.getChildren(); if (children != null) { for (int i = children.length - 1; i >= 0; i--) { Xpp3Dom child = children[i]; if (!contains(parameters, child.getName())) { configuration.removeChild(i); } } } } catch (Exception e) { mojo.getLog().warn("Cannot extract the eligible configuration for goal " + goal + " from the " + "configuration"); mojo.getLog().debug(e); // The configuration is not changed. } }
Example #4
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 5 votes |
/** * * @param w */ private void writeParameterTable(ConfluenceWikiWriter w) { List<Parameter> parameterList = descriptor.getParameters(); //remove components and read-only parameters List<Parameter> list = filterParameters(parameterList); if (list != null && list.size() > 0) { writeParameterSummary(list, w); writeParameterDetails(list, w); } }
Example #5
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 5 votes |
/** * * @param parameterList * @param w */ private void writeParameterSummary(List<Parameter> parameterList, ConfluenceWikiWriter w) { List<Parameter> requiredParams = getParametersByRequired(true, parameterList); if (!requiredParams.isEmpty()) { writeParameterList("Required Parameters", requiredParams, w); } List<Parameter> optionalParams = getParametersByRequired(false, parameterList); if (!optionalParams.isEmpty()) { writeParameterList("Optional Parameters", optionalParams, w); } }
Example #6
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 5 votes |
/** * * @param required * @param parameterList * @return */ private List<Parameter> getParametersByRequired(boolean required, List<Parameter> parameterList) { if( parameterList == null) return Collections.emptyList(); final List<Parameter> list = new ArrayList<Parameter>(); for (Parameter parameter : parameterList) { if (parameter.isRequired() == required) { list.add(parameter); } } return list; }
Example #7
Source File: LegacyPluginDescriptors.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
private static MojoDescriptor toMojoDescriptor(org.apache.maven.plugin.descriptor.MojoDescriptor mojo) { MojoDescriptor result = new MojoDescriptor(); result.setGoal(mojo.getGoal()); result.setDescription(mojo.getDescription()); result.setSince(mojo.getSince()); result.setRequiresDependencyResolution(mojo.getDependencyResolutionRequired()); result.setRequiresDependencyCollection(mojo.getDependencyCollectionRequired()); result.setRequiresDirectInvocation(mojo.isDirectInvocationOnly()); result.setRequiresProject(mojo.isProjectRequired()); result.setRequiresReports(mojo.isRequiresReports()); result.setAggregator(mojo.isAggregator()); result.setRequiresOnline(mojo.isOnlineRequired()); result.setInheritedByDefault(mojo.isInheritedByDefault()); result.setPhase(mojo.getPhase()); result.setImplementation(mojo.getImplementation()); result.setLanguage(mojo.getLanguage()); result.setConfigurator(mojo.getComponentConfigurator()); result.setInstantiationStrategy(mojo.getInstantiationStrategy()); result.setExecutionStrategy(mojo.getExecutionStrategy()); result.setThreadSafe(mojo.isThreadSafe()); result.setDeprecated(mojo.getDeprecated()); List<MojoParameter> parameters = new ArrayList<>(); if (mojo.getParameters() != null) { for (Parameter parameter : mojo.getParameters()) { parameters.add(toMojoParameter(parameter)); } } result.setParameters(parameters); List<MojoRequirement> requirements = new ArrayList<>(); for (ComponentRequirement requirement : mojo.getRequirements()) { requirements.add(toMojoRequirement(requirement)); } result.setRequirements(requirements); return result; }
Example #8
Source File: PluginExtractor.java From wisdom with Apache License 2.0 | 5 votes |
private static boolean contains(List<Parameter> parameters, String name) { for (Parameter parameter : parameters) { if (parameter.getName().equalsIgnoreCase(name)) { return true; } } return false; }
Example #9
Source File: MojoExtension.java From helm-maven-plugin with MIT License | 4 votes |
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { try { // get descriptor Class<? extends AbstractHelmMojo> mojoType = (Class<AbstractHelmMojo>) parameterContext.getParameter().getType(); MojoDescriptor descriptor = mojoDescriptors.get(mojoType); assertNotNull(descriptor, "Plugin descriptor for " + mojoType.getSimpleName() + " not found, run 'maven-plugin-plugin:descriptor'."); // create mojo with default values AbstractHelmMojo mojo = spy(mojoType); for (Parameter parameter : descriptor.getParameters()) { if (parameter.getDefaultValue() == null || !parameter.isEditable() || parameter.getType().equals("boolean")) { continue; } getField(mojoType, parameter.getName()).set(mojo, resolve(context, parameter.getDefaultValue())); } // read mojo values from annotations MojoProperty[] mojoProperties = ArrayUtils.addAll( context.getRequiredTestClass().getAnnotationsByType(MojoProperty.class), context.getRequiredTestMethod().getAnnotationsByType(MojoProperty.class)); for (MojoProperty mojoProperty : mojoProperties) { getField(mojoType, mojoProperty.name()).set(mojo, resolve(context, mojoProperty.value())); } // settings getField(mojoType, "settings").set(mojo, new Settings()); // plexus SecDispatcher SecDispatcher secDispatcher = spy(DefaultSecDispatcher.class); FieldSetter.setField(secDispatcher, DefaultSecDispatcher.class.getDeclaredField("_cipher"), new DefaultPlexusCipher()); getField(mojoType, "securityDispatcher").set(mojo, secDispatcher); // validate that every parameter is set for (Parameter paramter : descriptor.getParameters()) { if (paramter.isRequired()) { assertNotNull( getField(mojoType, paramter.getName()).get(mojo), "Parameter '" + paramter.getName() + "' not set for mojo '" + mojoType.getSimpleName() + "'."); } } return mojo; } catch (ReflectiveOperationException | PlexusCipherException e) { throw new ParameterResolutionException("Failed to setup mockito.", e); } }
Example #10
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 3 votes |
/** * * @param parameterList * @param w */ private void writeParameterDetails(List<Parameter> parameterList, ConfluenceWikiWriter w) { w.printNormalHeading("Parameter Details"); w.printNewParagraph(); for (Parameter parameter : parameterList) { w.printSmallHeading(createAnchor(parameter.getName(), parameter.getName())); String description = parameter.getDescription(); if (StringUtils.isEmpty(description)) { description = "No Description."; } w.println(replaceHTML(description)); writeDetail("Deprecated", parameter.getDeprecated(), w); writeDetail("Type", parameter.getType(), w); writeDetail("Since", parameter.getSince(), w); if (parameter.isRequired()) { writeDetail("Required", "Yes", w); } else { writeDetail("Required", "No", w); } writeDetail("Expression", parameter.getExpression(), w); writeDetail("Default", parameter.getDefaultValue(), w); } }
Example #11
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 2 votes |
/** * * @param title * @param parameterList * @param w */ private void writeParameterList(String title, List<Parameter> parameterList, ConfluenceWikiWriter w) { w.printNormalHeading(title); w.printNewParagraph(); w.printf("||%s||%s||%s||\n", "Name", "Type", "Description"); for (Parameter parameter : parameterList) { int index = parameter.getType().lastIndexOf("."); w.print('|'); w.print(createLinkToAnchor(parameter.getName(), parameter.getName())); w.print('|'); w.print(parameter.getType().substring(index + 1)); w.print('|'); String description = parameter.getDescription(); if (StringUtils.isEmpty(description)) { description = "No description."; } if (StringUtils.isNotEmpty(parameter.getDeprecated())) { description = "Deprecated. " + description; } w.print(replaceHTML(description).replace("\n\n", "\n")); if (StringUtils.isNotEmpty(parameter.getDefaultValue())) { w.printf(" Default value is %s", replaceHTML(parameter.getDefaultValue())); } w.println('|'); } }