如何以编程方式解析CDT构建变量{ProjName}?这是我要做的事情:
我试图获取配置的artifactName,然后用项目名称替换其中的{ProjName}。现在,我不想通过搜索来替换这个变量,因为用户可以在那里指定任何其他变量名。
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:我发布了这个问题的答案供我将来参考。
答案 0 :(得分:0)
这就是我完成它的方式:
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);
}