List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:org.eclipse.tycho.target.TargetPlatformMojo.java
License:Open Source License
private boolean enterProject(MavenProject project, HashSet<GAV> consideredProjects) { GAV projectGav = new GAV(project.getGroupId(), project.getArtifactId(), project.getVersion()); if (consideredProjects.contains(projectGav)) { return false; } else {/*from w ww .j ava2s . c om*/ consideredProjects.add(projectGav); return true; } }
From source file:org.eclipse.tycho.testing.AbstractTychoMojoTestCase.java
License:Open Source License
protected MavenProject getProject(List<MavenProject> projects, String artifactId) { for (MavenProject project : projects) { if (artifactId.equals(project.getArtifactId())) { return project; }//www. j av a 2 s . c o m } throw new IllegalArgumentException("No project with artifactId " + artifactId); }
From source file:org.eclipse.virgo.ide.bundlor.internal.core.maven.MavenPropertiesSource.java
License:Open Source License
public Properties getProperties() { try {/*from w ww . j av a 2 s. c om*/ IMavenProjectRegistry registry = MavenPlugin.getMavenProjectRegistry(); IMavenProjectFacade facade = registry.create(this.project, new NullProgressMonitor()); if (facade != null) { MavenProject mavenProj = facade.getMavenProject(new NullProgressMonitor()); Properties props = mavenProj.getProperties(); // add in some special maven properties addPropertyIfNotNull(props, "project.artifactId", mavenProj.getArtifactId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.groupId", mavenProj.getGroupId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.description", mavenProj.getDescription()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.name", mavenProj.getName()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.version", mavenProj.getVersion()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.artifactId", mavenProj.getArtifactId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.groupId", mavenProj.getGroupId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.description", mavenProj.getDescription()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.name", mavenProj.getName()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.version", mavenProj.getVersion()); //$NON-NLS-1$ return props; } } catch (CoreException e) { // this exception will be reported later on as the properties can't be reported. } return EMPTY_STANDARD; }
From source file:org.eiichiro.gig.shell.Main.java
License:Open Source License
/** * @param args/*from w w w.j a va 2s .c om*/ * @throws Exception */ public static void main(String[] args) throws Exception { Shell shell = new Shell(); shell.register(new Quit(shell)); shell.register(new Exit(shell)); shell.register(new Help(shell)); shell.register(new Hint(shell)); Console console = shell.console(); console.println(Colors.blue(" ____ _")); console.println(Colors.blue(" / ___(_) __ _")); console.println(Colors.blue("| | _| |/ _` |")); console.println(Colors.blue("| |_| | | (_| |")); console.println(Colors.blue(" \\____|_|\\__, |")); console.println(Colors.blue(" |___/")); console.println(""); console.println(Colors.blue("Gig Shell " + Version.MAJOR + "." + Version.MINER + "." + Version.BUILD + " (Experimental Beta) http://gig.eiichiro.org/")); console.println(""); console.println(Colors.blue("Welcome to Gig. Hit the TAB or press 'hint' to display available commands.")); console.println(Colors.blue("Press 'help command' to display the detailed information for the command.")); console.println(Colors.blue("Press 'quit' or 'exit' to exit this session. Enjoy!")); console.println(""); String dir = Environment.getProperty("user.dir"); File pom = new File(dir + File.separator + "pom.xml"); String prompt = "gig"; if (pom.exists()) { MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader(pom)); MavenProject project = new MavenProject(model); String artifactId = project.getArtifactId(); String version = project.getVersion(); prompt = prompt + Colors.yellow(":[" + artifactId + "-" + version + "]"); File gig = new File(dir + File.pathSeparator + ".gig"); if (!gig.exists()) { gig.mkdir(); } shell.register(new Scan(shell)); } console.prompt(prompt + "> "); shell.start(); }
From source file:org.exoplatform.maven2.plugin.Utils.java
License:Open Source License
public static void deployProject(File dirJar, File dirWar, MavenProject project, boolean deployDep, HashSet<String> ignoreProjects) throws Exception { if (!dirJar.exists()) { System.out.println("The directory " + dirJar.getParent() + " does not exists !"); return;//from w ww .j a v a 2 s.co m } if (!dirWar.exists()) { System.out.println("The directory " + dirWar.getParent() + " does not exists !"); return; } int counter = 0; if (deployDep) { counter += deployedDependency(dirJar, dirWar, project, ignoreProjects).size(); } deleteFileOnExist(dirWar, project.getBuild().getFinalName()); if (project.getPackaging().equals("jar")) { counter++; File moduleFile = new File(project.getBasedir().toString() + "/target/" + project.getArtifactId() + "-" + project.getVersion() + "." + project.getPackaging()); copyFileToDirectory(moduleFile, dirJar); printMessage("deploy", " Deployed file '" + project.getArtifactId() + "' to " + dirJar.getPath()); } else { if (project.getPackaging().equals("war") || project.getPackaging().equals("exo-jcr") || project.getPackaging().equals("exo-portal") || project.getPackaging().equals("exo-portlet")) { File deployWar = new File( project.getBasedir().toString() + "/target/" + project.getBuild().getFinalName() + ".war"); copyFileToDirectory(deployWar, dirWar); printMessage("deploy", " Deployed file '" + project.getArtifactId() + "' to " + dirWar.getPath()); counter++; } } printMessage("deploy", " TOTAL DEPLOY : " + counter + " project"); }
From source file:org.exoplatform.maven2.plugin.Utils.java
License:Open Source License
public static void createManifest(File mf, MavenProject project, HashSet ignoredProjects) throws IOException { StringBuilder b = new StringBuilder(); b.append("Manifest-Version: 1.0\n"); b.append("Ant-Version: Apache Ant 1.5.3\n"); b.append("Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)\n"); b.append("Class-Path: "); if (checkTypes(project)) { for (Artifact da : allDependencies(project, ignoredProjects)) { if (da.getType().equals("jar")) { b.append(da.getArtifactId() + "-" + da.getVersion() + ".jar "); }//from www. ja va 2 s . c om } } b.append("\n"); b.append("Built-By: exo\n"); b.append("Specification-Title: " + project.getArtifactId() + "\n"); b.append("Specification-Version: " + project.getVersion() + "\n"); b.append("Specification-Vendor: eXo Platform SARL\n"); b.append("Implementation-Title: " + project.getBuild().getFinalName() + "\n"); b.append("Implementation-Version: " + project.getVersion() + "\n"); b.append("Implementation-Vendor: eXo Platform SARL\n"); FileOutputStream out = new FileOutputStream(mf); out.write(b.toString().getBytes()); out.close(); }
From source file:org.exoplatform.maven2.plugin.Utils.java
License:Open Source License
public static void createManifest2(File mf, MavenProject project, HashSet includes) throws IOException { StringBuilder b = new StringBuilder(); b.append("Manifest-Version: 1.0\n"); b.append("Ant-Version: Apache Ant 1.5.3\n"); b.append("Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)\n"); if (includes != null) { b.append("Class-Path: "); for (Artifact da : allDependencies(project, null)) { if (da.getType().equals("jar") && includes.contains(da.getArtifactId())) { b.append(da.getArtifactId() + "-" + da.getVersion() + ".jar "); }/*from www. ja va 2s. c o m*/ } b.append("\n"); } b.append("Built-By: exo\n"); b.append("Specification-Title: " + project.getArtifactId() + "\n"); b.append("Specification-Version: " + project.getVersion() + "\n"); b.append("Specification-Vendor: eXo Platform SARL\n"); b.append("Implementation-Title: " + project.getBuild().getFinalName() + "\n"); b.append("Implementation-Version: " + project.getVersion() + "\n"); b.append("Implementation-Vendor: eXo Platform SARL\n"); FileOutputStream out = new FileOutputStream(mf); out.write(b.toString().getBytes()); out.close(); }
From source file:org.fedoraproject.tycho.TychoBootstrapMojo.java
License:Open Source License
public void createProjectDepMap(Map<String, List<Dependency>> mappings) { for (MavenProject proj : session.getProjects()) { mappings.put(proj.getArtifactId(), proj.getDependencies()); }//from w ww .jav a 2 s . c om }
From source file:org.fedoraproject.tycho.TychoBootstrapMojo.java
License:Open Source License
public boolean isExcluded(MavenProject proj) { return proj.getArtifactId().contains("surefire") || proj.getPackaging().equals("eclipse-test-plugin"); }
From source file:org.fluidity.deployment.maven.DependenciesSupportImpl.java
License:Apache License
@Override public void saveArtifact(final MavenProject project, final File file, final String finalName, final String classifier, final String packaging, final Logger log) throws MojoExecutionException { final boolean unclassified = classifier == null || classifier.isEmpty(); final String outputName = unclassified ? String.format("%s.%s", finalName, packaging) : String.format("%s-%s.%s", finalName, classifier, packaging); final File outputFile = new File(outputName); final String outputPath = outputFile.getAbsolutePath(); final Artifact artifact = project.getArtifact(); assert artifact != null; final File artifactFile = artifact.getFile(); if (artifactFile != null && artifactFile.getAbsolutePath().equals(outputPath)) { log.info(String.format("Replacing %s: %s", packaging, artifactFile.getAbsolutePath())); if (!artifactFile.delete()) { throw new MojoExecutionException(String.format("Could not delete %s", artifactFile)); }// w w w . j av a 2 s . c om if (!file.renameTo(artifactFile)) { throw new MojoExecutionException(String.format("Could not create %s", artifactFile)); } } else { boolean replacing = false; for (final Artifact attached : project.getAttachedArtifacts()) { if (attached.getFile().getAbsolutePath().equals(outputPath)) { replacing = true; break; } } log.info(String.format("%s %s: %s", replacing ? "Replacing" : "Saving", packaging, outputPath)); if (outputFile.exists() && !outputFile.delete()) { throw new MojoExecutionException(String.format("Could not delete %s", outputFile)); } if (!file.renameTo(outputFile)) { throw new MojoExecutionException(String.format("Could not create %s", outputFile)); } if (!replacing) { final DefaultArtifact attachment = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getScope(), packaging, classifier, artifact.getArtifactHandler()); attachment.setFile(outputFile); project.addAttachedArtifact(attachment); } } }