List of usage examples for org.apache.maven.project MavenProject getProperties
public Properties getProperties()
From source file:de.bbe_consulting.mavento.helper.MavenUtil.java
License:Apache License
/** * Extracts all compile dependencies.//from www. ja va 2s . c om * * @param targetDirectory * @param project * @param logger * @throws MojoExecutionException * @throws IOException */ public static void extractCompileDependencies(String targetDirectory, MavenProject project, Log logger) throws MojoExecutionException, IOException { final Set<Artifact> projectDependencies = project.getDependencyArtifacts(); FileUtil.createDirectories(targetDirectory, true); final Properties p = project.getProperties(); final String testId = (String) p.get("magento.test.artifact.id"); final String testGroupdId = (String) p.get("magento.test.artifact.group.id"); final String testVersion = (String) p.get("magento.test.artifact.version"); if (testId == null && testGroupdId == null && testVersion == null) { throw new MojoExecutionException("Error: One of the magento.test.artifact.* properties" + " is not defined. Please fix your pom.xml."); } // cycle through project dependencies for (Iterator<Artifact> artifactIterator = projectDependencies.iterator(); artifactIterator.hasNext();) { Artifact artifact = artifactIterator.next(); if ("compile".equals(artifact.getScope())) { if (!artifact.getArtifactId().equals(testId) && !artifact.getGroupId().equals(testGroupdId) && !artifact.getVersion().equals(testVersion)) { logger.info("Extracting " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ".."); String artifactPath = artifact.getFile().getPath(); FileUtil.unzipFile(artifactPath, targetDirectory); } } } }
From source file:de.bbe_consulting.mavento.helper.MavenUtil.java
License:Apache License
/** * Filter pom.xml properties for magento.config entries and convert them into * magento core_config format./*from w w w . j av a2s . c om*/ * * @param project * @param tokenMap * @param logger * @return Map<String, String> tokenMap with added magento.misc properties */ public static Map<String, String> addMagentoMiscProperties(MavenProject project, Map<String, String> tokenMap, Log logger) { final Properties p = project.getProperties(); for (Enumeration<?> e = p.keys(); e.hasMoreElements();) { String propertyKey = (String) e.nextElement(); if (propertyKey.startsWith("magento.config.")) { String finalToken = propertyKey.substring("magento.config.".length()).replace(".", "/"); tokenMap.put(finalToken, p.getProperty(propertyKey)); } } return tokenMap; }
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);/*from w w w.ja va 2 s . 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.builtin.CopyBWSourcesMojo.java
License:Apache License
private boolean isContainerEnabled(MavenProject p) { if (p == null) { return false; }/* ww w . java2s . c o m*/ String isContainer = p.getProperties().getProperty("bw.container"); return (isContainer != null && isContainer.equals("true")); }
From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.pom.GenerateRootDeploymentPOM.java
License:Apache License
private MavenProject isProjectActive(Model model, List<MavenProject> activeProjects) { for (MavenProject mavenProject : activeProjects) { String packageSkipProperty = mavenProject.getProperties().getProperty("bw.package.skip"); boolean packageSkip = packageSkipProperty != null && packageSkipProperty.equals("true"); if ((mavenProject.getGroupId().equals(model.getGroupId()) || (model.getGroupId() == null)) && // == null in case of [inherited] value mavenProject.getArtifactId().equals(model.getArtifactId()) && (mavenProject.getVersion().equals(model.getVersion()) || (model.getVersion() == null)) && // == null in case of [inherited] value !packageSkip) {//from w ww . j a v a 2s . c o m return mavenProject; } } return null; }
From source file:info.gianlucacosta.jythonmvn.JythonRun.java
License:Apache License
private ScriptEngine createScriptEngine() { ScriptEngine engine = new ScriptEngineManager().getEngineByName("python"); MavenProject project = (MavenProject) getPluginContext().get("project"); engine.put("project", project); Properties properties = project.getProperties(); engine.put("properties", properties); return engine; }
From source file:info.ronjenkins.maven.rtr.RTRConfig.java
License:Apache License
private static String getProperty(final String prop, final MavenSession session, final MavenProject project) { if (session == null) { return project.getProperties().getProperty(prop); } else if (project == null) { return session.getUserProperties().getProperty(prop); } else {/* w w w. j a va2 s . c om*/ return StringUtils.defaultString(session.getUserProperties().getProperty(prop), project.getProperties().getProperty(prop)); } }
From source file:io.fabric8.maven.AbstractFabric8Mojo.java
License:Apache License
protected Properties getProjectAndFabric8Properties(MavenProject project) { Properties properties = project.getProperties(); properties.putAll(project.getProperties()); // let system properties override so we can read from the command line properties.putAll(System.getProperties()); return properties; }
From source file:io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler.java
License:Apache License
@Override public List<ImageConfiguration> resolve(ImageConfiguration config, MavenProject project, MavenSession session) throws IllegalArgumentException { String prefix = getPrefix(config); Properties properties = project.getProperties(); RunImageConfiguration run = extractRunConfiguration(prefix, properties); BuildImageConfiguration build = extractBuildConfiguration(prefix, properties); WatchImageConfiguration watch = extractWatchConfig(prefix, properties); String name = extractName(prefix, properties); String alias = withPrefix(prefix, ALIAS, properties); return Collections.singletonList( new ImageConfiguration.Builder().name(name).alias(alias != null ? alias : config.getAlias()) .runConfig(run).buildConfig(build).watchConfig(watch).build()); }
From source file:io.fabric8.maven.enricher.api.BaseEnricher.java
License:Apache License
/** * Returns true if we are in OpenShift S2I binary building mode *//*w ww . j a va 2 s . co m*/ protected boolean isOpenShiftMode() { MavenProject project = getProject(); if (project != null) { Properties properties = project.getProperties(); if (properties != null) { return PlatformMode.isOpenShiftMode(properties); } } return false; }