List of usage examples for org.apache.maven.project MavenProject getCiManagement
public CiManagement getCiManagement()
From source file:com.effectivemaven.centrepoint.maven.repository.CentralRepositoryService.java
License:Apache License
public Project retrieveProject(String groupId, String artifactId, String version) throws RepositoryException { // get the project from the repository Artifact artifact = artifactFactory.createProjectArtifact(groupId, artifactId, version); MavenProject mavenProject; try {//from w w w . ja v a2 s .c o m mavenProject = projectBuilder.buildFromRepository(artifact, Collections.singletonList(repository), localRepository); } catch (ProjectBuildingException e) { throw new RepositoryException(e.getMessage(), e); } // populate the Centrepoint model from the Maven project Project project = new Project(); project.setId(MavenCoordinates.constructProjectId(groupId, artifactId)); project.setVersion(version); MavenCoordinates coordinates = new MavenCoordinates(); coordinates.setGroupId(groupId); coordinates.setArtifactId(artifactId); project.addExtensionModel(coordinates); project.setDescription(mavenProject.getDescription()); project.setName(mavenProject.getName()); if (mavenProject.getCiManagement() != null) { project.setCiManagementUrl(mavenProject.getCiManagement().getUrl()); } if (mavenProject.getIssueManagement() != null) { project.setIssueTrackerUrl(mavenProject.getIssueManagement().getUrl()); } if (mavenProject.getScm() != null) { project.setScmUrl(mavenProject.getScm().getUrl()); } project.setUrl(mavenProject.getUrl()); DistributionManagement distMgmt = mavenProject.getDistributionManagement(); if (distMgmt != null) { project.setRepositoryUrl(distMgmt.getRepository().getUrl()); project.setSnapshotRepositoryUrl(distMgmt.getSnapshotRepository().getUrl()); } return project; }
From source file:hudson.gridmaven.PomInfo.java
License:Open Source License
public PomInfo(MavenProject project, PomInfo parent, String relPath) { this.name = new ModuleName(project); this.version = project.getVersion(); this.displayName = project.getName(); this.defaultGoal = project.getDefaultGoal(); this.relativePath = relPath; this.parent = parent; if (parent != null) parent.children.add(name);/*w w w . j a v a2 s .co m*/ for (Dependency dep : (List<Dependency>) project.getDependencies()) dependencies.add(new ModuleDependency(dep)); MavenProject parentProject = project.getParent(); if (parentProject != null) dependencies.add(new ModuleDependency(parentProject)); if (parent != null) dependencies.add(parent.asDependency()); addPluginsAsDependencies(project.getBuildPlugins(), dependencies); addReportPluginsAsDependencies(project.getReportPlugins(), dependencies); List<Extension> extensions = project.getBuildExtensions(); if (extensions != null) for (Extension ext : extensions) dependencies.add(new ModuleDependency(ext)); // when the parent POM uses a plugin and builds a plugin at the same time, // the plugin module ends up depending on itself dependencies.remove(asDependency()); CiManagement ciMgmt = project.getCiManagement(); if ((ciMgmt != null) && (ciMgmt.getSystem() == null || ciMgmt.getSystem().equals("hudson"))) { Notifier mailNotifier = null; for (Notifier n : (List<Notifier>) ciMgmt.getNotifiers()) { if (n.getType().equals("mail")) { mailNotifier = n; break; } } this.mailNotifier = mailNotifier; } else this.mailNotifier = null; this.groupId = project.getGroupId(); this.artifactId = project.getArtifactId(); this.packaging = project.getPackaging(); }
From source file:org.codehaus.continuum.builder.maven.m2.DefaultMavenBuilderHelper.java
License:Apache License
public String getNagEmailAddress(MavenProject project) { for (Iterator it = project.getCiManagement().getNotifiers().iterator(); it.hasNext();) { Notifier notifier = (Notifier) it.next(); if (notifier.getType().equals("mail")) { return notifier.getAddress(); }//ww w. j a v a2s . co m } return null; }
From source file:org.codehaus.continuum.builder.maven.m2.DefaultMavenBuilderHelper.java
License:Apache License
protected MavenProject getProject(File file) throws ContinuumException { MavenProject project = null; try {/*from w w w .ja v a 2 s .co m*/ project = projectBuilder.build(file, getRepository()); } catch (ProjectBuildingException e) { throw new ContinuumException("Cannot build maven project from " + file, e); } // ---------------------------------------------------------------------- // Validate the MavenProject using some Continuum rules // ---------------------------------------------------------------------- // Nag email address CiManagement ciManagement = project.getCiManagement(); if (ciManagement == null) { throw new ContinuumException("Missing CiManagement from the project descriptor."); } if (StringUtils.isEmpty(getNagEmailAddress(project))) { throw new ContinuumException("Missing nag email address from the continuous integration info."); } // SCM connection Scm scm = project.getScm(); if (scm == null) { throw new ContinuumException("Missing Scm from the project descriptor."); } String url = scm.getConnection(); if (StringUtils.isEmpty(url)) { throw new ContinuumException("Missing anonymous scm connection url."); } // Version if (StringUtils.isEmpty(project.getVersion())) { throw new ContinuumException("Missing version from the project descriptor."); } return project; }
From source file:org.codehaus.continuum.builder.maven2.Maven2ContinuumBuilder.java
License:Open Source License
public ContinuumProject createProject(File workingDirectory) throws ContinuumException { Maven2ProjectDescriptor descriptor = new Maven2ProjectDescriptor(); // try // {/*from www .jav a 2s . c om*/ // scm.checkOutProject( project ); // } // catch( ContinuumScmException ex ) // { // throw new ContinuumException( "Error while checking out the project.", ex ); // } MavenProject mavenProject; File pomFile = getPomFile(workingDirectory); mavenProject = mavenTool.getProject(pomFile); List goals = new LinkedList(); goals.add("pom:install"); mavenTool.execute(mavenProject, goals); // ---------------------------------------------------------------------- // Populating the descriptor // ---------------------------------------------------------------------- if (mavenProject.getScm() == null) { throw new ContinuumException("The project descriptor is missing the SCM section."); } if (mavenProject.getCiManagement() == null) { throw new ContinuumException("The project descriptor is missing the CI section."); } Build build = mavenProject.getBuild(); boolean isPom = true; if (build != null) { String sourceDirectory = build.getSourceDirectory(); if (sourceDirectory != null && sourceDirectory.trim().length() > 0) { if (new File(sourceDirectory).isDirectory()) { isPom = false; } } } if (isPom) { descriptor.getGoals().add("pom:install"); } else { descriptor.getGoals().add("clean:clean"); descriptor.getGoals().add("jar:install"); } // descriptor.setName( mavenProject.getName() ); // The public Url takes priority over the developer connection Scm scm = mavenProject.getScm(); String scmUrl = scm.getConnection(); if (StringUtils.isEmpty(scmUrl)) { scmUrl = scm.getDeveloperConnection(); } if (StringUtils.isEmpty(scmUrl)) { throw new ContinuumException("Missing both anonymous and developer scm connection urls."); } // descriptor.setScmUrl( scmUrl ); CiManagement ciManagement = mavenProject.getCiManagement(); String nagEmailAddress = ciManagement.getNagEmailAddress(); if (StringUtils.isEmpty(nagEmailAddress)) { throw new ContinuumException( "Missing nag email address from the ci section of the project descriptor."); } // descriptor.setNagEmailAddress( nagEmailAddress ); String version = mavenProject.getVersion(); if (StringUtils.isEmpty(version)) { throw new ContinuumException("Missing version from the project descriptor."); } // descriptor.setVersion( version ); // ---------------------------------------------------------------------- // Make the project // ---------------------------------------------------------------------- ContinuumProject project = new GenericContinuumProject(); if (StringUtils.isEmpty(mavenProject.getName())) { throw new ContinuumException("The project name cannot be empty."); } project.setName(mavenProject.getName()); project.setScmUrl(scmUrl); project.setNagEmailAddress(nagEmailAddress); project.setVersion(version); project.setDescriptor(descriptor); return project; }
From source file:org.codehaus.continuum.maven.DefaultMavenTool.java
License:Open Source License
public MavenProject getProject(File file) throws ContinuumException { MavenProject project; try {/* www . ja v a 2 s.co m*/ project = maven.getProject(file); } catch (ProjectBuildingException ex) { throw new ContinuumException("Error while building project.", ex); } // ---------------------------------------------------------------------- // Validate the MavenProject after some Continuum rules // ---------------------------------------------------------------------- // Nag email address CiManagement ciManagement = project.getCiManagement(); if (ciManagement == null) { throw new ContinuumException("Missing CiManagement from the project descriptor."); } if (StringUtils.isEmpty(ciManagement.getNagEmailAddress())) { throw new ContinuumException("Missing nag email address from the continuous integration info."); } // SCM connection Scm scm = project.getScm(); if (scm == null) { throw new ContinuumException("Missing Scm from the project descriptor."); } String url = scm.getConnection(); if (StringUtils.isEmpty(url)) { throw new ContinuumException("Missing anonymous scm connection url."); } // Version if (StringUtils.isEmpty(project.getVersion())) { throw new ContinuumException("Missing version from the project descriptor."); } return project; }
From source file:org.codehaus.continuum.maven.DefaultMavenTool.java
License:Open Source License
public String getNagEmailAddress(MavenProject project) { return project.getCiManagement().getNagEmailAddress(); }
From source file:org.codehaus.mojo.cruisecontrol.CruiseControlPluginConfigurer.java
License:Apache License
public static void addEmailPlugin(PrettyPrintXMLWriter writer, EmailPublisher config, MavenProject project) { String ciUrl = null == project ? null : null == project.getCiManagement() ? null : project.getCiManagement().getUrl() + "buildresults/${project.name}"; String type = config.isHtmlemail() ? "htmlemail" : "email"; writer.startElement("plugin"); writer.addAttribute("name", type); WriterUtil.addIfNotNull(writer, "buildresultsurl", ciUrl); if (config.isHtmlemail()) { CruiseControlEmailConfigurer.addHtmlEmailAttributes(writer, config); }//from w w w . ja v a 2s. c o m CruiseControlEmailConfigurer.addCommonMailAttributes(writer, config); writer.endElement(); }
From source file:org.eclipse.m2e.core.ui.internal.actions.OpenUrlAction.java
License:Open Source License
private static String getUrl(String actionId, MavenProject mavenProject) { String url = null;/* ww w . j av a 2s.co m*/ if (ID_PROJECT.equals(actionId)) { url = mavenProject.getUrl(); if (url == null) { openDialog(Messages.OpenUrlAction_error_no_url); } } else if (ID_ISSUES.equals(actionId)) { IssueManagement issueManagement = mavenProject.getIssueManagement(); if (issueManagement != null) { url = issueManagement.getUrl(); } if (url == null) { openDialog(Messages.OpenUrlAction_error_no_issues); } } else if (ID_SCM.equals(actionId)) { Scm scm = mavenProject.getScm(); if (scm != null) { url = scm.getUrl(); } if (url == null) { openDialog(Messages.OpenUrlAction_error_no_scm); } } else if (ID_CI.equals(actionId)) { CiManagement ciManagement = mavenProject.getCiManagement(); if (ciManagement != null) { url = ciManagement.getUrl(); } if (url == null) { openDialog(Messages.OpenUrlAction_error_no_ci); } } return url; }
From source file:org.sonar.batch.maven.MavenProjectConverter.java
License:Open Source License
/** * For SONAR-3676/*from w ww. ja v a2 s . c om*/ */ private static void convertMavenLinksToProperties(ProjectDefinition definition, MavenProject pom) { setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_HOME_PAGE, pom.getUrl()); Scm scm = pom.getScm(); if (scm == null) { scm = new Scm(); } setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_SOURCES, scm.getUrl()); setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_SOURCES_DEV, scm.getDeveloperConnection()); CiManagement ci = pom.getCiManagement(); if (ci == null) { ci = new CiManagement(); } setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_CI, ci.getUrl()); IssueManagement issues = pom.getIssueManagement(); if (issues == null) { issues = new IssueManagement(); } setPropertyIfNotAlreadyExists(definition, CoreProperties.LINKS_ISSUE_TRACKER, issues.getUrl()); }