List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:com.torchmind.maven.plugins.attribution.AttributionMojo.java
License:Apache License
/** * Creates an artifact using a maven project. * @param artifact the maven project./*from ww w. j a v a 2s. c o m*/ * @return the artifact. */ @Nonnull public static Artifact createArtifact(@Nonnull MavenProject artifact) { return new Artifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getName(), artifact.getDescription(), artifact.getUrl(), artifact.getLicenses().stream().map(AttributionMojo::createLicense).collect(Collectors.toList()), artifact.getDevelopers().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), artifact.getContributors().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList())); }
From source file:com.tvarit.plugin.TvaritTomcatDeployerMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { final MavenProject project = (MavenProject) this.getPluginContext().getOrDefault("project", null); if (templateUrl == null) try {//from w ww . ja v a2s. c om templateUrl = new TemplateUrlMaker().makeUrl(project, "newinstance.template").toString(); } catch (MalformedURLException e) { throw new MojoExecutionException( "Could not create default url for templates. Please open an issue on github.", e); } final BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); AmazonS3Client s3Client = new AmazonS3Client(awsCredentials); final File warFile = project.getArtifact().getFile(); final String key = "deployables/" + project.getGroupId() + "/" + project.getArtifactId() + "/" + project.getVersion() + "/" + warFile.getName(); final PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, warFile); final ObjectMetadata metadata = new ObjectMetadata(); final HashMap<String, String> userMetadata = new HashMap<>(); userMetadata.put("project_name", projectName); userMetadata.put("stack_template_url", templateUrl); userMetadata.put("private_key_name", sshKeyName); metadata.setUserMetadata(userMetadata); putObjectRequest.withMetadata(metadata); final PutObjectResult putObjectResult = s3Client.putObject(putObjectRequest); /* AmazonCloudFormationClient amazonCloudFormationClient = new AmazonCloudFormationClient(awsCredentials); final com.amazonaws.services.cloudformation.model.Parameter projectNameParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("projectName").withParameterValue(this.projectName); final com.amazonaws.services.cloudformation.model.Parameter publicSubnetsParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("publicSubnets").withParameterValue(commaSeparatedSubnetIds); final com.amazonaws.services.cloudformation.model.Parameter tvaritRoleParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("tvaritRole").withParameterValue(tvaritRole); final com.amazonaws.services.cloudformation.model.Parameter tvaritInstanceProfileParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("tvaritInstanceProfile").withParameterValue(this.tvaritInstanceProfile); final com.amazonaws.services.cloudformation.model.Parameter tvaritBucketNameParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("bucketName").withParameterValue(this.bucketName); final com.amazonaws.services.cloudformation.model.Parameter instanceSecurityGroupIdParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("sgId").withParameterValue(this.instanceSecurityGroupId); final com.amazonaws.services.cloudformation.model.Parameter sshKeyNameParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("keyName").withParameterValue(this.sshKeyName); final String warFileUrl = s3Client.getUrl(bucketName, key).toString(); final com.amazonaws.services.cloudformation.model.Parameter warFileUrlParameter = new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey("warFileUrl").withParameterValue(warFileUrl); final CreateStackRequest createStackRequest = new CreateStackRequest(); if (templateUrl == null) { try { templateUrl = new TemplateUrlMaker().makeUrl(project, "newinstance.template").toString(); } catch (MalformedURLException e) { throw new MojoExecutionException("Could not create default url for templates. Please open an issue on github.", e); } } createStackRequest. withStackName(projectName + "-instance-" + project.getVersion().replace(".", "-")). withParameters( projectNameParameter, publicSubnetsParameter, tvaritInstanceProfileParameter, tvaritRoleParameter, tvaritBucketNameParameter, instanceSecurityGroupIdParameter, warFileUrlParameter, sshKeyNameParameter ). withDisableRollback(true). withTemplateURL(templateUrl); createStackRequest.withDisableRollback(true); final Stack stack = new StackMaker().makeStack(createStackRequest, amazonCloudFormationClient, getLog()); AmazonAutoScalingClient amazonAutoScalingClient = new AmazonAutoScalingClient(awsCredentials); final AttachInstancesRequest attachInstancesRequest = new AttachInstancesRequest(); attachInstancesRequest.withInstanceIds(stack.getOutputs().get(0).getOutputValue(), stack.getOutputs().get(1).getOutputValue()).withAutoScalingGroupName(autoScalingGroupName); amazonAutoScalingClient.attachInstances(attachInstancesRequest); */ }
From source file:com.willowtreeapps.saguaro.maven.MavenLicenseResolver.java
License:Apache License
@Override public Set<LicenseDependency> resolveLicenseDependencies() throws PluginException { Set<Artifact> deps = projectHelper.getArtifacts(); Set<LicenseDependency> licenseDependencies = new LinkedHashSet<LicenseDependency>(); for (Artifact artifact : deps) { MavenProject depProject = projectHelper.buildFromRepository(artifact); Dependency dependency = new Dependency(depProject.getGroupId(), depProject.getArtifactId()); List<org.apache.maven.model.License> licenseList = depProject.getLicenses(); Set<LicenseInfo> licenses = new LinkedHashSet<LicenseInfo>(); for (org.apache.maven.model.License license : licenseList) { licenses.add(LicenseInfo.withUrl(license.getName(), license.getUrl())); }// w ww .ja v a 2 s. co m licenseDependencies.add(new LicenseDependency(depProject.getName(), dependency, licenses)); } return licenseDependencies; }
From source file:de.adorsys.cmer.NoDependencyVersions.java
License:Apache License
private void checkOnNoDependencieVersionsFrom3rdParty(MavenProject project) throws EnforcerRuleException { Model originalModel = project.getOriginalModel(); StringBuilder dependenciesWithVersionDeclaration = new StringBuilder(); if (project.getGroupId().equals(ignoreMasterProjectGroupId) || originalModel.getDependencyManagement() == null || originalModel.getDependencyManagement().getDependencies() == null) { return;// w w w . ja v a 2 s .c om } boolean fail = false; for (Dependency d : originalModel.getDependencyManagement().getDependencies()) { if (!d.getGroupId().startsWith(allowedGroupPrefix)) { dependenciesWithVersionDeclaration.append(" - " + d.toString() + "\n"); fail = true; } } if (fail) { throw new EnforcerRuleException("This Project contains Dependency-Versions from 3rd party libs (not " + allowedGroupPrefix + ").\n" + "Please declare for maintainance reasons 3rd pary versions in " + ignoreMasterProjectGroupId + ".\n" + "This dependencies sould be corrected:\n" + dependenciesWithVersionDeclaration ); } }
From source file:de.adorsys.cmer.ProjectNamingConverntions.java
License:Apache License
private void checkGroupIdAndArifactOverlapping(MavenProject project, EnforcerRuleHelper helper) throws EnforcerRuleException { String[] groupParts = project.getGroupId().split("[.]"); String[] artifactParts = project.getArtifactId().split("[.]"); String lastPartGroup = groupParts[groupParts.length - 1]; String firstPartArtifactId = artifactParts[0]; if (!lastPartGroup.equals(firstPartArtifactId)) { throw new EnforcerRuleException( "The last fragment of the groupId does not macht the first part of the artifactId of artifact " + project.getArtifactId()); }// w w w . j a v a 2 s. co m }
From source file:de.adorsys.cmer.ProjectNamingConverntions.java
License:Apache License
private void checkGroupIdPrefix(MavenProject project) throws EnforcerRuleException { if (!project.getGroupId().startsWith(allowedGroupPrefix)) { throw new EnforcerRuleException("The groupId of project " + project.getArtifact() + " have to start with :" + allowedGroupPrefix); }/*www . ja va 2 s . c o m*/ }
From source file:de.akquinet.innovation.continuous.UniqueVersionMojo.java
License:Apache License
public void updateReleaseProperties(String newVersion) throws IOException { Properties properties = new Properties(); File releaseFile = new File(project.getBasedir(), "release.properties"); if (releaseFile.exists()) { FileInputStream fis = new FileInputStream(releaseFile); properties.load(fis);/* ww w . ja v a 2s.com*/ IOUtils.closeQuietly(fis); } properties.put("scm.tag", project.getArtifactId() + "-" + newVersion); String oldVersion = project.getVersion(); // For all projects set: //project.rel.org.myCompany\:projectA=1.2 //project.dev.org.myCompany\:projectA=1.3-SNAPSHOT for (MavenProject project : reactor) { properties.put("project.rel." + project.getGroupId() + ":" + project.getArtifactId(), newVersion); properties.put("project.dev." + project.getGroupId() + ":" + project.getArtifactId(), oldVersion); } FileOutputStream fos = new FileOutputStream(releaseFile); properties.store(fos, "File edited by the continuous-version-maven-plugin"); IOUtils.closeQuietly(fos); }
From source file:de.eacg.ecs.plugin.ScanAndTransferMojo.java
private boolean isPrivateComponent(MavenProject project) { for (String pc : getPrivateComponents()) { String compareString = project.getGroupId(); if (pc.contains(":")) { compareString += ':' + project.getArtifactId(); }/* ww w . jav a 2 s. c o m*/ boolean result = pc.equals(compareString); if (result) { return true; } } return false; }
From source file:de.eacg.ecs.plugin.ScanAndTransferMojo.java
private Dependency mapDependency(DependencyNode node, Map<ComponentId, Map.Entry<MavenProject, String[]>> projectLookup) { Dependency.Builder builder = new Dependency.Builder(); Artifact artifact = node.getArtifact(); ComponentId artifactId = ComponentId.create(artifact); Map.Entry<MavenProject, String[]> projectLicensesPair = projectLookup.get(artifactId); // try fallback to artifact baseVersion, (for example because a snapshot is locked ) if (projectLicensesPair == null) { projectLicensesPair = projectLookup.get(ComponentId.createFallback(artifact)); }//from ww w.jav a2 s. c o m if (projectLicensesPair == null) { getLog().error("Something weird happened: no Project found for artifact: " + artifactId); return null; } MavenProject project = projectLicensesPair.getKey(); String[] licensesArr = projectLicensesPair.getValue(); builder.setName(project.getName()).setDescription(project.getDescription()) .setKey("mvn:" + project.getGroupId() + ':' + project.getArtifactId()) .addVersion(project.getVersion()).setHomepageUrl(project.getUrl()); if (isPrivateComponent(project)) { builder.setPrivate(true); } try { File file = artifact.getFile(); if (file != null) { builder.setChecksum("sha-1:" + ChecksumCreator.createChecksum(file)); } else { Artifact af = findProjectArtifact(artifact); if (af != null && af.getFile() != null) { builder.setChecksum("sha-1:" + ChecksumCreator.createChecksum(af.getFile())); } else { getLog().warn( "Could not generate checksum - no file specified: " + ComponentId.create(artifact)); } } } catch (NoSuchAlgorithmException | IOException e) { getLog().warn("Could not generate checksum: " + e.getMessage()); } if (licensesArr != null && (licensesArr.length != 1 || !LicenseMap.UNKNOWN_LICENSE_MESSAGE.equals(licensesArr[0]))) { for (String license : licensesArr) { builder.addLicense(license); } } for (DependencyNode childNode : node.getChildren()) { Dependency dep = mapDependency(childNode, projectLookup); if (dep != null) { builder.addDependency(dep); } } return builder.buildDependency(); }
From source file:de.lightful.maven.plugins.drools.impl.dependencies.DependencyLoader.java
License:Apache License
private Dependency createDependencyFrom(MavenProject project) { final String artifactType = project.getPackaging(); org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), EMPTY_CLASSIFIER, fileExtensionOf(artifactType), project.getVersion()); return new Dependency(artifact, WellKnownNames.SCOPE_COMPILE); }