List of usage examples for org.apache.maven.project MavenProject getProjectBuildingRequest
@Deprecated
public ProjectBuildingRequest getProjectBuildingRequest()
From source file:com.github.htfv.maven.plugins.buildconfigurator.core.configurators.propertyfiles.PropertyFileConfigurator.java
License:Apache License
/** * Updates project properties. Properties are immutable - if there is * already a user or a project property with the same key defined, it will * not be overwritten.//ww w. ja va 2 s.c o m * * @param ctx * The configuration context. * @param resultBuilder * The result builder. */ private void updateProjectProperties(final ConfigurationContext ctx, final Result.Builder resultBuilder) { final Configuration properties = ctx.getProperties(); final MavenProject project = ctx.getProject(); final Properties projectProperties = project.getProperties(); final Properties userProperties = project.getProjectBuildingRequest().getUserProperties(); @SuppressWarnings("unchecked") final Iterator<String> keys = properties.getKeys(); while (keys.hasNext()) { final String key = keys.next(); if (userProperties.containsKey(key) || projectProperties.containsKey(key)) { continue; } final String value = ctx.getStringValue(properties.getString(key)); projectProperties.setProperty(key, value); resultBuilder.newProperty(key, value); } }
From source file:com.github.htfv.maven.plugins.eclipseconfigurator.utils.ECELUtils.java
License:Apache License
public static ELContext createELContext(final MavenProject mavenProject) { final Map<String, Object> implicitObjects = new HashMap<String, Object>(); implicitObjects.put("project", mavenProject); return createELContext(new MapPropertySource(implicitObjects), new PropertiesPropertySource(mavenProject.getProjectBuildingRequest().getUserProperties()), new PropertiesPropertySource(mavenProject.getProperties())); }
From source file:com.inetpsa.seed.plugin.components.ArtifactResolver.java
License:Open Source License
public String getHighestVersion(MavenProject mavenProject, String groupId, String artifactId, boolean allowSnapshots) { RepositorySystemSession session = mavenProject.getProjectBuildingRequest().getRepositorySession(); VersionRangeRequest rangeRequest = new VersionRangeRequest(); rangeRequest.setArtifact(new DefaultArtifact(groupId, artifactId, null, "[0,)")); rangeRequest.setRepositories(mavenProject.getRemoteProjectRepositories()); VersionRangeResult rangeResult;//from ww w .ja v a 2s . c o m try { rangeResult = repositorySystem.resolveVersionRange(session, rangeRequest); } catch (Exception e) { throw new RuntimeException(String.format("Unable to resolve version for %s:%s", groupId, artifactId), e); } Version highestVersion = null; for (Version version : rangeResult.getVersions()) { if (highestVersion == null) { highestVersion = version; } else if ((allowSnapshots || !version.toString().endsWith("-SNAPSHOT")) && version.compareTo(highestVersion) > 0) { highestVersion = version; } } if (highestVersion == null) { throw new RuntimeException(String.format("No version found for artifact %s:%s", groupId, artifactId)); } return highestVersion.toString(); }
From source file:com.inetpsa.seed.plugin.components.ArtifactResolver.java
License:Open Source License
public ArtifactResult resolveArtifact(MavenProject mavenProject, String groupId, String artifactId, String type, String classifier, String version) throws ArtifactResolutionException { RepositorySystemSession session = mavenProject.getProjectBuildingRequest().getRepositorySession(); String coordinates = groupId + ":" + artifactId; if (type != null && !type.isEmpty()) { coordinates += ":" + type; }/* w ww. ja v a2s.co m*/ if (classifier != null && !classifier.isEmpty()) { coordinates += ":" + classifier; } if (version != null && !version.isEmpty()) { coordinates += ":" + version; } return repositorySystem.resolveArtifact(session, new ArtifactRequest(new DefaultArtifact(coordinates), mavenProject.getRemoteProjectRepositories(), null)); }
From source file:com.inetpsa.seed.plugin.components.ArtifactResolver.java
License:Open Source License
public List<ArtifactResult> resolveTransitiveArtifacts(MavenProject mavenProject, Artifact artifact, List<Dependency> managedDependencies, DependencyFilter dependencyFilter) throws DependencyResolutionException { RepositorySystemSession session = mavenProject.getProjectBuildingRequest().getRepositorySession(); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE)); if (managedDependencies != null) { collectRequest.setManagedDependencies(managedDependencies); }/*from w w w. j av a2 s. c om*/ return repositorySystem .resolveDependencies(session, new DependencyRequest(collectRequest, dependencyFilter)) .getArtifactResults(); }
From source file:hudson.gridmaven.reporters.MavenFingerprinter.java
License:Open Source License
private ArtifactRepository getLocalRepository(MavenBuildInformation mavenBuildInformation, MavenProject parent, MavenProject pom) {// w ww.j av a 2s.c om if (mavenBuildInformation.isMaven3OrLater()) { return parent.getProjectBuildingRequest().getLocalRepository(); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.2")) { // principally this should also work with Maven 2.1, but it's not tested, so err on the safe side return getArtifactRepositoryMaven21(pom); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.0")) { // Maven 2.0 has no corresponding mechanism return null; } else { LOGGER.warning("Unknown Maven version: " + mavenBuildInformation.getMavenVersion()); return null; } }
From source file:hudson.maven.reporters.MavenFingerprinter.java
License:Open Source License
private ArtifactRepository getLocalRepository(MavenBuildInformation mavenBuildInformation, MavenProject pom) { if (mavenBuildInformation.isMaven3OrLater()) { return pom.getProjectBuildingRequest().getLocalRepository(); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.2")) { // principally this should also work with Maven 2.1, but it's not tested, so err on the safe side return getArtifactRepositoryMaven21(pom); } else if (mavenBuildInformation.isAtLeastMavenVersion("2.0")) { // Maven 2.0 has no corresponding mechanism return null; } else {// w w w .j a v a 2s . c o m LOGGER.warning("Unknown Maven version: " + mavenBuildInformation.getMavenVersion()); return null; } }
From source file:org.dugilos.m2e.nar.internal.NarPluginConfiguration.java
License:Open Source License
public NarPluginConfiguration(IProject project, MavenProject mavenProject, String pluginId, Log log) throws CoreException { this.mavenProject = mavenProject; this.pluginId = pluginId; // extract local repository (containing nar files dependencies) ProjectBuildingRequest buildingRequest = mavenProject.getProjectBuildingRequest(); ArtifactRepository artifactRepository = buildingRequest.getLocalRepository(); // extract project directories absoluteProjectBaseDir = project.getLocation().toFile(); projectBuildDirectory = mavenProject.getBuild().getDirectory(); // extract com.github.maven-nar:nar-maven-plugin plugin narMavenPlugin = getNarMavenPlugin(mavenProject); MgtNarMavenPlugin = getMgtNarMavenPlugin(mavenProject); // If the plugin isn't used in the project, it's useless to go further if (narMavenPlugin == null) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, "Plugin " + NAR_MAVEN_PLUGIN_GROUPID + ":" + NAR_MAVEN_PLUGIN_ARTIFACTID + " not found"); throw new CoreException(status); }//from w ww . ja va 2 s. c om String arch = NarUtil.getArchitecture(null); String os = NarUtil.getOS(null); String aolPrefix = arch + "." + os + "."; NarProperties narProperties = null; try { narProperties = NarProperties.getInstance(mavenProject); } catch (MojoFailureException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } String configLinkerName = getConfigurationLinkerName(); linker = new Linker(configLinkerName, log); // if configLinkerName is null we call getName(NarProperties properties, String prefix) to initialise the name from AOL if (configLinkerName == null) { try { linker.getName(narProperties, aolPrefix); } catch (MojoFailureException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } catch (MojoExecutionException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } } try { narManager = new NarManager(log, artifactRepository, mavenProject, arch, os, linker); } catch (MojoFailureException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } catch (MojoExecutionException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } try { aol = NarUtil.getAOL(mavenProject, arch, os, linker, null, log); } catch (MojoFailureException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } catch (MojoExecutionException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } String layoutName = getLayoutName(); try { narLayout = AbstractNarLayout.getLayout(layoutName, log); } catch (MojoExecutionException e) { int severity = IStatus.ERROR; Status status = new Status(severity, pluginId, e.getMessage(), e); throw new CoreException(status); } }
From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java
License:Open Source License
/** * Makes MavenProject instances returned by #readProject methods suitable for caching and reuse with other * MavenSession instances.<br/>//from ww w .j a v a 2s .co m * Do note that MavenProject.getParentProject() cannot be used for detached MavenProject instances. Use * #resolveParentProject to resolve parent project instance. */ public void detachFromSession(MavenProject project) throws CoreException { project.getProjectBuildingRequest().setRepositorySession(lookup(ContextRepositorySystemSession.class)); }
From source file:org.hudsonci.maven.eventspy_30.handler.ProfileLogger.java
License:Open Source License
@SuppressWarnings("unused") public static void log(final ExecutionEvent event) { if (disabled) return;// ww w .ja v a 2 s . co m for (MavenProject project : event.getSession().getProjects()) { log.debug("*** Examining profiles for {}.", project.getName()); logProfileList(project.getActiveProfiles(), "active"); logProfileList(project.getModel().getProfiles(), "model"); //logProfiles( event.getSession().getProjectBuildingRequest().getProfiles(), "ProjectBuildingRequest" ); logProfileList(project.getProjectBuildingRequest().getProfiles(), "ProjectBuildingRequest"); log.debug("InjectedProfileIds"); for (Entry<String, List<String>> entry : project.getInjectedProfileIds().entrySet()) { log.debug(" from {} are {}", entry.getKey(), entry.getValue()); } Settings settings = event.getSession().getSettings(); logSettingsProfileList(settings.getProfiles(), "session-settings"); log.debug("Collected projects: {}", project.getCollectedProjects()); log.debug("Project references: {}", project.getProjectReferences()); } }