Destructor
Destructor

Reputation: 3294

How to resolve CDT build variable ${ProjName} programatically?

How to resolve the CDT build variable {ProjName} programmatically? Here is what I am trying to do:
I am trying to get the artifactName of a configuration and then replace the {ProjName} in it with the project name. Now, I don't want to replace just this variable by searching for it, because user may specify any other variable name there.

private String getResolvedArticatName(final IConfiguration configuration){
    String artifactName = configuration.getArtifactName();
    String resolvedArtifactName = resolve(artifactName);
    return resolvedArtifactName;
}

private String resolve(String artifactName){
    //resolve the parameter, artifactName, and return it;
}

PS: I posted answer to this question for my future reference.

Upvotes: 1

Views: 600

Answers (1)

Destructor
Destructor

Reputation: 3294

This is how I got it done:

private String resolve(final String artifactName, final IConfiguration configuration) throws CdtVariableException{
        ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
        return mngr.resolveValue(artifactName, "", File.pathSeparator, ManagedBuildManager.getDescriptionForConfiguration(configuration));
}

private String getResolvedArticatName(final IConfiguration configuration) throws CdtVariableException{
    String artifactName = configuration.getArtifactName();
    return resolve(artifactName);
}

Upvotes: 1

Related Questions