org.apache.maven.plugin.descriptor.MojoDescriptor Java Examples
The following examples show how to use
org.apache.maven.plugin.descriptor.MojoDescriptor.
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: 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 #2
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #3
Source File: IteratorMojo.java From iterator-maven-plugin with Apache License 2.0 | 6 votes |
/** * Taken from MojoExecutor of Don Brown. Make it working with Maven 3.1. * * @param plugin * @param goal * @param configuration * @param env * @throws MojoExecutionException * @throws PluginResolutionException * @throws PluginDescriptorParsingException * @throws InvalidPluginDescriptorException * @throws PluginManagerException * @throws PluginConfigurationException * @throws MojoFailureException */ private void executeMojo( Plugin plugin, String goal, Xpp3Dom configuration ) throws MojoExecutionException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, MojoFailureException, PluginConfigurationException, PluginManagerException { if ( configuration == null ) { throw new NullPointerException( "configuration may not be null" ); } PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin ); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { throw new MojoExecutionException( "Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() ); } MojoExecution exec = mojoExecution( mojoDescriptor, configuration ); pluginManager.executeMojo( getMavenSession(), exec ); }
Example #4
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #5
Source File: MojoConfigurationMergerTest.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
@Test public void extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration() throws Exception { InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml"); assertNotNull(is); PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8")); String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor); assertEquals("We expect the goal name to be 'jar'", "jar", goal); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); PlexusConfiguration defaultMojoConfiguration = mojoDescriptor.getMojoConfiguration(); System.out.println(defaultMojoConfiguration); PlexusConfiguration configurationFromMaven = builder("configuration") // .es("jar") // .es("sourceJar").v("true").ee() // .ee() // .buildPlexusConfiguration(); PlexusConfiguration mojoConfiguration = merger.extractAndMerge(goal, configurationFromMaven, defaultMojoConfiguration); String xml = mojoConfiguration.toString(); assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml); assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml); assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml); assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml); assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml); }
Example #6
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #7
Source File: MojoExtension.java From helm-maven-plugin with MIT License | 6 votes |
@Override public void beforeAll(ExtensionContext context) throws Exception { // get plugin descriptor InputStream inputStream = AbstractHelmMojo.class.getResourceAsStream("/META-INF/maven/plugin.xml"); assertNotNull(inputStream, "Plugin descriptor not found."); plugin = new PluginDescriptorBuilder().build(new InterpolationFilterReader(new BufferedReader(new XmlStreamReader(inputStream)), new HashMap<>())); // get mojos mojoDescriptors = new HashMap<>(); for (MojoDescriptor mojoDescriptor : plugin.getMojos()) { mojoDescriptors.put((Class<? extends AbstractHelmMojo>) Class.forName(mojoDescriptor.getImplementation()), mojoDescriptor); } }
Example #8
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #9
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #10
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter(MojoDescriptor mojoDescriptor) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>(2); if (StringUtils.isNotEmpty(scopeToCollect)) { scopes.add(scopeToCollect); } if (StringUtils.isNotEmpty(scopeToResolve)) { scopes.add(scopeToResolve); } if (scopes.isEmpty()) { return null; } else { return new CumulativeScopeArtifactFilter(scopes); } }
Example #11
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #12
Source File: MultiStartMojo.java From thorntail with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin(THORNTAIL_MAVEN_PLUGIN); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get(THORNTAIL_PROCESS); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(THORNTAIL_PROCESS); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put(THORNTAIL_PROCESS, procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #13
Source File: MojoExecutionService.java From jkube with Eclipse Public License 2.0 | 5 votes |
private MojoExecution getMojoExecution(String executionId, MojoDescriptor mojoDescriptor) { if (executionId != null) { return new MojoExecution(mojoDescriptor, executionId); } else { return new MojoExecution(mojoDescriptor, toXpp3Dom(mojoDescriptor.getMojoConfiguration())); } }
Example #14
Source File: MultiStartMojo.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin"); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process"); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process"); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put("swarm-process", procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #15
Source File: MojoExecutionService.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException { String[] parts = splitGoalSpec(fullGoal); Plugin plugin = project.getPlugin(parts[0]); String goal = parts[1]; if (plugin == null) { throw new MojoFailureException("No goal " + fullGoal + " found in pom.xml"); } try { String executionId = null; if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) { int pos = goal.indexOf('#'); executionId = goal.substring(pos + 1); goal = goal.substring(0, pos); } PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); } MojoExecution exec = getMojoExecution(executionId, mojoDescriptor); pluginManager.executeMojo(session, exec); } catch (Exception e) { throw new MojoExecutionException("Unable to execute mojo", e); } }
Example #16
Source File: MojoExecutionService.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
private MojoExecution getMojoExecution(String executionId, MojoDescriptor mojoDescriptor) { if (executionId != null) { return new MojoExecution(mojoDescriptor, executionId); } else { return new MojoExecution(mojoDescriptor, toXpp3Dom(mojoDescriptor.getMojoConfiguration())); } }
Example #17
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException { List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { if (className.equals(mojo.getImplementation())) { return mojo.getGoal(); } } throw new ComponentConfigurationException("Cannot find the goal implementation with " + className); }
Example #18
Source File: An_UpdateChecker.java From deadcode4j with Apache License 2.0 | 5 votes |
private void whenCheckingForUpdate() { PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setPluginArtifact(new DefaultArtifact("de.is24", "junit", "23", null, "maven-plugin", "", null)); MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setPluginDescriptor(pluginDescriptor); result = objectUnderTest.checkForUpdate(new MojoExecution(mojoDescriptor)); }
Example #19
Source File: MultiStartMojo.java From wildfly-swarm with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin"); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process"); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process"); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put("swarm-process", procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #20
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #21
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #22
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements(Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions) { for (MojoExecution mojoExecution : mojoExecutions) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll(toScopes(mojoDescriptor.getDependencyResolutionRequired())); scopesToCollect.addAll(toScopes(mojoDescriptor.getDependencyCollectionRequired())); } }
Example #23
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #24
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #25
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #26
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private void collectDependencyRequirements( Set<String> scopesToResolve, Set<String> scopesToCollect, Collection<MojoExecution> mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } }
Example #27
Source File: MojoExecutionService.java From jkube with Eclipse Public License 2.0 | 5 votes |
public void callPluginGoal(String fullGoal) { String[] parts = splitGoalSpec(fullGoal); Plugin plugin = project.getPlugin(parts[0]); String goal = parts[1]; if (plugin == null) { throw new IllegalStateException("No goal " + fullGoal + " found in pom.xml"); } try { String executionId = null; if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) { int pos = goal.indexOf('#'); executionId = goal.substring(pos + 1); goal = goal.substring(0, pos); } PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); } MojoExecution exec = getMojoExecution(executionId, mojoDescriptor); pluginManager.executeMojo(session, exec); } catch (Exception e) { throw new IllegalStateException("Unable to execute mojo", e); } }
Example #28
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 #29
Source File: PluginConfluenceDocGenerator.java From maven-confluence-plugin with Apache License 2.0 | 4 votes |
public Goal(MojoDescriptor mojoDescriptor) { this.descriptor = mojoDescriptor; }
Example #30
Source File: VersionsExpressionEvaluator.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
public VersionsExpressionEvaluator( MavenSession mavenSession, PathTranslator pathTranslator, MavenProject mavenProject ) { super( mavenSession, new MojoExecution( new MojoDescriptor() ), pathTranslator, null, mavenProject, mavenSession.getExecutionProperties() ); }