Refine search
protected static PluginDescriptor clone( PluginDescriptor original ) { PluginDescriptor clone = null; if ( original != null ) { clone = new PluginDescriptor(); clone.setGroupId( original.getGroupId() ); clone.setArtifactId( original.getArtifactId() ); clone.setVersion( original.getVersion() ); clone.setGoalPrefix( original.getGoalPrefix() ); clone.setInheritedByDefault( original.isInheritedByDefault() ); clone.setName( original.getName() ); clone.setDescription( original.getDescription() ); clone.setRequiredMavenVersion( original.getRequiredMavenVersion() ); clone.setPluginArtifact( ArtifactUtils.copyArtifactSafe( original.getPluginArtifact() ) ); clone.setComponents( clone( original.getMojos(), clone ) ); clone.setId( original.getId() ); clone.setIsolatedRealm( original.isIsolatedRealm() ); clone.setSource( original.getSource() ); clone.setDependencies( original.getDependencies() ); } return clone; }
project.addCompileSourceRoot(targetDirectory); v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); properties.setProperty("platform.artifacts", project.getBuild().getOutputDirectory()); for (Artifact a : plugin.getArtifacts()) { String s = a.getFile().getCanonicalPath(); String v = properties.getProperty("platform.artifacts", ""); v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s); Properties projectProperties = project.getProperties(); for (String key : properties.stringPropertyNames()) { projectProperties.setProperty("javacpp." + key, properties.getProperty(key));
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); } }
public PluginManagerException( MojoDescriptor mojoDescriptor, String message, MavenProject project, PlexusContainerException cause ) { super( message, cause ); this.project = project; PluginDescriptor pd = mojoDescriptor.getPluginDescriptor(); pluginGroupId = pd.getGroupId(); pluginArtifactId = pd.getArtifactId(); pluginVersion = pd.getVersion(); goal = mojoDescriptor.getGoal(); }
Map<String, Object> retrieveContext( MavenSession session ) { Map<String, Object> context = null; if ( session != null ) { PluginDescriptor desc = new PluginDescriptor(); desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) ); MavenProject current = session.getCurrentProject(); if ( current != null ) { //TODO why is this using the context context = session.getPluginContext( desc, current ); } } return ( context != null ) ? context : new HashMap<String, Object>(); }
throws MojoExecutionException if ( !packagingTypes.contains( project.getPackaging() ) ) getLog().warn( "Unsupported packaging type " + project.getPackaging() + ", execution skipped" ); return; String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() ); if ( goalPrefix == null ) PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGroupId( project.getGroupId() ); pluginDescriptor.setArtifactId( project.getArtifactId() ); pluginDescriptor.setVersion( project.getVersion() ); pluginDescriptor.setGoalPrefix( goalPrefix ); pluginDescriptor.setName( project.getName() ); pluginDescriptor.setDescription( project.getDescription() ); List<ComponentDependency> deps = GeneratorUtils.toComponentDependencies( project.getRuntimeDependencies() ); pluginDescriptor.setDependencies( deps );
mavenProject, mavenProject.getProperties() ); propertyHelper.setNext( new AntPropertyHelper( exprEvaluator, mavenProject.getArtifacts(), getLog() ) ); p.setPath( StringUtils.join( mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator ) ); getPathFromArtifacts( mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifacts(), antProject );
@Override protected void executeWithGems() throws MojoExecutionException, ScriptException, IOException { JarDependencies jars = new JarDependencies(project.getBuild().getOutputDirectory(), "Jars.lock"); jars.addAll(plugin.getArtifacts(), new Filter(){ @Override public boolean addIt(Artifact a) { return a.getScope().equals("runtime") && !project.getArtifactMap().containsKey(a.getGroupId() +":" + a.getArtifactId()); } }); jars.addAll(project.getArtifacts()); jars.generateJarsLock(); jars.copyJars(); File pluginGemHome = gemHome( gemsBasePath(), plugin.getArtifactId() ); addResource(project.getResources(), createGemsResource(pluginGemHome.getAbsolutePath())); addResource(project.getResources(), createGemsResource(gemsBasePath())); }
final String goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId()); final PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGroupId(project.getGroupId()); pluginDescriptor.setArtifactId(project.getArtifactId()); pluginDescriptor.setVersion(project.getVersion()); pluginDescriptor.setGoalPrefix(goalPrefix); deps.addAll(toComponentDependencies(project.getCompileDependencies())); pluginDescriptor.setDependencies(deps); pluginDescriptor.setDescription(project.getDescription());
prop.setProperty( Project.GIT_URL_KEY, gitUrl ); prop.setProperty( Project.CREATE_TIMESTAMP_KEY, timeStamp ); prop.setProperty( Project.GROUP_ID_KEY, this.project.getGroupId() ); prop.setProperty( Project.ARTIFACT_ID_KEY, this.project.getArtifactId() ); prop.setProperty( Project.PROJECT_VERSION_KEY, this.project.getVersion() ); prop.setProperty( Project.TEST_PACKAGE_BASE, testPackageBase ); prop.setProperty( Project.MD5_KEY, md5 ); prop.setProperty( Project.CHOP_VERSION_KEY, plugin.getVersion() );
String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() ); if ( goalPrefix == null ) PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGroupId( project.getGroupId() ); pluginDescriptor.setArtifactId( project.getArtifactId() ); pluginDescriptor.setVersion( project.getVersion() ); pluginDescriptor.setGoalPrefix( goalPrefix ); List<ComponentDependency> deps = GeneratorUtils.toComponentDependencies( project.getRuntimeDependencies() ); pluginDescriptor.setDependencies( deps );
IProgressMonitor progress) { try { final Map<String, Plugin> declaredPlugins = this.helper.getSession().getCurrentProject().getBuild().getPluginsAsMap(); Plugin plugin = declaredPlugins.get(ArtifactUtils.versionlessKey(MAVEN_COMPILER_PLUGIN_GROUPID, MAVEN_COMPILER_PLUGIN_ARTIFACTID)); if (plugin == null) { plugin = new Plugin(); plugin.setArtifactId(MAVEN_COMPILER_PLUGIN_ARTIFACTID); plugin.setGroupId(MAVEN_COMPILER_PLUGIN_GROUPID); plugin.setVersion(findVersion(logger)); ? MAVEN_COMPILER_PLUGIN_TEST_GOAL : MAVEN_COMPILER_PLUGIN_STANDARD_GOAL; final MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor != null) { final Xpp3Dom mojoConfiguration; try { mojoConfiguration = this.helper.toXpp3Dom(mojoDescriptor.getMojoConfiguration()); } catch (PlexusConfigurationException e1) { throw new MojoExecutionException(e1.getLocalizedMessage(), e1); final MojoExecution execution = new MojoExecution(mojoDescriptor, configuration); this.helper.executeMojo(execution); return true;
Plugin plugin = new Plugin(); plugin.setGroupId("org.datanucleus"); plugin.setArtifactId("datanucleus-maven-plugin"); plugin.setVersion(DATANUCLEUS_VERSION); plugin.addDependency(enhancer_api.equals("JDO") ? JDO_DEPENDENCY : JPA_DEPENDENCY); for (Dependency transitiveDep : project.getDependencies()) { plugin.addDependency(transitiveDep); project.getRemotePluginRepositories(), session.getRepositorySession()); } catch (PluginNotFoundException | PluginResolutionException | PluginDescriptorParsingException MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("enhance"); convertPlexusConfiguration(mojoDescriptor.getMojoConfiguration())); MojoExecution exec = new MojoExecution(mojoDescriptor, configuration);
private void unpackFileBasedResources() throws MojoExecutionException { if ( mojoExecution == null || mavenProject == null ) { unconstructedParts.add( "Unpacked Ant build scripts (in Maven build directory)." ); return; } // What we need to write out any resources in the plugin to the target directory of the // mavenProject using the Ant-based plugin: // // 1. Need a reference to the plugin JAR itself // 2. Need a reference to the ${basedir} of the mavenProject PluginDescriptor pluginDescriptor = mojoExecution.getMojoDescriptor().getPluginDescriptor(); File pluginJar = pluginDescriptor.getPluginArtifact().getFile(); String resourcesPath = pluginDescriptor.getArtifactId(); File outputDirectory = new File( mavenProject.getBuild().getDirectory() ); try { UnArchiver ua = new ZipUnArchiver( pluginJar ); ua.extract( resourcesPath, outputDirectory ); } catch ( ArchiverException e ) { throw new MojoExecutionException( "Error extracting resources from your Ant-based plugin.", e ); } }
(project.getBuild().getDirectory() + "/rubygems"); File pluginGemHome = gemHome( base, plugin.getArtifactId() ); getLog().info("installing gems for plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + " . . ."); this.plugin.getArtifacts(), this.localRepository, getRemoteRepos()); resource.addInclude("gems/**"); resource.addInclude("specifications/**"); addResource(project.getBuild().getTestResources(), resource); resource.addInclude("gems/**"); resource.addInclude("specifications/**"); addResource(project.getBuild().getResources(), resource);
if ((plugin.getVersion() == null || plugin.getVersion().length() == 0) && currentProject != null) { PluginManagement pm = currentProject.getPluginManagement(); if (pm != null) { for (Plugin p : pm.getPlugins()) { if (plugin.getGroupId().equals(p.getGroupId()) && plugin.getArtifactId().equals(p.getArtifactId())) { plugin.setVersion(p.getVersion()); break; MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
/** * We use a specific status directory for each Mojo execution to store state * which is needed during the next build invocation run. * @return the directory for storing status information of the current Mojo execution. */ public File getMojoStatusDirectory() throws MojoExecutionException { if ( mojoExecution == null ) { throw new MojoExecutionException( "MojoExecution could not get resolved" ); } File buildOutputDirectory = new File( mavenProject.getBuild().getDirectory() ); //X TODO the executionId contains -cli and -mojoname //X we should remove those postfixes as it should not make //X any difference whether being run on the cli or via build String mojoStatusPath = MAVEN_STATUS_ROOT + File.separator + mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() + File.separator + mojoExecution.getMojoDescriptor().getGoal() + File.separator + mojoExecution.getExecutionId(); File mojoStatusDir = new File( buildOutputDirectory, mojoStatusPath ); if ( !mojoStatusDir.exists() ) { mojoStatusDir.mkdirs(); } return mojoStatusDir; }
private File createWorkspace() throws MojoExecutionException { WorkspaceMojo.workspace = null; getLog().info(""); getLog().info(">>> " + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion() + ":workspace (" + "default-cli" + ") @ " + project.getArtifactId() + " >>>"); ArrayList<Element> configuration = new ArrayList<Element>(); executeMojo( plugin( groupId(pluginDescriptor.getGroupId()), artifactId(pluginDescriptor.getArtifactId()), version(pluginDescriptor.getVersion()) ), goal("workspace"), configuration( configuration.toArray(new Element[0]) ), getEnvironment() ); getLog().info(""); getLog().info("<<< " + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion() + ":workspace (" + "default-cli" + ") @ " + project.getArtifactId() + " <<<"); getLog().info(""); return WorkspaceMojo.workspace; }
protected boolean hasExmlConfiguration() { for (Object o : getProject().getBuildPlugins()) { Plugin plugin = (Plugin) o; if (plugin.getGroupId().equals(pluginDescriptor.getGroupId()) && plugin.getArtifactId().equals(pluginDescriptor.getArtifactId())) { return true; } } Build build = getProject().getOriginalModel().getBuild(); if (build != null) { PluginManagement pluginManagement = build.getPluginManagement(); if (pluginManagement != null) { for (Plugin plugin : pluginManagement.getPlugins()) { if (plugin.getGroupId().equals(pluginDescriptor.getGroupId()) && plugin.getArtifactId().equals(pluginDescriptor.getArtifactId())) { return true; } } } } return false; }
protected boolean isExmlProject() { for(Object o : getProject().getBuildPlugins()) { Plugin plugin = (Plugin) o; if (plugin.getGroupId().equals(pluginDescriptor.getGroupId()) && plugin.getArtifactId().equals(pluginDescriptor.getArtifactId())) { return plugin.isExtensions(); } } return false; } }