List of usage examples for org.apache.maven.project MavenProject getProperties
public Properties getProperties()
From source file:org.jboss.tools.maven.apt.internal.preferences.PreferencesManager.java
License:Open Source License
private static Properties getMavenProperties(IProject project) { try {/* w w w . ja v a2s. co m*/ if (!project.isAccessible() || !project.hasNature(IMavenConstants.NATURE_ID)) { return null; } IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(project); if (facade == null) { IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME); facade = MavenPlugin.getMavenProjectRegistry().create(pom, true, new NullProgressMonitor()); } if (facade != null) { MavenProject mavenProject = facade.getMavenProject(new NullProgressMonitor()); return mavenProject.getProperties(); } } catch (CoreException ex) { log.error("Error loading maven project for " + project.getName(), ex); } return null; }
From source file:org.jboss.tools.maven.springboot.configurators.SpringBootProjectConfigurator.java
License:Open Source License
private boolean isSpringBootConfigurable(MavenProject mavenProject) { String springBootActivation = mavenProject.getProperties().getProperty(ACTIVATION_PROPERTY); boolean configureSpringBoot = false; if (springBootActivation == null) { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); configureSpringBoot = store.getBoolean(Activator.CONFIGURE_SPRING_BOOT); } else {//w ww . j a v a 2 s.com configureSpringBoot = Boolean.valueOf(springBootActivation); } return configureSpringBoot; }
From source file:org.jboss.tools.releng.NoSnapshotsAllowed.java
License:Open Source License
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException { Log log = helper.getLog();// w w w.j a v a 2 s . co m try { // get the various expressions out of the helper. MavenProject project = (MavenProject) helper.evaluate("${project}"); // MavenSession session = (MavenSession) helper.evaluate( "${session}" ); String target = (String) helper.evaluate("${project.build.directory}"); String artifactId = (String) helper.evaluate("${project.artifactId}"); // defaults if not set if (includePattern == null || includePattern.equals("")) { includePattern = ".*"; } if (excludePattern == null || excludePattern.equals("")) { excludePattern = ""; } log.debug("Search for properties matching " + SNAPSHOT + "..."); Properties projProps = project.getProperties(); Enumeration<?> e = projProps.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); // fetch from parent pom if not passed into the rule config if (buildAlias == null && key.equals("BUILD_ALIAS")) { buildAlias = projProps.getProperty(key); if (buildAlias.matches(buildAliasSearch)) { log.info("Found buildAlias = " + buildAlias + " (for buildAliasSearch = " + buildAliasSearch + ")"); } else { log.debug("Found buildAlias = " + buildAlias + " (for buildAliasSearch = " + buildAliasSearch + ")"); } } else if (key.matches(includePattern) && (excludePattern.equals("") || !key.matches(excludePattern)) && projProps.getProperty(key).indexOf(SNAPSHOT) > -1) { log.error("Found property " + key + " = " + projProps.getProperty(key)); snapshotKey = key; // } else { // log.debug("Property: "+ key + " = " + projProps.getProperty(key)); } } // // retrieve any component out of the session directly // ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class ); // RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class ); // log.debug( "Retrieved Session: " + session ); // log.debug( "Retrieved Resolver: " + resolver ); // log.debug( "Retrieved RuntimeInfo: " + rti ); log.debug("Retrieved Target Folder: " + target); log.debug("Retrieved ArtifactId: " + artifactId); log.debug("Retrieved Project: " + project); log.debug("Retrieved Project Version: " + project.getVersion()); if (buildAlias.matches(buildAliasSearch) && snapshotKey != null) { throw new EnforcerRuleException("\nWhen buildAlias (" + buildAlias + ") matches /" + buildAliasSearch + "/, cannot include " + SNAPSHOT + " dependencies.\n"); } } catch (ExpressionEvaluationException e) { throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e); } }
From source file:org.jfrog.build.extractor.maven.BuildInfoRecorder.java
License:Apache License
private void initModule(MavenProject project) { if (project == null) { logger.warn("Skipping Artifactory Build-Info module initialization: Null project."); return;// w w w .j a v a2 s. c om } ModuleBuilder module = new ModuleBuilder(); module.id(getModuleIdString(project.getGroupId(), project.getArtifactId(), project.getVersion())); module.properties(project.getProperties()); currentModule.set(module); currentModuleArtifacts.set(Collections.synchronizedSet(new HashSet<Artifact>())); currentModuleDependencies.set(Collections.synchronizedSet(new HashSet<Artifact>())); }
From source file:org.jszip.maven.RunMojo.java
License:Apache License
private long processResourceSourceChanges(List<MavenProject> reactorProjects, MavenProject project, long lastModified) throws ArtifactFilterException { long newLastModified = lastModified; getLog().debug("Last modified for resource sources = " + lastModified); Set<File> checked = new HashSet<File>(); for (Artifact a : getOverlayArtifacts(project, scope)) { MavenProject p = findProject(reactorProjects, a); if (p == null || p.getBuild() == null || p.getBuild().getResources() == null) { continue; }//w ww.j a v a 2s . co m boolean changed = false; boolean changedFiltered = false; for (org.apache.maven.model.Resource r : p.getBuild().getResources()) { File dir = new File(r.getDirectory()); getLog().debug("Checking last modified for " + dir); if (checked.contains(dir)) { continue; } checked.add(dir); long dirLastModified = recursiveLastModified(dir); if (lastModified < dirLastModified) { changed = true; if (r.isFiltering()) { changedFiltered = true; } } } if (changedFiltered) { getLog().info("Detected change in resources of " + ArtifactUtils.versionlessKey(a) + "..."); getLog().debug("Resource filtering is used by project, invoking Maven to handle update"); // need to let Maven handle it as its the only (although slower) safe way to do it right with filters InvocationRequest request = new DefaultInvocationRequest(); request.setPomFile(p.getFile()); request.setInteractive(false); request.setRecursive(false); request.setGoals(Collections.singletonList("process-resources")); Invoker invoker = new DefaultInvoker(); invoker.setLogger(new MavenProxyLogger()); try { invoker.execute(request); newLastModified = System.currentTimeMillis(); getLog().info("Change in resources of " + ArtifactUtils.versionlessKey(a) + " processed"); } catch (MavenInvocationException e) { getLog().info(e); } } else if (changed) { getLog().info("Detected change in resources of " + ArtifactUtils.versionlessKey(a) + "..."); getLog().debug("Resource filtering is not used by project, handling update ourselves"); // can do it fast ourselves MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(p.getResources(), new File(p.getBuild().getOutputDirectory()), p, p.getProperties().getProperty("project.build.sourceEncoding"), Collections.emptyList(), Collections.<String>emptyList(), session); try { mavenResourcesFiltering.filterResources(mavenResourcesExecution); newLastModified = System.currentTimeMillis(); getLog().info("Change in resources of " + ArtifactUtils.versionlessKey(a) + " processed"); } catch (MavenFilteringException e) { getLog().info(e); } } } return newLastModified; }
From source file:org.kathrynhuxtable.maven.plugins.docbkxwrapper.Merger.java
License:Apache License
/** * DOCUMENT ME!//from w w w. ja va 2s. co m * * @param inputEncoding * @param outputEncoding * @param project * * @return DOCUMENT ME! */ private AttributeMap initializeAttributes(String inputEncoding, String outputEncoding, MavenProject project) { AttributeMap attributes = new AttributeMap(); if (attributes.get("project") == null) { attributes.put("project", project); } // Put any of the properties in directly into the Velocity attributes attributes.putAll(project.getProperties()); if (attributes.get("inputEncoding") == null) { attributes.put("inputEncoding", inputEncoding); } if (attributes.get("outputEncoding") == null) { attributes.put("outputEncoding", outputEncoding); } Date date = new Date(); attributes.put("currentDate", date); attributes.put("lastPublished", new SimpleDateFormat("dd MMM yyyy").format(date)); return attributes; }
From source file:org.kuali.maven.plugins.externals.MojoHelper.java
License:Educational Community License
public void validate(MavenProject project, List<Mapping> mappings) { validate(project.getProperties(), mappings); validateModules(project.getModules(), mappings); }
From source file:org.lorislab.maven.plugin.utils.FilterUtils.java
License:Apache License
/** * Filter source file and save to the destination file. * * @param project the maven project./*from ww w .ja va2s . c om*/ * @param source the source file. * @param dest the destination file. * * @throws java.io.IOException * @throws org.apache.maven.plugin.MojoExecutionException */ public static void filter(MavenProject project, File source, File dest) throws IOException, MojoExecutionException { Properties filterProperties = new Properties(System.getProperties()); filterProperties.putAll(project.getProperties()); filter(filterProperties, source, dest); }
From source file:org.openspaces.maven.plugin.Utils.java
License:Apache License
/** * Checks if a project is a PU project.//from w w w. j a va 2 s . c o m * * @param project the project * @return true if the project is a PU project, false otherwise. */ static boolean isPUType(MavenProject project) { String gsType = project.getProperties().getProperty(Utils.GS_TYPE); if (gsType == null) { return false; } return gsType.equalsIgnoreCase(Utils.GS_TYPE_PU); }
From source file:org.ops4j.pax.construct.clone.CloneMojo.java
License:Apache License
/** * Analyze bundle project to see if it actually just wraps another artifact * /* ww w. j ava 2s .c o m*/ * @param project Maven bundle project * @return wrapped artifact, null if it isn't a wrapper project */ private Dependency findWrappee(MavenProject project) { Properties properties = project.getProperties(); Dependency wrappee = new Dependency(); // Pax-Construct v2 wrappee.setGroupId(properties.getProperty("wrapped.groupId")); wrappee.setArtifactId(properties.getProperty("wrapped.artifactId")); wrappee.setVersion(properties.getProperty("wrapped.version")); if (null == wrappee.getArtifactId()) { // original Pax-Construct wrappee.setGroupId(properties.getProperty("jar.groupId")); wrappee.setArtifactId(properties.getProperty("jar.artifactId")); wrappee.setVersion(properties.getProperty("jar.version")); if (null == wrappee.getArtifactId()) { // has someone customized their wrapper? return findCustomizedWrappee(project); } } return wrappee; }