List of usage examples for org.apache.maven.project MavenProject getPackaging
public String getPackaging()
From source file:org.eclipse.tycho.core.resolver.DefaultTychoResolver.java
License:Open Source License
@Override public void traverse(MavenProject project, final DependencyVisitor visitor) { TychoProject tychoProject = projectTypes.get(project.getPackaging()); if (tychoProject != null) { tychoProject.getDependencyWalker(project).walk(new ArtifactDependencyVisitor() { @Override/*w ww . j av a 2s . c o m*/ public void visitPlugin(org.eclipse.tycho.core.PluginDescription plugin) { visitor.visit(plugin); } @Override public boolean visitFeature(org.eclipse.tycho.core.FeatureDescription feature) { return visitor.visit(feature); } }); } else { // TODO do something! } }
From source file:org.eclipse.tycho.extras.sourcefeature.SourceFeatureP2MetadataProvider.java
License:Open Source License
public Map<String, IDependencyMetadata> getDependencyMetadata(MavenSession session, MavenProject project, List<Map<String, String>> environments, OptionalResolutionAction optionalAction) { File template = new File(project.getBasedir(), SourceFeatureMojo.FEATURE_TEMPLATE_DIR); if (!ArtifactKey.TYPE_ECLIPSE_FEATURE.equals(project.getPackaging()) || !template.isDirectory()) { return null; }/*from w ww . j a v a 2s . c om*/ Plugin plugin = project.getPlugin("org.eclipse.tycho.extras:tycho-source-feature-plugin"); if (plugin != null) { try { File sourceFeatureBasedir = SourceFeatureMojo.getSourcesFeatureDir(project); /* * There is no easy way to determine what *exact* source bundles/features will be * included in the source feature at this point. Because of this, the source feature * dependency-only metadata does not include any dependencies. * * This has two implications. * * First, any missing source bundles/features will not be detected/reported until * source feature mojo is executed. This is inconsistent with how everything else * works in Tycho, but probably is a good thing. * * More importantly, though, source bundles/features are not included as transitive * dependencies of other reactor projects that include the source feature. To solve * this for eclipse-repository project, repository project dependencies are * recalculated during repository packaging. Other 'aggregating' project types, like * eclipse-update-site and eclipse-feature with deployableFeature=true, will not be * compatible with source features until * https://bugs.eclipse.org/bugs/show_bug.cgi?id=353889 is implemented. */ Feature feature = Feature.read(new File(project.getBasedir(), "feature.xml")); Document document = new Document(); document.setRootNode(new Element("feature")); document.setXmlDeclaration(new XMLDeclaration("1.0", "UTF-8")); Feature sourceFeature = new Feature(document); sourceFeature.setId(feature.getId() + ".source"); sourceFeature.setVersion(feature.getVersion()); Feature.write(sourceFeature, new File(sourceFeatureBasedir, Feature.FEATURE_XML)); String classifier = SourceFeatureMojo.SOURCES_FEATURE_CLASSIFIER; IArtifactFacade artifact = new AttachedArtifact(project, sourceFeatureBasedir, classifier); return Collections.singletonMap(classifier, generator.generateMetadata(artifact, null, OptionalResolutionAction.REQUIRE)); } catch (IOException e) { log.error("Could not create sources feature.xml", e); } } return null; }
From source file:org.eclipse.tycho.p2.facade.P2TargetPlatformResolver.java
License:Open Source License
private static boolean isBundleProject(MavenProject project) { String type = project.getPackaging(); return ArtifactKey.TYPE_ECLIPSE_PLUGIN.equals(type) || ArtifactKey.TYPE_ECLIPSE_TEST_PLUGIN.equals(type); }
From source file:org.eclipse.tycho.p2.facade.P2TargetPlatformResolver.java
License:Open Source License
private boolean isAllowConflictingDependencies(MavenProject project, TargetPlatformConfiguration configuration) { String packaging = project.getPackaging(); if (org.eclipse.tycho.ArtifactKey.TYPE_ECLIPSE_UPDATE_SITE.equals(packaging) || org.eclipse.tycho.ArtifactKey.TYPE_ECLIPSE_FEATURE.equals(packaging)) { Boolean allow = configuration.getAllowConflictingDependencies(); if (allow != null) { return allow.booleanValue(); }/* w w w . ja v a 2 s. c o m*/ } // conflicting dependencies do not make sense for products and bundles return false; }
From source file:org.eclipse.tycho.p2.resolver.P2DependencyResolver.java
License:Open Source License
private boolean isAllowConflictingDependencies(MavenProject project, TargetPlatformConfiguration configuration) { String packaging = project.getPackaging(); if (PackagingType.TYPE_ECLIPSE_UPDATE_SITE.equals(packaging) || PackagingType.TYPE_ECLIPSE_FEATURE.equals(packaging)) { Boolean allow = configuration.getAllowConflictingDependencies(); if (allow != null) { return allow.booleanValue(); }/* w w w . ja va2 s.com*/ } // conflicting dependencies do not make sense for products and bundles return false; }
From source file:org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.java
License:Open Source License
public TargetPlatform computeTargetPlatform(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects) { TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project); ExecutionEnvironment ee = projectTypes.get(project.getPackaging()).getExecutionEnvironment(project); TargetPlatformBuilder tpBuilder = resolverFactory.createTargetPlatformBuilder(// ee != null ? ee.getProfileName() : null, configuration.isDisableP2Mirrors()); tpBuilder.setProjectLocation(project.getBasedir()); addThisReactorProjectToTargetPlatform(session, project, configuration, tpBuilder); addOtherReactorProjectsToTargetPlatform(project, reactorProjects, tpBuilder); if (TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) { addPomDependenciesToTargetPlatform(project, tpBuilder, reactorProjects, session); }//from ww w . j a va 2s . c om for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) { addEntireP2RepositoryToTargetPlatform(repository, tpBuilder, session); } if (configuration.getTarget() != null) { addTargetFileContentToTargetPlatform(configuration, tpBuilder, session); } tpBuilder.addFilters(configuration.getFilters()); return tpBuilder.buildTargetPlatform(); }
From source file:org.eclipse.tycho.source.AbstractSourceJarMojo.java
License:Apache License
protected void packageSources(List projects) throws MojoExecutionException { if (project.getArtifact().hasClassifier()) { getLog().warn("NOT adding sources to artifacts with classifier as Maven only supports one classifier " + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a [" + project.getArtifact().getClassifier() + "] classifier."); return;// w ww. j a va 2 s. c o m } MavenArchiver archiver = createArchiver(); for (Iterator i = projects.iterator(); i.hasNext();) { MavenProject subProject = getProject((MavenProject) i.next()); if ("pom".equals(subProject.getPackaging())) { continue; } archiveProjectContent(subProject, archiver.getArchiver()); } if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) { getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath()); archive.setManifestFile(defaultManifestFile); } updateSourceManifest(archive); File outputFile = new File(outputDirectory, finalName + "-" + getClassifier() + getExtension()); try { archiver.setOutputFile(outputFile); archive.setAddMavenDescriptor(false); if (!archive.isForced()) { // optimized archive creation not supported for now because of build qualifier mismatch issues, see TYCHO-502 getLog().warn("ignoring unsupported archive forced = false parameter."); archive.setForced(true); } archiver.createArchive(project, archive); } catch (IOException e) { throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e); } catch (ArchiverException e) { throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e); } catch (ManifestException e) { throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e); } if (attach) { projectHelper.attachArtifact(project, getType(), getClassifier(), outputFile); } else { getLog().info("NOT adding java-sources to attached artifacts list."); } }
From source file:org.eclipse.tycho.source.OsgiSourceMojo.java
License:Open Source License
protected static boolean isRelevantProjectImpl(MavenProject project, BuildPropertiesParser buildPropertiesParser) { String packaging = project.getPackaging(); boolean relevant = org.eclipse.tycho.ArtifactKey.TYPE_ECLIPSE_PLUGIN.equals(packaging) || org.eclipse.tycho.ArtifactKey.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging); if (!relevant) { return false; }/* w w w . j a va 2 s . c o m*/ // this assumes that sources generation has to be explicitly enabled in pom.xml Plugin plugin = project.getPlugin("org.eclipse.tycho:tycho-source-plugin"); if (plugin == null) { return false; } for (PluginExecution execution : plugin.getExecutions()) { if (execution.getGoals().contains(GOAL)) { boolean requireSourceRoots = Boolean .parseBoolean(getParameterValue(execution, "requireSourceRoots", "false")); if (requireSourceRoots) { return true; } try { if (!getSources(project, requireSourceRoots, buildPropertiesParser).isEmpty()) { return true; } } catch (MojoExecutionException e) { // can't happen because requireSourceRoots==false } } } return false; }
From source file:org.exoplatform.maven2.plugin.Utils.java
License:Open Source License
public static void deployProject(File dirJar, File dirWar, MavenProject project, boolean deployDep, HashSet<String> ignoreProjects) throws Exception { if (!dirJar.exists()) { System.out.println("The directory " + dirJar.getParent() + " does not exists !"); return;//ww w . j a v a2 s . c o m } if (!dirWar.exists()) { System.out.println("The directory " + dirWar.getParent() + " does not exists !"); return; } int counter = 0; if (deployDep) { counter += deployedDependency(dirJar, dirWar, project, ignoreProjects).size(); } deleteFileOnExist(dirWar, project.getBuild().getFinalName()); if (project.getPackaging().equals("jar")) { counter++; File moduleFile = new File(project.getBasedir().toString() + "/target/" + project.getArtifactId() + "-" + project.getVersion() + "." + project.getPackaging()); copyFileToDirectory(moduleFile, dirJar); printMessage("deploy", " Deployed file '" + project.getArtifactId() + "' to " + dirJar.getPath()); } else { if (project.getPackaging().equals("war") || project.getPackaging().equals("exo-jcr") || project.getPackaging().equals("exo-portal") || project.getPackaging().equals("exo-portlet")) { File deployWar = new File( project.getBasedir().toString() + "/target/" + project.getBuild().getFinalName() + ".war"); copyFileToDirectory(deployWar, dirWar); printMessage("deploy", " Deployed file '" + project.getArtifactId() + "' to " + dirWar.getPath()); counter++; } } printMessage("deploy", " TOTAL DEPLOY : " + counter + " project"); }
From source file:org.exoplatform.maven2.plugin.Utils.java
License:Open Source License
private static boolean checkTypes(MavenProject project) { if (project.getPackaging().equals("war") || project.getPackaging().equals("exopc-war") || project.getPackaging().equals("ear")) { return true; }// ww w . j a v a 2s . c o m return false; }