List of usage examples for org.apache.maven.project MavenProject getPackaging
public String getPackaging()
From source file:de.lightful.maven.plugins.drools.impl.dependencies.DependencyLoader.java
License:Apache License
private Dependency createDependencyFrom(MavenProject project) { final String artifactType = project.getPackaging(); org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), EMPTY_CLASSIFIER, fileExtensionOf(artifactType), project.getVersion()); return new Dependency(artifact, WellKnownNames.SCOPE_COMPILE); }
From source file:de.lightful.maven.plugins.drools.impl.OutputFileWriter.java
License:Apache License
private void ensureCorrectPackaging(MavenProject mavenProject) { if (!WellKnownNames.DROOLS_KNOWLEDGE_MODULE_PACKAGING_IDENTIFIER.equals(mavenProject.getPackaging())) { error.write("Internal error: packaging of project must be equal to '" + WellKnownNames.DROOLS_KNOWLEDGE_MODULE_PACKAGING_IDENTIFIER + "' when using this plugin!") .nl();//from w ww . j a v a 2 s . c om } }
From source file:fr.fastconnect.factory.tibco.bw.codereview.CodeReviewNoForkMojo.java
License:Apache License
public static boolean skip(MavenProject mavenProject) { return !BWEAR_TYPE.equals(mavenProject.getPackaging()) && !PROJLIB_TYPE.equals(mavenProject.getPackaging()); }
From source file:fr.fastconnect.factory.tibco.bw.codereview.pages.CodeReviewIndexMojo.java
License:Apache License
public static boolean skip(MavenProject mavenProject) { return !POM_TYPE.equals(mavenProject.getPackaging()); }
From source file:fr.fastconnect.factory.tibco.bw.maven.builtin.CopyBWSourcesMojo.java
License:Apache License
@Override protected List<Resource> getResources() { List<Resource> result = new ArrayList<Resource>(); if (resources != null) { result.addAll(resources);// w w w . j a v a 2s. c o m } if (isContainerEnabled(getProject())) { result.clear(); // ignore configuration from Plexus 'components.xml' getLog().debug(getProject().getProperties().toString()); getLog().debug(getProject().getProperties().getProperty("project.build.directory.src")); File buildSrcDirectory = new File( getProject().getProperties().getProperty("project.build.directory.src")); buildSrcDirectory.mkdirs(); // create "target/src" directory // define a ".archive" file to merge all ".archive" found in other projects String bwProjectArchiveBuilder = getProject().getProperties().getProperty("bw.project.archive.builder"); File bwProjectArchiveMerged = new File( buildSrcDirectory.getAbsolutePath() + File.separator + bwProjectArchiveBuilder); getLog().debug(".archive: " + bwProjectArchiveMerged.getAbsolutePath()); // create an empty Archive Builder (".archive" file) ArchiveBuilder mergedArchiveBuilder = new ArchiveBuilder(); List<MavenProject> projectsToAggregate = new ArrayList<MavenProject>(); MavenProject aggregator = getProject().getParent(); @SuppressWarnings("unchecked") List<String> modules = aggregator.getModules(); for (String module : modules) { getLog().debug(module); String pom = aggregator.getBasedir() + File.separator + module + File.separator + "pom.xml"; File pomFile = new File(pom); try { projectsToAggregate.add(new MavenProject(POMManager.getModelFromPOM(pomFile, getLog()))); } catch (Exception e) { getLog().debug("Unable to add project from module: " + module); } } List<MavenProject> projects = new ArrayList<MavenProject>(); projects.addAll(getSession().getProjects()); for (Iterator<MavenProject> it = projects.iterator(); it.hasNext();) { MavenProject p = (MavenProject) it.next(); if (!isProjectToAggregate(p, projectsToAggregate)) { it.remove(); } } if (projects.size() > 0) { for (MavenProject p : projects) { if (p.getPackaging().equals(AbstractBWMojo.BWEAR_TYPE) && !isContainerEnabled(p)) { // initialize project information String basedir = p.getBasedir().getAbsolutePath(); String bwProjectLocation = p.getProperties().getProperty("bw.project.location"); bwProjectArchiveBuilder = p.getProperties().getProperty("bw.project.archive.builder"); // the ".archive" of the project getLog().debug(basedir); getLog().debug(bwProjectLocation); File bwProjectArchive = new File(basedir + File.separator + bwProjectLocation + File.separator + bwProjectArchiveBuilder); getLog().debug(bwProjectArchive.getAbsolutePath()); // mergedArchiveBuilder.merge(bwProjectArchive); // add sources from the project to the container sources File srcDirectory = new File(basedir + File.separator + bwProjectLocation); result.add(addResource(srcDirectory)); } } mergedArchiveBuilder.setSharedArchiveAuthor(pluginDescriptor.getArtifactId()); mergedArchiveBuilder.setEnterpriseArchiveAuthor(pluginDescriptor.getArtifactId()); mergedArchiveBuilder.setEnterpriseArchiveFileLocationProperty( this.getProject().getArtifactId() + AbstractBWMojo.BWEAR_EXTENSION); mergedArchiveBuilder.setEnterpriseArchiveName(enterpriseArchiveName); mergedArchiveBuilder.setFirstProcessArchiveName(processArchiveName); mergedArchiveBuilder.removeDuplicateProcesses(); mergedArchiveBuilder.save(bwProjectArchiveMerged); } } return result; }
From source file:fr.fastconnect.factory.tibco.bw.maven.BWLifecycleParticipant.java
License:Apache License
private List<MavenProject> prepareProjects(List<MavenProject> projects, MavenSession session) throws MavenExecutionException { List<MavenProject> result = new ArrayList<MavenProject>(); ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); for (MavenProject mavenProject : projects) { logger.debug("project: " + mavenProject.getGroupId() + ":" + mavenProject.getArtifactId()); List<String> oldActiveProfileIds = projectBuildingRequest.getActiveProfileIds(); try {/*from w w w. j a v a 2 s.c om*/ List<String> activeProfileIds = activateProfilesWithProperties(mavenProject, oldActiveProfileIds); if (activeProfileIds.size() != oldActiveProfileIds.size()) { projectBuildingRequest.setActiveProfileIds(activeProfileIds); if (mavenProject.getFile() != null) { List<File> files = new ArrayList<File>(); files.add(mavenProject.getFile()); List<ProjectBuildingResult> results = null; try { results = projectBuilder.build(files, true, projectBuildingRequest); } catch (ProjectBuildingException e) { } for (ProjectBuildingResult projectBuildingResult : results) { mavenProject = projectBuildingResult.getProject(); } } } } finally { projectBuildingRequest.setActiveProfileIds(oldActiveProfileIds); } if (mavenProject.getPackaging().startsWith(AbstractBWMojo.BWEAR_TYPE) || "true".equals(propertiesManager.getPropertyValue("enableBWLifecycle"))) { addTIBCODependenciesToPlugin(mavenProject, logger); } result.add(mavenProject); } return result; }
From source file:hudson.gridmaven.PomInfo.java
License:Open Source License
public PomInfo(MavenProject project, PomInfo parent, String relPath) { this.name = new ModuleName(project); this.version = project.getVersion(); this.displayName = project.getName(); this.defaultGoal = project.getDefaultGoal(); this.relativePath = relPath; this.parent = parent; if (parent != null) parent.children.add(name);//from w w w. j a v a 2 s . c o m for (Dependency dep : (List<Dependency>) project.getDependencies()) dependencies.add(new ModuleDependency(dep)); MavenProject parentProject = project.getParent(); if (parentProject != null) dependencies.add(new ModuleDependency(parentProject)); if (parent != null) dependencies.add(parent.asDependency()); addPluginsAsDependencies(project.getBuildPlugins(), dependencies); addReportPluginsAsDependencies(project.getReportPlugins(), dependencies); List<Extension> extensions = project.getBuildExtensions(); if (extensions != null) for (Extension ext : extensions) dependencies.add(new ModuleDependency(ext)); // when the parent POM uses a plugin and builds a plugin at the same time, // the plugin module ends up depending on itself dependencies.remove(asDependency()); CiManagement ciMgmt = project.getCiManagement(); if ((ciMgmt != null) && (ciMgmt.getSystem() == null || ciMgmt.getSystem().equals("hudson"))) { Notifier mailNotifier = null; for (Notifier n : (List<Notifier>) ciMgmt.getNotifiers()) { if (n.getType().equals("mail")) { mailNotifier = n; break; } } this.mailNotifier = mailNotifier; } else this.mailNotifier = null; this.groupId = project.getGroupId(); this.artifactId = project.getArtifactId(); this.packaging = project.getPackaging(); }
From source file:io.fabric8.maven.AbstractFabric8Mojo.java
License:Apache License
/** * Returns true if this project is a pom packaging project *//*from w ww . j a v a2 s .c o m*/ protected boolean isPom(MavenProject reactorProject) { return "pom".equals(reactorProject.getPackaging()); }
From source file:io.fabric8.maven.CreateProfileZipMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {/* w w w.j a v a 2 s . c o m*/ if (isIgnoreProject()) return; generateZip(); if (reactorProjects != null) { List<MavenProject> pomZipProjects = new ArrayList<>(); List<MavenProject> fabricZipGoalProjects = new ArrayList<>(); List<MavenProject> fabricHasParentZipGoalProject = new ArrayList<MavenProject>(); for (MavenProject reactorProject : reactorProjects) { if ("pom".equals(reactorProject.getPackaging())) { pomZipProjects.add(reactorProject); } List<Plugin> buildPlugins = reactorProject.getBuildPlugins(); for (Plugin buildPlugin : buildPlugins) { String artifactId = buildPlugin.getArtifactId(); // TODO I guess we could try find if the "zip" goal is being invoked? if ("fabric8-maven-plugin".equals(artifactId)) { // TODO should we only consider reactorProjects which have a fabric8:zip goal? Object goals = buildPlugin.getGoals(); boolean hasZipGoal = goals != null && goals.toString().contains("zip"); List<PluginExecution> executions = buildPlugin.getExecutions(); for (PluginExecution execution : executions) { List<String> execGoals = execution.getGoals(); if (execGoals.contains("zip")) { hasZipGoal = true; } } getLog().debug( "project " + reactorProject.getArtifactId() + " has zip goal: " + hasZipGoal); fabricZipGoalProjects.add(reactorProject); } } } // we want a list of projects which has a parent that has a zip goal too // as that helps us detect the 'last' project when we do a full build from the entire project for (MavenProject project : fabricZipGoalProjects) { if (fabricZipGoalProjects.contains(project.getParent())) { fabricHasParentZipGoalProject.add(project); } } // are we the last project? boolean last = reactorProjects.size() > 1 && project == reactorProjects.get(reactorProjects.size() - 1); if (!last) { // are we the last project with the zip goal, part of a group as they have a parent? // TODO: there can be multiple groups, so when we switch to a new group we should aggregate last = fabricHasParentZipGoalProject.size() > 1 && project == fabricHasParentZipGoalProject .get(fabricHasParentZipGoalProject.size() - 1); } if (!last) { // are we the last project with the zip goal? last = fabricZipGoalProjects.size() > 1 && project == fabricZipGoalProjects.get(fabricZipGoalProjects.size() - 1); } // we need to generate the aggregated zip last, so we have all the generated profiles in the other modules // which we can aggregate if (last) { getLog().info(""); getLog().info("Creating aggregated profile zip"); getLog().info("built the last fabric8:zip project so generating a combined zip for all " + fabricZipGoalProjects.size() + " projects with a fabric8:zip goal"); // favor root project as the 1st project with fabric8:zip goal MavenProject rootProject = fabricZipGoalProjects.size() > 0 ? fabricZipGoalProjects.get(0) : reactorProjects.get(0); // we got the root project, now filter out pom projects which has the rootProject as one of their parents List<MavenProject> ourPomZipProjects = new ArrayList<MavenProject>(); // include the root project if its a zip as well if (pomZipProjects.contains(rootProject)) { ourPomZipProjects.add(rootProject); } ourPomZipProjects.add(rootProject); for (MavenProject zip : pomZipProjects) { if (hasParent(zip, rootProject, true)) { ourPomZipProjects.add(zip); } } getLog().info("Choosing root project " + rootProject.getArtifactId() + " for generation of aggregated zip"); generateAggregatedZip(rootProject, fabricZipGoalProjects, ourPomZipProjects); } } } catch (MojoFailureException e) { throw e; } catch (MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException("Error executing", e); } }
From source file:io.fabric8.vertx.maven.plugin.utils.MojoUtils.java
License:Apache License
/** * @param project/*from w ww .j a va 2s . com*/ * @param mavenSession * @param buildPluginManager * @throws MojoExecutionException */ public void buildPrimaryArtifact(MavenProject project, MavenSession mavenSession, BuildPluginManager buildPluginManager) throws MojoExecutionException { if (logger != null && logger.isDebugEnabled()) { logger.debug("Primary artifact does not exist, building ..."); } String packaging = project.getPackaging(); if ("jar".equals(packaging)) { Optional<Plugin> jarPlugin = hasPlugin(project, JAR_PLUGIN_KEY); if (jarPlugin.isPresent()) { executeMojo(jarPlugin.get(), goal(GOAL_PACKAGE), configuration(element("outputDirectory", "${project.build.outputDir}"), element("classesDirectory", "${project.build.outputDirectory}")), executionEnvironment(project, mavenSession, buildPluginManager)); } else { executeMojo( plugin(G_MAVEN_JAR_PLUGIN, A_MAVEN_JAR_PLUGIN, properties.getProperty(V_MAVEN_JAR_PLUGIN)), goal(GOAL_PACKAGE), configuration(element("outputDirectory", "${project.build.outputDir}"), element("classesDirectory", "${project.build.outputDirectory}")), executionEnvironment(project, mavenSession, buildPluginManager)); } } else { throw new MojoExecutionException("The packaging :" + packaging + " is not supported as of now"); } throw new MojoExecutionException("The packaging :" + packaging + " is not supported as of now"); }