List of usage examples for org.apache.maven.project MavenProject setContextValue
public void setContextValue(String key, Object value)
From source file:org.apache.sling.maven.slingstart.ProjectHelper.java
License:Apache License
/** * Get the effective model from the project * @param project The maven projet/*from w w w.java2 s . co m*/ * @return The effective model * @throws MojoExecutionException If reading fails */ public static Model getEffectiveModel(final MavenProject project, ResolverOptions resolverOptions) throws MojoExecutionException { Model result = (Model) project.getContextValue(EFFECTIVE_MODEL_CACHE); if (result == null) { try { final StringReader r = new StringReader((String) project.getContextValue(EFFECTIVE_MODEL_TXT)); result = ModelReader.read(r, project.getId()); result = ModelUtility.getEffectiveModel(result, resolverOptions); project.setContextValue(EFFECTIVE_MODEL_CACHE, result); } catch (final IOException ioe) { throw new MojoExecutionException(ioe.getMessage(), ioe); } } return result; }
From source file:org.apache.sling.maven.slingstart.ProjectHelper.java
License:Apache License
/** * Get the raw model from the project//from ww w .j a v a 2 s. c o m * @param project The maven projet * @return The raw local model * @throws MojoExecutionException If reading fails */ public static Model getRawModel(final MavenProject project) throws MojoExecutionException { Model result = (Model) project.getContextValue(RAW_MODEL_CACHE); if (result == null) { try { final StringReader r = new StringReader((String) project.getContextValue(RAW_MODEL_TXT)); result = ModelReader.read(r, project.getId()); project.setContextValue(RAW_MODEL_CACHE, result); } catch (final IOException ioe) { throw new MojoExecutionException(ioe.getMessage(), ioe); } } return result; }
From source file:org.eclipse.ebr.tycho.extras.plugin.RecipeBundleProject.java
License:Open Source License
@Override public void setupProject(final MavenSession session, final MavenProject project) { // FIXME this might not work, i.e. a manifest might not exist yet // instead we should build the ArtifactKey based on known values (POM) final ArtifactKey key = getManifest(project).toArtifactKey(); project.setContextValue(CTX_ARTIFACT_KEY, key); }
From source file:org.eclipse.m2e.core.internal.embedder.MavenProjectMutableState.java
License:Open Source License
public static MavenProjectMutableState takeSnapshot(MavenProject project) { MavenProjectMutableState snapshot = new MavenProjectMutableState(); if (project.getContextValue(CTX_SNAPSHOT) == null) { snapshot.compileSourceRoots = new ArrayList<String>(project.getCompileSourceRoots()); snapshot.testCompileSourceRoots = new ArrayList<String>(project.getTestCompileSourceRoots()); snapshot.resources = new ArrayList<Resource>(project.getResources()); snapshot.testResources = new ArrayList<Resource>(project.getTestResources()); snapshot.properties = new Properties(); snapshot.properties.putAll(project.getProperties()); project.setContextValue(CTX_SNAPSHOT, Boolean.TRUE); snapshot.nested = false;/* ww w .j ava2 s.c om*/ } return snapshot; }
From source file:org.eclipse.m2e.core.internal.embedder.MavenProjectMutableState.java
License:Open Source License
public void restore(MavenProject project) { if (nested) { return;/*from w ww . ja v a 2 s . co m*/ } setElements(project.getCompileSourceRoots(), compileSourceRoots); setElements(project.getTestCompileSourceRoots(), testCompileSourceRoots); setElements(project.getResources(), resources); setElements(project.getTestResources(), testResources); if (properties != null) { project.getProperties().clear(); project.getProperties().putAll(properties); } project.setContextValue(CTX_SNAPSHOT, null); }
From source file:org.eclipse.tycho.core.osgitools.AbstractTychoProject.java
License:Open Source License
public void setDependencyArtifacts(MavenSession session, MavenProject project, DependencyArtifacts dependencyArtifacts) { project.setContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS, dependencyArtifacts); }
From source file:org.eclipse.tycho.core.osgitools.AbstractTychoProject.java
License:Open Source License
public void setTargetPlatform(MavenProject project, TargetPlatform targetPlatform) { project.setContextValue(TychoConstants.CTX_TARGET_PLATFORM, targetPlatform); }
From source file:org.eclipse.tycho.core.osgitools.DefaultReactorProject.java
License:Open Source License
public static ReactorProject adapt(MavenProject project) { if (project == null) { return null; }/*from www. j ava 2s.c o m*/ ReactorProject reactorProject = (ReactorProject) project.getContextValue(CTX_REACTOR_PROJECT); if (reactorProject == null) { reactorProject = new DefaultReactorProject(project); project.setContextValue(CTX_REACTOR_PROJECT, reactorProject); } return reactorProject; }
From source file:org.eclipse.tycho.core.osgitools.OsgiBundleProject.java
License:Open Source License
@Override public void setupProject(MavenSession session, MavenProject project) { ArtifactKey key = readArtifactKey(project.getBasedir()); if (key == null) { throw new IllegalArgumentException( "Missing bundle symbolic name or version for project " + project.toString()); }/*from w ww .ja va 2 s .c o m*/ project.setContextValue(CTX_ARTIFACT_KEY, key); }
From source file:org.eclipse.tycho.core.osgitools.OsgiBundleProject.java
License:Open Source License
@Override public void resolveClassPath(MavenSession session, MavenProject project) { DependencyArtifacts artifacts = getDependencyArtifacts(project); State state = getResolverState(project, artifacts); if (getLogger().isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) { getLogger().debug(resolver.toDebugString(state)); }//from w ww .ja va 2s. co m BundleDescription bundleDescription; try { bundleDescription = state.getBundleByLocation(project.getBasedir().getCanonicalPath()); } catch (IOException e) { throw new RuntimeException(e); } List<ClasspathEntry> classpath = new ArrayList<ClasspathEntry>(); // project itself ArtifactDescriptor artifact = getArtifact(artifacts, project.getBasedir(), bundleDescription.getSymbolicName()); ReactorProject projectProxy = DefaultReactorProject.adapt(project); List<File> projectClasspath = getThisProjectClasspath(artifact, projectProxy); classpath.add(new DefaultClasspathEntry(projectProxy, artifact.getKey(), projectClasspath, null)); // build.properties/jars.extra.classpath addExtraClasspathEntries(classpath, projectProxy, artifacts); // dependencies for (DependencyEntry entry : dependencyComputer.computeDependencies(state.getStateHelper(), bundleDescription)) { File location = new File(entry.desc.getLocation()); ArtifactDescriptor otherArtifact = getArtifact(artifacts, location, entry.desc.getSymbolicName()); ReactorProject otherProject = otherArtifact.getMavenProject(); List<File> locations; if (otherProject != null) { locations = getOtherProjectClasspath(otherArtifact, otherProject, null); } else { locations = getBundleClasspath(otherArtifact); } if (locations.isEmpty() && !entry.rules.isEmpty()) { getLogger().warn("Empty classpath of required bundle " + otherArtifact); } classpath.add(new DefaultClasspathEntry(otherProject, otherArtifact.getKey(), locations, entry.rules)); } project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_CLASSPATH, classpath); project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_BOOTCLASSPATH_EXTRA_ACCESSRULES, dependencyComputer.computeBootClasspathExtraAccessRules(state.getStateHelper(), bundleDescription)); addPDESourceRoots(project); }