List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:me.gladwell.eclipse.m2e.android.project.EclipseAndroidWorkspace.java
License:Open Source License
public IDEAndroidProject findOpenWorkspaceDependency(Dependency dependency) { for (IProject project : workspace.getRoot().getProjects()) { if (!project.isOpen()) { continue; }/* w w w . jav a2 s .c o m*/ IDEAndroidProject androidProject = projectFactory.createAndroidProject(project); if (androidProject.isMavenised()) { MavenProject mavenProject; try { mavenProject = mavenModelManager.readMavenProject(androidProject.getPom(), null); } catch (CoreException e) { throw new ProjectConfigurationException(e); } if (StringUtils.equals(dependency.getName(), project.getName()) && StringUtils.equals(dependency.getGroup(), mavenProject.getGroupId()) && dependency.getVersion().equals(mavenProject.getVersion())) { return androidProject; } } } throw new DependencyNotFoundInWorkspace(dependency); }
From source file:ms.dew.devops.kernel.config.ConfigBuilder.java
License:Apache License
private static FinalProjectConfig doBuildProject(DewConfig dewConfig, AppKindPlugin appKindPlugin, DeployPlugin deployPlugin, MavenProject mavenProject, String inputProfile, String inputDockerHost, String inputDockerRegistryUrl, String inputDockerRegistryUserName, String inputDockerRegistryPassword, String inputKubeBase64Config, Optional<String> dockerHostAppendOpt, Optional<String> dockerRegistryUrlAppendOpt, Optional<String> dockerRegistryUserNameAppendOpt, Optional<String> dockerRegistryPasswordAppendOpt, Optional<String> kubeBase64ConfigAppendOpt) throws InvocationTargetException, IllegalAccessException { FinalProjectConfig finalProjectConfig = new FinalProjectConfig(); if (inputProfile.equalsIgnoreCase(FLAG_DEW_DEVOPS_DEFAULT_PROFILE)) { $.bean.copyProperties(finalProjectConfig, dewConfig); } else {/* www. j ava 2 s . c o m*/ $.bean.copyProperties(finalProjectConfig, dewConfig.getProfiles().get(inputProfile)); } // setting basic finalProjectConfig.setId(mavenProject.getId()); finalProjectConfig.setAppKindPlugin(appKindPlugin); finalProjectConfig.setDeployPlugin(deployPlugin); finalProjectConfig.setProfile(inputProfile); finalProjectConfig.setAppGroup(mavenProject.getGroupId()); finalProjectConfig.setAppName(mavenProject.getArtifactId()); finalProjectConfig.setSkip(false); if (mavenProject.getName() != null && !mavenProject.getName().trim().isEmpty()) { finalProjectConfig.setAppShowName(mavenProject.getName()); } else { finalProjectConfig.setAppShowName(mavenProject.getArtifactId()); } // ? if (inputDockerHost != null && !inputDockerHost.trim().isEmpty()) { finalProjectConfig.getDocker().setHost(inputDockerHost.trim()); } if (inputDockerRegistryUrl != null && !inputDockerRegistryUrl.trim().isEmpty()) { finalProjectConfig.getDocker().setRegistryUrl(inputDockerRegistryUrl.trim()); } if (inputDockerRegistryUserName != null && !inputDockerRegistryUserName.trim().isEmpty()) { finalProjectConfig.getDocker().setRegistryUserName(inputDockerRegistryUserName.trim()); } if (inputDockerRegistryPassword != null && !inputDockerRegistryPassword.trim().isEmpty()) { finalProjectConfig.getDocker().setRegistryPassword(inputDockerRegistryPassword.trim()); } if (inputKubeBase64Config != null && !inputKubeBase64Config.trim().isEmpty()) { finalProjectConfig.getKube().setBase64Config(inputKubeBase64Config.trim()); } // setting path finalProjectConfig.setDirectory(mavenProject.getBasedir().getPath() + File.separator); finalProjectConfig.setTargetDirectory(finalProjectConfig.getDirectory() + "target" + File.separator); // setting git info finalProjectConfig.setScmUrl(GitHelper.inst().getScmUrl()); finalProjectConfig.setGitCommit(GitHelper.inst().getCurrentCommit()); finalProjectConfig.setImageVersion(finalProjectConfig.getGitCommit()); finalProjectConfig.setAppVersion(finalProjectConfig.getGitCommit()); // setting custom config by app kind finalProjectConfig.getAppKindPlugin().customConfig(finalProjectConfig); // setting reuse version fillReuseVersionInfo(finalProjectConfig, dewConfig, dockerHostAppendOpt, dockerRegistryUrlAppendOpt, dockerRegistryUserNameAppendOpt, dockerRegistryPasswordAppendOpt, kubeBase64ConfigAppendOpt); return finalProjectConfig; }
From source file:ms.dew.devops.kernel.plugin.deploy.maven.MavenDeployPlugin.java
License:Apache License
@Override public Resp<String> deployAble(FinalProjectConfig projectConfig) { MavenProject mavenProject = projectConfig.getMavenProject(); String version = mavenProject.getVersion(); if (version.trim().toLowerCase().endsWith("snapshot")) { // //from w ww . j ava 2s.c om if (mavenProject.getDistributionManagement() == null || mavenProject.getDistributionManagement().getSnapshotRepository() == null || mavenProject.getDistributionManagement().getSnapshotRepository().getUrl() == null || mavenProject.getDistributionManagement().getSnapshotRepository().getUrl().trim().isEmpty()) { return Resp.forbidden("Maven distribution snapshot repository not found"); } } else if (mavenProject.getDistributionManagement() == null || mavenProject.getDistributionManagement().getRepository() == null || mavenProject.getDistributionManagement().getRepository().getUrl() == null || mavenProject.getDistributionManagement().getRepository().getUrl().trim().isEmpty()) { // ?? return Resp.forbidden("Maven distribution repository not found"); } String repoUrl = mavenProject.getDistributionManagement().getRepository().getUrl().trim(); // TBD auth repoUrl = repoUrl.endsWith("/") ? repoUrl : repoUrl + "/"; repoUrl += mavenProject.getGroupId().replaceAll("\\.", "/") + "/" + mavenProject.getArtifactId() + "/" + version; try { if ($.http.getWrap(repoUrl).statusCode == 200) { return Resp.forbidden("The current version already exists"); } } catch (IOException e) { throw new ProjectProcessException(e.getMessage(), e); } return Resp.success(""); }
From source file:net.dynamic_tools.maven.plugin.javascript.util.JavaScriptArchiver.java
License:Apache License
public void createDefaultManifest(MavenProject project) throws ManifestException, IOException, ArchiverException { Manifest manifest = new Manifest(); Manifest.Attribute attr = new Manifest.Attribute("Created-By", "Apache Maven"); manifest.addConfiguredAttribute(attr); attr = new Manifest.Attribute("Implementation-Title", project.getName()); manifest.addConfiguredAttribute(attr); attr = new Manifest.Attribute("Implementation-Version", project.getVersion()); manifest.addConfiguredAttribute(attr); attr = new Manifest.Attribute("Implementation-Vendor-Id", project.getGroupId()); manifest.addConfiguredAttribute(attr); if (project.getOrganization() != null) { String vendor = project.getOrganization().getName(); attr = new Manifest.Attribute("Implementation-Vendor", vendor); manifest.addConfiguredAttribute(attr); }//from ww w . j a v a2s . c o m attr = new Manifest.Attribute("Built-By", System.getProperty("user.name")); manifest.addConfiguredAttribute(attr); File mf = File.createTempFile("maven", ".mf"); mf.deleteOnExit(); PrintWriter writer = new PrintWriter(new FileWriter(mf)); manifest.write(writer); writer.close(); setManifest(mf); }
From source file:net.erdfelt.maven.graphing.MultimoduleGraphMojo.java
License:Apache License
private boolean isMultiModuleDependency(Dependency dep) { boolean ret = false; Iterator it = projects.iterator(); while (it.hasNext()) { MavenProject project = (MavenProject) it.next(); if (StringUtils.equals(project.getGroupId(), dep.getGroupId()) && StringUtils.equals(project.getArtifactId(), dep.getArtifactId()) && StringUtils.equals(project.getPackaging(), dep.getType())) { // Found dep that matches on groupId / artifactId / type only. if (ignoreVersions) { // No test of version. ret = true;/*www . jav a 2s. c o m*/ break; } else if (StringUtils.equals(project.getVersion(), dep.getVersion())) { // Found dep that matches on version too. ret = true; break; } } } return ret; }
From source file:net.erdfelt.maven.graphing.MultimoduleGraphMojo.java
License:Apache License
private Node toNode(MavenProject project) { return toNode(project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getPackaging()); }
From source file:net.flexmojos.oss.plugin.war.CopyMojo.java
License:Open Source License
private List<Artifact> getRuntimeLocalesDependencies(MavenProject artifactProject) { String[] runtimeLocales = CompileConfigurationLoader.getCompilerPluginSettings(artifactProject, "runtimeLocales"); if (runtimeLocales == null || runtimeLocales.length == 0) { return Collections.emptyList(); }/*from w w w. j a v a2 s. co m*/ List<Artifact> artifacts = new ArrayList<Artifact>(); for (String locale : runtimeLocales) { artifacts.add(repositorySystem.createArtifactWithClassifier(artifactProject.getGroupId(), artifactProject.getArtifactId(), artifactProject.getVersion(), SWF, locale)); } return artifacts; }
From source file:net.israfil.mojo.flex2.AbstractFlexModule.java
License:Open Source License
public void resolveArtifact(MavenProject project, Set artifacts) throws MojoFailureException { if (artifact != null) return; // succeed fast. if (groupId == null) groupId = project.getGroupId(); if (artifactId == null) throw new MojoFailureException("No artifact specified"); Iterator i = artifacts.iterator(); while (i.hasNext()) { Artifact a = (Artifact) i.next(); if (a.getGroupId().equals(groupId) && a.getArtifactId().equals(artifactId)) this.artifact = a; }//from w w w . j a v a2s. c o m if (artifact == null) throw new MojoFailureException( "Could not find artifact: " + groupId + ":" + artifactId + " from declared dependencies"); if (targetFilename == null) targetFilename = artifact.getFile().getName(); }
From source file:net.kozelka.contentcheck.mojo.LicenseShowMojo.java
License:Open Source License
/** * Artifact resolving and the rest of Maven repo magic taken from <a href="http://maven.apache.org/plugins/maven-project-info-reports-plugin/index.html">Maven Project Info Reports Plugin</a>. *//*from ww w. j a v a 2s.c o m*/ public void execute() throws MojoExecutionException, MojoFailureException { final File src = sourceFile.exists() ? sourceFile : defaultBundleForPOMPacking; if (!src.exists()) { getLog().warn("Skipping project since there is no archive to check."); return; } final List<MavenProject> mavenProjectForDependencies = getMavenProjectForDependencies(); try { final ContentIntrospector introspector = VendorFilter.createIntrospector( new MyIntrospectionListener(getLog()), ignoreVendorArchives, vendorId, manifestVendorEntry, checkFilesPattern); final Set<ActualEntry> archiveEntries = new LinkedHashSet<ActualEntry>(); introspector.setSourceFile(src); //TODO: instead of collecting, put the dependency comparison right inside final ContentCollector collector = new ContentCollector(archiveEntries); introspector.getEvents().addListener(collector); introspector.walk(); introspector.getEvents().removeListener(collector); final Map<String, List<License>> entries = new LinkedHashMap<String, List<License>>(); final Map<String, List<License>> additionalLicenseInformation = new LinkedHashMap<String, List<License>>(); if (licenseMappingFile != null && licenseMappingFile.exists()) { //read additional license information getLog().info( String.format("Reading license mapping file %s", licenseMappingFile.getAbsolutePath())); try { additionalLicenseInformation.putAll(LicenseShow.parseLicenseMappingFile(licenseMappingFile)); } catch (JsonParseException e) { throw new MojoFailureException(String.format( "Cannot parse JSON from file %s the content of the file is not well formed JSON.", licenseMappingFile), e); } catch (JsonMappingException e) { throw new MojoFailureException( String.format("Cannot deserialize JSON from file %s", licenseMappingFile), e); } catch (IOException e) { throw new MojoFailureException(e.getMessage(), e); } } getLog().info("Comparing the archive content with Maven project artifacts"); for (ActualEntry archiveEntry : archiveEntries) { List<License> licenses = null; //these licenses will be associated with the given archive entry for (MavenProject mavenProject : mavenProjectForDependencies) { mavenProject.getGroupId(); final String artifactId = mavenProject.getArtifactId(); final String version = mavenProject.getVersion(); final String jarName = artifactId + "-" + version + ".jar"; //guess jar name if (archiveEntry.getUri().endsWith(jarName)) { @SuppressWarnings("unchecked") final List<License> _licenses = mavenProject.getLicenses(); licenses = _licenses == null || _licenses.size() == 0 ? null : _licenses; break; } } final List<License> licensesMappingFile = additionalLicenseInformation .get(FileUtils.filename(archiveEntry.getUri())); if (licenses == null && licensesMappingFile == null) {//misising license information getLog().debug(String.format( "Cannot resolve license information for archive entry %s neither from the POM file nor the file for license mapping", archiveEntry)); //archive entry must be present even if there is no a matching Maven Project entries.put(archiveEntry.getUri(), Collections.<License>emptyList()); } else if (licenses != null && licensesMappingFile != null) {//licenses specified in both - POM and license mapping file getLog().warn(String.format( "The license information for file %s are defined in the POM file and also in the file for license mapping. Using license information from the the file for license mapping.", archiveEntry)); entries.put(archiveEntry.getUri(), licensesMappingFile); //mapping manually specified licenses precedes licenses from POM } else if (licenses != null) {//license information in POM entries.put(archiveEntry.getUri(), licenses);//license } else { //license information in mapping file //put additional license information to the object that holds this information entries.put(archiveEntry.getUri(), licensesMappingFile); } } final LicenseShow.LicenseOutput logOutput = new MavenLogOutput(getLog()); logOutput.output(entries); if (csvOutput) { final LicenseShow.CsvOutput csvOutput = new LicenseShow.CsvOutput(csvOutputFile); getLog().info(String.format("Creating license output to CSV file %s", csvOutputFile.getPath())); csvOutput.output(entries); } } catch (IOException e) { throw new MojoFailureException(e.getMessage(), e); } }
From source file:net.oneandone.maven.plugins.billofmaterials.CreateBillOfMaterialsMojo.java
License:Apache License
/** * Returns a string representation for the comment. * * @param userName current user// w w w . ja v a 2s.c o m * @return string representation for the comment. */ String projectCommentToString(final String userName) { final MavenProject project = getProject(); return String.format(Locale.ENGLISH, "# %s:%s:%s user=%s\n", project.getGroupId(), project.getArtifactId(), project.getVersion(), userName); }