Java Code Examples for org.apache.maven.project.MavenProject#getArtifactId()

The following examples show how to use org.apache.maven.project.MavenProject#getArtifactId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenExecutorImpl.java    From developer-studio with Apache License 2.0 6 votes vote down vote up
public boolean setMavenParent(File mavenProjectLocation,
		File parentMavenProjectLocation) throws Exception {
	if (parentMavenProjectLocation==null){
		setMavenParent(mavenProjectLocation, (MavenProjectType)null);
	}else{
		File parentProjectPomFile = new File(parentMavenProjectLocation,"pom.xml");
		MavenProject parentProject = MavenUtils.getMavenProject(parentProjectPomFile);
		String relativeLocation = FileUtils.getRelativePath(parentMavenProjectLocation,mavenProjectLocation);
		if (!parentProject.getModules().contains(relativeLocation)){
			parentProject.getModules().add(relativeLocation);
		}
		MavenUtils.saveMavenProject(parentProject, parentProjectPomFile);
		MavenProjectType parentMavenProject=new MavenProjectType(parentProject.getGroupId(),parentProject.getArtifactId(),parentProject.getVersion());
		String relativePath = FileUtils.getRelativePath(mavenProjectLocation, parentProjectPomFile).replace('\\', '/');
		parentMavenProject.setRelativePath(relativePath);
		setMavenParent(mavenProjectLocation, parentMavenProject);
	}
	return true;
}
 
Example 2
Source File: Bom.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
public static Bom readBom(Path pomFile) throws MavenRepositoryException {
  RepositorySystem system = RepositoryUtility.newRepositorySystem();
  RepositorySystemSession session = RepositoryUtility.newSession(system);

  MavenProject mavenProject = RepositoryUtility.createMavenProject(pomFile, session);
  String coordinates = mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() 
      + ":" + mavenProject.getVersion();
  DependencyManagement dependencyManagement = mavenProject.getDependencyManagement();
  List<org.apache.maven.model.Dependency> dependencies = dependencyManagement.getDependencies();

  ArtifactTypeRegistry registry = session.getArtifactTypeRegistry();
  ImmutableList<Artifact> artifacts = dependencies.stream()
      .map(dependency -> RepositoryUtils.toDependency(dependency, registry))
      .map(Dependency::getArtifact)
      .filter(artifact -> !shouldSkipBomMember(artifact))
      .collect(ImmutableList.toImmutableList());
  
  Bom bom = new Bom(coordinates, artifacts);
  return bom;
}
 
Example 3
Source File: DependenciesMojo.java    From mangooio with Apache License 2.0 6 votes vote down vote up
private void boms(MavenProject project, Properties props) {
    while (project != null) {
        String artifactId = project.getArtifactId();
        if (isBom(artifactId)) {
            props.setProperty(BOMS + artifactId, coordinates(project.getArtifact()));
        }
        if (project.getDependencyManagement() != null) {
            for (Dependency dependency : project.getDependencyManagement().getDependencies()) {
                if ("import".equals(dependency.getScope())) {
                    props.setProperty(BOMS + dependency.getArtifactId(), coordinates(dependency));
                }
            }
        }
        project = project.getParent();
    }
}
 
Example 4
Source File: PackageMojo.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
public static String computeOutputName(MavenProject project, String classifier) {
    String finalName = project.getBuild().getFinalName();
    if (finalName != null) {
        if (finalName.endsWith(".jar")) {
            finalName = finalName.substring(0, finalName.length() - 4);
        }
        if (classifier != null && !classifier.isEmpty()) {
            finalName += "-" + classifier;
        }
        finalName += ".jar";
        return finalName;
    } else {
        finalName = project.getArtifactId() + "-" + project.getVersion();
        if (classifier != null && !classifier.isEmpty()) {
            finalName += "-" + classifier;
        }
        finalName += ".jar";
        return finalName;
    }
}
 
Example 5
Source File: MavenProjectConfigurator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Save the settings for the GWT nature in the application GWT preferences.
 *
 * @param project
 * @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);
}
 
Example 6
Source File: MvnPluginReport.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the set of {@link Application}s to be considered in the result report.
 * 
 * If the given {@link MavenProject} has the packaging type 'POM', applications
 * corresponding to all its sub-modules will be added to this set.
 * 
 * Depending on the configuration option {@link CoreConfiguration#REP_OVERRIDE_VER},
 * the application version is either taken from the POM or from configuration
 * setting {@link CoreConfiguration#APP_CTX_VERSI}.
 * 
 * @param _prj
 * @param _ids
 */
private void collectApplicationModules(MavenProject _prj, Set<Application> _ids) {

	// The version as specified in the POM of the given project		
	final String pom_version = _prj.getVersion();
	
	// The version specified with configuration option {@link CoreConfiguration#APP_CTX_VERSI}
	final String app_ctx_version = this.goal.getGoalContext().getApplication().getVersion();
	
	// The application module to be added
	final Application app = new Application(_prj.getGroupId(), _prj.getArtifactId(), pom_version);
	
	// Override version found in the respective pom.xml with the version of the application context
	// This becomes necessary if module scan results are NOT uploaded with the version found in the POM,
	// but with one specified in other ways, e.g., per -Dvulas.core.appContext.version
	if(this.vulasConfiguration.getConfiguration().getBoolean(CoreConfiguration.REP_OVERRIDE_VER, false) && !pom_version.equals(app_ctx_version)) {
		app.setVersion(app_ctx_version);
		this.getLog().warn("Report will include application version " + app + " rather than version [" + pom_version + "] specified in its POM");
	}
	
	_ids.add(app);
	if(_prj.getPackaging().equalsIgnoreCase("pom")) {
		for(MavenProject module: _prj.getCollectedProjects()) {
			this.collectApplicationModules(module, _ids);
		}
	}
}
 
Example 7
Source File: PackageMojo.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
public static String computeOutputName(Archive archive, MavenProject project, String classifier) {

        String output = archive.getOutputFileName();
        if (!StringUtils.isBlank(output)) {
            if (! output.endsWith(JAR_EXTENSION)) {
                output += JAR_EXTENSION;
            }
            return output;
        }

        String finalName = project.getBuild().getFinalName();
        if (finalName != null) {
            if (finalName.endsWith(JAR_EXTENSION)) {
                finalName = finalName.substring(0, finalName.length() - JAR_EXTENSION.length());
            }
            if (classifier != null && !classifier.isEmpty()) {
                finalName += "-" + classifier;
            }
            finalName += JAR_EXTENSION;
            return finalName;
        } else {
            finalName = project.getArtifactId() + "-" + project.getVersion();
            if (classifier != null && !classifier.isEmpty()) {
                finalName += "-" + classifier;
            }
            finalName += JAR_EXTENSION;
            return finalName;
        }
    }
 
Example 8
Source File: UpdateReleasePropertiesMojo.java    From revapi with Apache License 2.0 5 votes vote down vote up
@Override void updateProjectVersion(MavenProject project, Version version) throws MojoExecutionException {
    File rpf = getReleasePropertiesFile();
    Properties ps = readProperties(rpf);

    String relProp;
    String devProp;

    if (isSingleVersionForAllModules()) {
        relProp = "project.rel." + project.getGroupId() + ":" + project.getArtifactId();
        devProp = "project.dev." + project.getGroupId() + ":" + project.getArtifactId();
    } else {
        relProp = "releaseVersion";
        devProp = "developmentVersion";
    }

    ps.setProperty(relProp, version.toString());

    Version dev = version.clone();
    dev.setPatch(dev.getPatch() + 1);
    dev.setSuffix(releaseVersionSuffix == null ? "SNAPSHOT" : releaseVersionSuffix + "-SNAPSHOT");

    ps.setProperty(devProp, dev.toString());

    try (FileOutputStream out = new FileOutputStream(rpf)) {
        ps.store(out, null);
    } catch (IOException e) {
        throw new MojoExecutionException("Failed to write to the release.properties file.", e);
    }
}
 
Example 9
Source File: MavenDeployPlugin.java    From dew with Apache License 2.0 5 votes vote down vote up
@Override
public Resp<String> deployAble(FinalProjectConfig projectConfig) {
    MavenProject mavenProject = projectConfig.getMavenProject();
    String version = mavenProject.getVersion();
    if (version.trim().toLowerCase().endsWith("snapshot")) {
        // 如果快照仓库存在
        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");
        }
        // SNAPSHOT每次都要发
        return Resp.success("");
    } 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();
    // TODO auth
    repoUrl = repoUrl.endsWith("/") ? repoUrl : repoUrl + "/";
    repoUrl += mavenProject.getGroupId().replaceAll("\\.", "/")
            + "/"
            + mavenProject.getArtifactId()
            + "/"
            + version
            + "/maven-metadata.xml";
    if ($.http.getWrap(repoUrl).statusCode == 200) {
        return Resp.forbidden("The current version already exists");
    }
    return Resp.success("");
}
 
Example 10
Source File: GenerateBomMojo.java    From sundrio with Apache License 2.0 5 votes vote down vote up
private void build(MavenSession session, MavenProject project, List<MavenProject> allProjects, GoalSet goals) throws MojoExecutionException {
    session.setProjects(allProjects);
    ProjectIndex projectIndex = new ProjectIndex(session.getProjects());
    try {
        ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus(new BomDependencyGraph(session.getProjects()));
        ReactorContext reactorContext = new ReactorContextFactory(new MavenVersion(mavenVersion)).create(session.getResult(), projectIndex, Thread.currentThread().getContextClassLoader(),
                reactorBuildStatus, builder);
        List<TaskSegment> segments = segmentCalculator.calculateTaskSegments(session);
        for (TaskSegment segment : segments) {
            builder.buildProject(session, reactorContext, project, filterSegment(segment, goals));
        }
    } catch (Throwable t) {
        throw new MojoExecutionException("Error building generated bom:" + project.getArtifactId(), t);
    }
}
 
Example 11
Source File: MavenProjectConfigurator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the war output directory.
 *
 * @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;
}
 
Example 12
Source File: ReleasableModule.java    From multi-module-maven-release-plugin with MIT License 5 votes vote down vote up
public ReleasableModule(MavenProject project, VersionName version, String equivalentVersion, String relativePathToModule) {
    this.project = project;
    this.version = version;
    this.equivalentVersion = equivalentVersion;
    this.relativePathToModule = relativePathToModule;
    this.tagName = project.getArtifactId() + "-" + version.releaseVersion();
}
 
Example 13
Source File: SmartBuilderImpl.java    From takari-smart-builder with Apache License 2.0 4 votes vote down vote up
private static String projectGA(MavenProject project) {
  return project.getGroupId() + ":" + project.getArtifactId();
}
 
Example 14
Source File: ReactorModelPool.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
public void addProject( MavenProject project )
{
    Coordinates coordinates = new Coordinates( project.getGroupId(), project.getArtifactId(),
            project.getVersion() );
    models.put( coordinates, project.getFile() );
}
 
Example 15
Source File: ReactorBuildStats.java    From takari-smart-builder with Apache License 2.0 4 votes vote down vote up
private static String projectGA(MavenProject project) {
  return project.getGroupId() + ":" + project.getArtifactId();
}
 
Example 16
Source File: AbstractVersionModifyingMojo.java    From revapi with Apache License 2.0 4 votes vote down vote up
void updateProjectVersion(MavenProject project, Version version) throws MojoExecutionException {
    try {

        int indentationSize;
        try (BufferedReader rdr = new BufferedReader(new FileReader(project.getFile()))) {
            indentationSize = XmlUtil.estimateIndentationSize(rdr);
        }

        VTDGen gen = new VTDGen();
        gen.enableIgnoredWhiteSpace(true);
        gen.parseFile(project.getFile().getAbsolutePath(), true);

        VTDNav nav = gen.getNav();
        AutoPilot ap = new AutoPilot(nav);
        XMLModifier mod = new XMLModifier(nav);

        ap.selectXPath("/project/version");
        if (ap.evalXPath() != -1) {
            //found the version
            int textPos = nav.getText();
            mod.updateToken(textPos, version.toString());
        } else {
            if (!forceVersionUpdate && !project.getParent().getVersion().equals(version.toString())) {
                throw new MojoExecutionException("Project " + project.getArtifactId() + " inherits the version" +
                        " from the parent project (" + project.getParent().getVersion() + ") but should have a" +
                        " different version according to the configured rules (" + version.toString() + "). If" +
                        " you wish to insert an explicit version instead of inheriting it, set the " +
                        Props.forceVersionUpdate.NAME + " property to true.");
            }

            //place the version after the artifactId
            ap.selectXPath("/project/artifactId");
            if (ap.evalXPath() == -1) {
                throw new MojoExecutionException("Failed to find artifactId element in the pom.xml of project "
                        + project.getArtifact().getId() + " when trying to insert a version tag after it.");
            } else {
                StringBuilder versionLine = new StringBuilder();
                versionLine.append('\n');
                for (int i = 0; i < indentationSize; ++i) {
                    versionLine.append(' ');
                }
                versionLine.append("<version>").append(version.toString()).append("</version>");
                mod.insertAfterElement(versionLine.toString());
            }
        }

        try (OutputStream out = new FileOutputStream(project.getFile())) {
            mod.output(out);
        }
    } catch (IOException | ModifyException | NavException | XPathParseException | XPathEvalException | TranscodeException e) {
        throw new MojoExecutionException("Failed to update the version of project " + project, e);
    }
}
 
Example 17
Source File: GenerateProcess.java    From dew with Apache License 2.0 4 votes vote down vote up
/**
 * Process.
 *
 * @param mojo          the mojo
 * @param mavenProject  the maven project
 * @param mavenSession  the maven session
 * @param pluginManager the plugin manager
 * @param language      the language
 * @param inputSpec     the input spec
 * @return the file
 */
public static File process(SDKGenMojo mojo, MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager,
                           String language, String inputSpec) {
    log.info("Generate SDK by {}", language);
    /*MavenHelper.invoke("io.swagger.core.v3", "swagger-maven-plugin", "2.1.1",
            "resolve", new HashMap<>() {
                {
                    put("outputFileName", output.getParent());
                    put("goals", new HashMap<>() {
                        {
                            put("goal", "-P release");
                        }
                    });
                    put("mavenOpts", "");
                }
            }, mavenProject, mavenSession, pluginManager);*/

    String groupId = mavenProject.getGroupId();
    String artifactId = mavenProject.getArtifactId() + ".sdk";
    String basePackage = NameHelper.formatPackage(groupId + "." + mavenProject.getArtifactId() + ".sdk");
    setAndGetIfNotExist(mojo, "apiPackage", basePackage + ".api");
    setAndGetIfNotExist(mojo, "modelPackage", basePackage + ".model");
    setAndGetIfNotExist(mojo, "invokerPackage", basePackage + ".invoker");
    setAndGetIfNotExist(mojo, "groupId", groupId);
    setAndGetIfNotExist(mojo, "artifactId", artifactId);
    setAndGetIfNotExist(mojo, "artifactVersion", mavenProject.getVersion());
    setValueToParentField(mojo, "language", language);
    setValueToParentField(mojo, "inputSpec", inputSpec);
    String lang;
    switch (language) {
        case "group.idealworld.dew.sdkgen.lang.java.DewJavaClientCodegen":
            lang = "java";
            break;
        default:
            lang = language;
    }
    String finalLang = lang;
    setAndGetIfNotExist(mojo, "configOptions", new HashMap<String, Object>() {
        {
            put("sourceFolder", "src/main/" + finalLang);
        }
    });
    return (File) $.bean.getValue(mojo, "output");
}
 
Example 18
Source File: ConfigBuilder.java    From dew with Apache License 2.0 4 votes vote down vote up
/**
 * Build project optional.
 *
 * @param dewConfig                       the dew config
 * @param appKindPlugin                   the app kind plugin
 * @param deployPlugin                    the deploy plugin
 * @param mavenSession                    the maven session
 * @param mavenProject                    the maven project
 * @param inputProfile                    the input profile
 * @param inputDockerHost                 the input docker host
 * @param inputDockerRegistryUrl          the input docker registry url
 * @param inputDockerRegistryUserName     the input docker registry user name
 * @param inputDockerRegistryPassword     the input docker registry password
 * @param inputKubeBase64Config           the input kube base 64 config
 * @param dockerHostAppendOpt             the docker host append opt
 * @param dockerRegistryUrlAppendOpt      the docker registry url append opt
 * @param dockerRegistryUserNameAppendOpt the docker registry user name append opt
 * @param dockerRegistryPasswordAppendOpt the docker registry password append opt
 * @return the result
 */
public static FinalProjectConfig buildProject(DewConfig dewConfig, AppKindPlugin appKindPlugin, DeployPlugin deployPlugin,
                                              MavenSession mavenSession, 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) {
    // 格式化
    inputProfile = inputProfile.toLowerCase();
    dewConfig.setProfiles(
            dewConfig.getProfiles().entrySet().stream()
                    .collect(Collectors.toMap(profile -> profile.getKey().toLowerCase(), Map.Entry::getValue)));

    // 命名空间与Kubernetes集群冲突检查,不同环境如果命名空间同名则要求位于不同的Kubernetes集群中
    Set<String> envChecker = dewConfig.getProfiles().values().stream()
            .map(prof -> prof.getNamespace() + prof.getKube().getBase64Config())
            .collect(Collectors.toSet());
    if (!dewConfig.getNamespace().isEmpty() && !dewConfig.getKube().getBase64Config().isEmpty()) {
        envChecker.add(dewConfig.getNamespace() + dewConfig.getKube().getBase64Config());
    } else {
        envChecker.add("");
    }
    if (envChecker.size() != dewConfig.getProfiles().size() + 1) {
        throw new ConfigException("[" + mavenProject.getArtifactId() + "] "
                + "Namespace and kubernetes cluster between different environments cannot be the same");
    }
    // 指定的环境是否存在
    if (!inputProfile.equals(FLAG_DEW_DEVOPS_DEFAULT_PROFILE) && !dewConfig.getProfiles().containsKey(inputProfile)) {
        throw new ConfigException("[" + mavenProject.getArtifactId() + "] Can't be found [" + inputProfile + "] profile");
    }
    FinalProjectConfig finalProjectConfig = doBuildProject(dewConfig, appKindPlugin, deployPlugin, mavenSession, mavenProject,
            inputProfile, inputDockerHost, inputDockerRegistryUrl,
            inputDockerRegistryUserName, inputDockerRegistryPassword, inputKubeBase64Config,
            dockerHostAppendOpt, dockerRegistryUrlAppendOpt, dockerRegistryUserNameAppendOpt, dockerRegistryPasswordAppendOpt);
    if (!finalProjectConfig.getSkip() && finalProjectConfig.getKube().getBase64Config().isEmpty()) {
        throw new ConfigException("[" + mavenProject.getArtifactId() + "] Kubernetes config can't be empty");
    }
    return finalProjectConfig;
}
 
Example 19
Source File: Info.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Messages({
    "# {0} - dir basename", "LBL_misconfigured_project={0} [unloadable]",
    "# {0} - path to project", "TXT_Maven_project_at=Maven project at {0}"
})
private String getDisplayName(NbMavenProject nb) {
    MavenProject pr = nb.getMavenProject();
    if (NbMavenProject.isErrorPlaceholder(pr)) {
        return LBL_misconfigured_project(project.getProjectDirectory().getNameExt());
    }
    String custom = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_DISPLAY_NAME, true);
    if (custom == null) {
        custom = NbPreferences.forModule(Info.class).get(MavenSettings.PROP_PROJECTNODE_NAME_PATTERN, null);
    }
    if (custom != null) {
        //we evaluate because of global property and property in nb-configuration.xml file. The pom.xml originating value should be already resolved.
        ExpressionEvaluator evaluator = PluginPropertyUtils.createEvaluator(project);
        try {
            Object s = evaluator.evaluate(custom);
            if (s != null) {
                //just make sure the name gets resolved
                String ss = s.toString().replace("${project.name)", "" + pr.getGroupId() + ":" + pr.getArtifactId());
                return ss;
            }
        } catch (ExpressionEvaluationException ex) {
            //now just continue to the default processing
            LOG.log(Level.INFO, "bad display name expression:" + custom, ex);
        }
    }

    String toReturn = pr.getName();
    if (toReturn == null) {
        String grId = pr.getGroupId();
        String artId = pr.getArtifactId();
        if (grId != null && artId != null) {
            toReturn = grId + ":" + artId; //NOI18N
        } else {
            toReturn = TXT_Maven_project_at(FileUtil.getFileDisplayName(project.getProjectDirectory()));
        }
    }
    return toReturn;
}
 
Example 20
Source File: Utils.java    From deadcode4j with Apache License 2.0 2 votes vote down vote up
/**
 * Returns <i>groupId:artifactId</i> for the specified project.
 *
 * @since 1.2.0
 */
@Nonnull
public static String getKeyFor(@Nonnull MavenProject project) {
    return project.getGroupId() + ":" + project.getArtifactId();
}