List of usage examples for org.apache.maven.project MavenProject getVersion
public String getVersion()
From source file:com.github.maven_nar.NarLayout30.java
License:Apache License
public File getNoArchDirectory(File baseDir, MavenProject project) { return new File(baseDir, project.getArtifactId() + "-" + project.getVersion() + "-" + NarConstants.NAR_NO_ARCH); }
From source file:com.github.maven_nar.NarLayout30.java
License:Apache License
private File getAolDirectory(File baseDir, MavenProject project, String aol, String type) { return new File(baseDir, project.getArtifactId() + "-" + project.getVersion() + "-" + aol + "-" + type); }
From source file:com.google.gdt.eclipse.maven.configurators.MavenProjectConfigurator.java
License:Open Source License
/** * Save the settings for the GWT nature in the application GWT preferences. * * @param project//from w ww.j av a2 s . c o m * @param mavenProject * @param mavenConfig * @throws BackingStoreException */ private void persistGwtNatureSettings(IProject project, MavenProject mavenProject, Xpp3Dom mavenConfig) throws BackingStoreException { IPath warOutDir = getWarOutDir(project, mavenProject); WebAppProjectProperties.setWarSrcDir(project, getWarSrcDir(mavenProject, mavenConfig)); // src/main/webapp WebAppProjectProperties.setWarSrcDirIsOutput(project, getLaunchFromHere(mavenConfig)); // false // TODO the extension should be used, from WarArgProcessor WebAppProjectProperties.setLastUsedWarOutLocation(project, warOutDir); WebAppProjectProperties.setGwtMavenModuleName(project, getGwtModuleName(mavenProject)); WebAppProjectProperties.setGwtMavenModuleShortName(project, getGwtModuleShortName(mavenProject)); String message = "MavenProjectConfiguratior Maven: Success with setting up GWT Nature\n"; message += "\tartifactId=" + mavenProject.getArtifactId() + "\n"; message += "\tversion=" + mavenProject.getVersion() + "\n"; message += "\twarOutDir=" + warOutDir; Activator.log(message); }
From source file:com.google.gdt.eclipse.maven.configurators.MavenProjectConfigurator.java
License:Open Source License
/** * Get the war output directory.//from ww w .j av a 2s. c o m * * @param project * @param mavenProject * @return returns the war output path */ private IPath getWarOutDir(IProject project, MavenProject mavenProject) { String artifactId = mavenProject.getArtifactId(); String version = mavenProject.getVersion(); IPath locationOfProject = (project.getRawLocation() != null ? project.getRawLocation() : project.getLocation()); IPath warOut = null; // Default directory target/artifact-version if (locationOfProject != null && artifactId != null && version != null) { warOut = locationOfProject.append("target").append(artifactId + "-" + version); } // Get the GWT Maven plugin 1 <hostedWebapp/> directory if (isGwtMavenPlugin1(mavenProject) && getGwtMavenPluginHostedWebAppDirectory(mavenProject) != null) { warOut = getGwtMavenPluginHostedWebAppDirectory(mavenProject); } // Get the Gwt Maven plugin 1 <webappDirectory/> if (isGwtMavenPlugin2(mavenProject) && getGwtPlugin2WebAppDirectory(mavenProject) != null) { warOut = getGwtPlugin2WebAppDirectory(mavenProject); } // Get the maven war plugin <webappDirectory/> if (getMavenWarPluginWebAppDirectory(mavenProject) != null) { warOut = getMavenWarPluginWebAppDirectory(mavenProject); } // make the directory if it doesn't exist if (warOut != null) { warOut.toFile().mkdirs(); } return warOut; }
From source file:com.google.gdt.eclipse.maven.e35.configurators.GoogleProjectConfigurator.java
License:Open Source License
@Override protected void doConfigure(final MavenProject mavenProject, IProject project, ProjectConfigurationRequest request, final IProgressMonitor monitor) throws CoreException { final IMaven maven = MavenPlugin.getDefault().getMaven(); boolean configureGaeNatureSuccess = configureNature(project, mavenProject, GaeNature.NATURE_ID, true, new NatureCallbackAdapter() { @Override//from w w w. jav a 2s . c o m public void beforeAddingNature() { try { DefaultMavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); executionRequest.setBaseDirectory(mavenProject.getBasedir()); executionRequest.setLocalRepository(maven.getLocalRepository()); executionRequest.setRemoteRepositories(mavenProject.getRemoteArtifactRepositories()); executionRequest .setPluginArtifactRepositories(mavenProject.getPluginArtifactRepositories()); executionRequest.setPom(mavenProject.getFile()); executionRequest.setGoals(GAE_UNPACK_GOAL); MavenExecutionResult result = maven.execute(executionRequest, monitor); if (result.hasExceptions()) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error configuring project", result.getExceptions().get(0))); } } catch (CoreException e) { Activator.getDefault().getLog().log( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error configuring project", e)); } } }, monitor); boolean configureGWTNatureSuccess = configureNature(project, mavenProject, GWTNature.NATURE_ID, true, new NatureCallbackAdapter() { @Override public void beforeAddingNature() { // Get the GWT version from the project pom String gwtVersion = null; List<Dependency> dependencies = mavenProject.getDependencies(); for (Dependency dependency : dependencies) { if (GWTMavenRuntime.MAVEN_GWT_GROUP_ID.equals(dependency.getGroupId()) && (GWTMavenRuntime.MAVEN_GWT_USER_ARTIFACT_ID .equals(dependency.getArtifactId()) || GWTMavenRuntime.MAVEN_GWT_SERVLET_ARTIFACT_ID .equals(dependency.getArtifactId()))) { gwtVersion = dependency.getVersion(); break; } } // Check that the pom.xml has GWT dependencies if (!StringUtilities.isEmpty(gwtVersion)) { try { /* * Download and install the gwt-dev.jar into the local * repository. */ maven.resolve(GWTMavenRuntime.MAVEN_GWT_GROUP_ID, GWTMavenRuntime.MAVEN_GWT_DEV_JAR_ARTIFACT_ID, gwtVersion, "jar", null, mavenProject.getRemoteArtifactRepositories(), monitor); } catch (CoreException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error configuring project", e)); } } } }, monitor); if (configureGWTNatureSuccess || configureGaeNatureSuccess) { try { // Add GWT Web Application configuration parameters WebAppProjectProperties.setWarSrcDir(project, new Path("src/main/webapp")); WebAppProjectProperties.setWarSrcDirIsOutput(project, false); String artifactId = mavenProject.getArtifactId(); String version = mavenProject.getVersion(); IPath location = (project.getRawLocation() != null ? project.getRawLocation() : project.getLocation()); if (location != null && artifactId != null && version != null) { WebAppProjectProperties.setLastUsedWarOutLocation(project, location.append("target").append(artifactId + "-" + version)); } } catch (BackingStoreException be) { Activator.getDefault().getLog() .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error configuring project", be)); } } }
From source file:com.greenpepper.maven.runner.resolver.FileResolver.java
License:Open Source License
/** {@inheritDoc} */ public final File resolve(String value) throws ProjectBuildingException { File projectFile = new File(value); MavenProject mavenProject = embedder.readProject(projectFile); mavenGAV = new ProjectFileResolver.MavenGAV(mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion()); mavenGAV.setPackaging(mavenProject.getPackaging()); return projectFile; }
From source file:com.groupcdg.maven.tidesdk.GenerateMojo.java
License:Apache License
private Collection<String> createXml() { return new ArrayList<String>() { {//from w w w . java 2s. c o m add("<?xml version='1.0' encoding='UTF-8'?>"); add("<ti:app xmlns:ti='http://ti.appcelerator.org'>"); MavenProject project = getProject(); add("<id>" + project.getGroupId() + '.' + project.getArtifactId() + "</id>"); add("<name>" + getName() + "</name>"); add("<version>" + project.getVersion() + "</version>"); String publisher = getPublisher(project); if (publisher != null) { add("<publisher>" + publisher + "</publisher>"); add("<copyright>" + Calendar.getInstance().get(Calendar.YEAR) + " " + publisher + "</copyright>"); } String url = getUrl(project); if (url != null) add("<url>" + url + "</url>"); String icon = getIcon(); if (icon != null) add("<icon>" + icon + "</icon>"); addAll(getDisplay().createXml(getName(), getIndex())); add("</ti:app>"); } }; }
From source file:com.helger.maven.buildinfo.GenerateBuildInfoMojo.java
License:Apache License
private Map<String, String> _determineBuildInfoProperties() { // Get the current time, using the time zone specified in the settings final DateTime aDT = PDTFactory.getCurrentDateTime(); // Build the default properties final Map<String, String> aProps = new LinkedHashMap<String, String>(); // Version 1: initial // Version 2: added dependency information; added per build plugin the key // property/*w w w . j a va2 s . c o m*/ aProps.put("buildinfo.version", "2"); // Project information aProps.put("project.groupid", project.getGroupId()); aProps.put("project.artifactid", project.getArtifactId()); aProps.put("project.version", project.getVersion()); aProps.put("project.name", project.getName()); aProps.put("project.packaging", project.getPackaging()); // Parent project information (if available) final MavenProject aParentProject = project.getParent(); if (aParentProject != null) { aProps.put("parentproject.groupid", aParentProject.getGroupId()); aProps.put("parentproject.artifactid", aParentProject.getArtifactId()); aProps.put("parentproject.version", aParentProject.getVersion()); aProps.put("parentproject.name", aParentProject.getName()); } // All reactor projects (nested projects) // Don't emit this, if this is "1" as than only the current project would be // listed if (reactorProjects != null && reactorProjects.size() != 1) { final String sPrefix = "reactorproject."; // The number of reactor projects aProps.put(sPrefix + "count", Integer.toString(reactorProjects.size())); // Show details of all reactor projects, index starting at 0 int nIndex = 0; for (final MavenProject aReactorProject : reactorProjects) { aProps.put(sPrefix + nIndex + ".groupid", aReactorProject.getGroupId()); aProps.put(sPrefix + nIndex + ".artifactid", aReactorProject.getArtifactId()); aProps.put(sPrefix + nIndex + ".version", aReactorProject.getVersion()); aProps.put(sPrefix + nIndex + ".name", aReactorProject.getName()); ++nIndex; } } // Build Plugins final List<?> aBuildPlugins = project.getBuildPlugins(); if (aBuildPlugins != null) { final String sPrefix = "build.plugin."; // The number of build plugins aProps.put(sPrefix + "count", Integer.toString(aBuildPlugins.size())); // Show details of all plugins, index starting at 0 int nIndex = 0; for (final Object aObj : aBuildPlugins) { final Plugin aPlugin = (Plugin) aObj; aProps.put(sPrefix + nIndex + ".groupid", aPlugin.getGroupId()); aProps.put(sPrefix + nIndex + ".artifactid", aPlugin.getArtifactId()); aProps.put(sPrefix + nIndex + ".version", aPlugin.getVersion()); final Object aConfiguration = aPlugin.getConfiguration(); if (aConfiguration != null) { // Will emit an XML structure! aProps.put(sPrefix + nIndex + ".configuration", aConfiguration.toString()); } aProps.put(sPrefix + nIndex + ".key", aPlugin.getKey()); ++nIndex; } } // Build dependencies final List<?> aDependencies = project.getDependencies(); if (aDependencies != null) { final String sDepPrefix = "dependency."; // The number of build plugins aProps.put(sDepPrefix + "count", Integer.toString(aDependencies.size())); // Show details of all dependencies, index starting at 0 int nDepIndex = 0; for (final Object aDepObj : aDependencies) { final Dependency aDependency = (Dependency) aDepObj; aProps.put(sDepPrefix + nDepIndex + ".groupid", aDependency.getGroupId()); aProps.put(sDepPrefix + nDepIndex + ".artifactid", aDependency.getArtifactId()); aProps.put(sDepPrefix + nDepIndex + ".version", aDependency.getVersion()); aProps.put(sDepPrefix + nDepIndex + ".type", aDependency.getType()); if (aDependency.getClassifier() != null) aProps.put(sDepPrefix + nDepIndex + ".classifier", aDependency.getClassifier()); aProps.put(sDepPrefix + nDepIndex + ".scope", aDependency.getScope()); if (aDependency.getSystemPath() != null) aProps.put(sDepPrefix + nDepIndex + ".systempath", aDependency.getSystemPath()); aProps.put(sDepPrefix + nDepIndex + ".optional", Boolean.toString(aDependency.isOptional())); aProps.put(sDepPrefix + nDepIndex + ".managementkey", aDependency.getManagementKey()); // Add all exclusions of the current dependency final List<?> aExclusions = aDependency.getExclusions(); if (aExclusions != null) { final String sExclusionPrefix = sDepPrefix + nDepIndex + ".exclusion."; // The number of build plugins aProps.put(sExclusionPrefix + "count", Integer.toString(aExclusions.size())); // Show details of all dependencies, index starting at 0 int nExclusionIndex = 0; for (final Object aExclusionObj : aExclusions) { final Exclusion aExclusion = (Exclusion) aExclusionObj; aProps.put(sExclusionPrefix + nExclusionIndex + ".groupid", aExclusion.getGroupId()); aProps.put(sExclusionPrefix + nExclusionIndex + ".artifactid", aExclusion.getArtifactId()); ++nExclusionIndex; } } ++nDepIndex; } } // Build date and time aProps.put("build.datetime", aDT.toString()); aProps.put("build.datetime.millis", Long.toString(aDT.getMillis())); aProps.put("build.datetime.date", aDT.toLocalDate().toString()); aProps.put("build.datetime.time", aDT.toLocalTime().toString()); aProps.put("build.datetime.timezone", aDT.getZone().getID()); final int nOfsMilliSecs = aDT.getZone().getOffset(aDT); aProps.put("build.datetime.timezone.offsethours", Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_HOUR)); aProps.put("build.datetime.timezone.offsetmins", Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_MINUTE)); aProps.put("build.datetime.timezone.offsetsecs", Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_SECOND)); aProps.put("build.datetime.timezone.offsetmillisecs", Integer.toString(nOfsMilliSecs)); // Emit system properties? if (withAllSystemProperties || CollectionHelper.isNotEmpty(selectedSystemProperties)) for (final Map.Entry<String, String> aEntry : CollectionHelper .getSortedByKey(SystemProperties.getAllProperties()).entrySet()) { final String sName = aEntry.getKey(); if (withAllSystemProperties || _matches(selectedSystemProperties, sName)) if (!_matches(ignoredSystemProperties, sName)) aProps.put("systemproperty." + sName, aEntry.getValue()); } // Emit environment variable? if (withAllEnvVars || CollectionHelper.isNotEmpty(selectedEnvVars)) for (final Map.Entry<String, String> aEntry : CollectionHelper.getSortedByKey(System.getenv()) .entrySet()) { final String sName = aEntry.getKey(); if (withAllEnvVars || _matches(selectedEnvVars, sName)) if (!_matches(ignoredEnvVars, sName)) aProps.put("envvar." + sName, aEntry.getValue()); } return aProps; }
From source file:com.kamomileware.maven.plugin.opencms.packaging.ClassesPackagingTask.java
License:Apache License
protected void generateJarArchive(ModulePackagingContext context) throws MojoExecutionException { MavenProject project = context.getProject(); ArtifactFactory factory = context.getArtifactFactory(); Artifact artifact = factory.createBuildArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "jar"); String archiveName = null;//from w w w . ja va 2 s . c om try { archiveName = getArtifactFinalName(context, artifact); } catch (InterpolationException e) { throw new MojoExecutionException("Could not get the final name of the artifact[" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "]", e); } final String targetFilename = LIB_PATH + archiveName; if (context.getModuleStructure().registerFile("currentBuild", targetFilename)) { File base = context.getModuleSourceTargetDirectory() == null ? context.getModuleDirectory() : new File(context.getModuleDirectory(), context.getModuleSourceTargetDirectory()); final File libDirectory = new File(base, LIB_PATH); final File jarFile = new File(libDirectory, archiveName); final ClassesPackager packager = new ClassesPackager(); packager.packageClasses(context.getClassesDirectory(), jarFile, context.getJarArchiver(), project, context.getArchive()); } else { context.getLog().warn( "Could not generate archive classes file[" + targetFilename + "] has already been copied."); } }
From source file:com.monday_consulting.maven.plugins.fsm.DependencyToXMLMojo.java
License:Apache License
/** * Log Projects and their resolved dependencies via MavenProject.getArtifacts(). * * @param reactorProjects MavenProjects in the current reactor *//*from ww w . jav a 2 s . c om*/ private void checkReactor(final List<MavenProject> reactorProjects) { for (final MavenProject reactorProject : reactorProjects) { final String msg = "Check resolved Artifacts for: " + "\ngroudId: " + reactorProject.getGroupId() + "\nartifactId: " + reactorProject.getArtifactId() + "\nversion: " + reactorProject.getVersion(); if (getLog().isDebugEnabled()) getLog().debug(msg); if (reactorProject.getArtifacts() == null || reactorProject.getArtifacts().isEmpty()) { if (getLog().isDebugEnabled()) getLog().debug("+ Dependencies not resolved or Reactor-Project has no dependencies!"); } else { for (final Artifact artifact : reactorProject.getArtifacts()) { if (getLog().isDebugEnabled()) getLog().debug(" + " + artifact.getGroupId() + " : " + artifact.getArtifactId() + " : " + artifact.getVersion() + " : " + artifact.getType() + " : " + artifact.getFile()); } } } }