use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenProject method getAnnotationProcessorOptions.
public Map<String, String> getAnnotationProcessorOptions() {
Element compilerConfig = getCompilerConfig();
if (compilerConfig == null) {
return Collections.emptyMap();
}
if (getProcMode() != MavenProject.ProcMode.NONE) {
return getAnnotationProcessorOptionsFromCompilerConfig(compilerConfig);
}
MavenPlugin bscMavenPlugin = findPlugin("org.bsc.maven", "maven-processor-plugin");
if (bscMavenPlugin != null) {
return getAnnotationProcessorOptionsFromProcessorPlugin(bscMavenPlugin);
}
return Collections.emptyMap();
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenProject method getAnnotationProcessorOptionsFromCompilerConfig.
private static Map<String, String> getAnnotationProcessorOptionsFromCompilerConfig(Element compilerConfig) {
Map<String, String> res = new LinkedHashMap<>();
String compilerArgument = compilerConfig.getChildText("compilerArgument");
addAnnotationProcessorOptionFomrParametersString(compilerArgument, res);
Element compilerArgs = compilerConfig.getChild("compilerArgs");
if (compilerArgs != null) {
for (Element e : compilerArgs.getChildren()) {
if (!StringUtil.equals(e.getName(), "arg"))
continue;
String arg = e.getTextTrim();
addAnnotationProcessorOption(arg, res);
}
}
Element compilerArguments = compilerConfig.getChild("compilerArguments");
if (compilerArguments != null) {
for (Element e : compilerArguments.getChildren()) {
String name = e.getName();
name = StringUtil.trimStart(name, "-");
if (name.length() > 1 && name.charAt(0) == 'A') {
res.put(name.substring(1), e.getTextTrim());
}
}
}
return res;
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenProject method getFilterPropertiesFiles.
public List<String> getFilterPropertiesFiles() {
List<String> res = getCachedValue(FILTERS_CACHE_KEY);
if (res == null) {
Element propCfg = getPluginGoalConfiguration("org.codehaus.mojo", "properties-maven-plugin", "read-project-properties");
if (propCfg != null) {
Element files = propCfg.getChild("files");
if (files != null) {
res = new ArrayList<>();
for (Element file : files.getChildren("file")) {
File f = new File(file.getValue());
if (!f.isAbsolute()) {
f = new File(getDirectory(), file.getValue());
}
res.add(f.getAbsolutePath());
}
}
}
if (res == null) {
res = getFilters();
} else {
res.addAll(getFilters());
}
res = putCachedValue(FILTERS_CACHE_KEY, res);
}
return res;
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenProjectReader method doReadProjectModel.
private RawModelReadResult doReadProjectModel(VirtualFile file, boolean headerOnly) {
MavenModel result = null;
Collection<MavenProjectProblem> problems = MavenProjectProblem.createProblemsList();
Set<String> alwaysOnProfiles = new THashSet<>();
String fileExtension = file.getExtension();
if (!"pom".equalsIgnoreCase(fileExtension) && !"xml".equalsIgnoreCase(fileExtension)) {
File basedir = getBaseDir(file);
MavenEmbeddersManager manager = MavenProjectsManager.getInstance(myProject).getEmbeddersManager();
MavenEmbedderWrapper embedder = manager.getEmbedder(MavenEmbeddersManager.FOR_MODEL_READ, basedir.getPath(), basedir.getPath());
try {
result = embedder.readModel(VfsUtilCore.virtualToIoFile(file));
} catch (MavenProcessCanceledException ignore) {
} finally {
manager.release(embedder);
}
if (result == null) {
result = new MavenModel();
result.setPackaging(MavenConstants.TYPE_JAR);
return new RawModelReadResult(result, problems, alwaysOnProfiles);
} else {
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
}
result = new MavenModel();
Element xmlProject = readXml(file, problems, MavenProjectProblem.ProblemType.SYNTAX);
if (xmlProject == null || !"project".equals(xmlProject.getName())) {
result.setPackaging(MavenConstants.TYPE_JAR);
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
MavenParent parent;
if (MavenJDOMUtil.hasChildByPath(xmlProject, "parent")) {
parent = new MavenParent(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.groupId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.version", UNKNOWN)), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.relativePath", "../pom.xml"));
result.setParent(parent);
} else {
parent = new MavenParent(new MavenId(UNKNOWN, UNKNOWN, UNKNOWN), "../pom.xml");
}
result.setMavenId(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "groupId", parent.getMavenId().getGroupId()), MavenJDOMUtil.findChildValueByPath(xmlProject, "artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "version", parent.getMavenId().getVersion())));
if (headerOnly)
return new RawModelReadResult(result, problems, alwaysOnProfiles);
result.setPackaging(MavenJDOMUtil.findChildValueByPath(xmlProject, "packaging", MavenConstants.TYPE_JAR));
result.setName(MavenJDOMUtil.findChildValueByPath(xmlProject, "name"));
readModelBody(result, result.getBuild(), xmlProject);
result.setProfiles(collectProfiles(file, xmlProject, problems, alwaysOnProfiles));
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenProjectReader method collectProfiles.
private void collectProfiles(List<Element> xmlProfiles, List<MavenProfile> result, String source) {
for (Element each : xmlProfiles) {
String id = MavenJDOMUtil.findChildValueByPath(each, "id");
if (isEmptyOrSpaces(id))
continue;
MavenProfile profile = new MavenProfile(id, source);
if (!addProfileIfDoesNotExist(profile, result))
continue;
Element xmlActivation = MavenJDOMUtil.findChildByPath(each, "activation");
if (xmlActivation != null) {
MavenProfileActivation activation = new MavenProfileActivation();
activation.setActiveByDefault("true".equals(MavenJDOMUtil.findChildValueByPath(xmlActivation, "activeByDefault")));
Element xmlOS = MavenJDOMUtil.findChildByPath(xmlActivation, "os");
if (xmlOS != null) {
activation.setOs(new MavenProfileActivationOS(MavenJDOMUtil.findChildValueByPath(xmlOS, "name"), MavenJDOMUtil.findChildValueByPath(xmlOS, "family"), MavenJDOMUtil.findChildValueByPath(xmlOS, "arch"), MavenJDOMUtil.findChildValueByPath(xmlOS, "version")));
}
activation.setJdk(MavenJDOMUtil.findChildValueByPath(xmlActivation, "jdk"));
Element xmlProperty = MavenJDOMUtil.findChildByPath(xmlActivation, "property");
if (xmlProperty != null) {
activation.setProperty(new MavenProfileActivationProperty(MavenJDOMUtil.findChildValueByPath(xmlProperty, "name"), MavenJDOMUtil.findChildValueByPath(xmlProperty, "value")));
}
Element xmlFile = MavenJDOMUtil.findChildByPath(xmlActivation, "file");
if (xmlFile != null) {
activation.setFile(new MavenProfileActivationFile(MavenJDOMUtil.findChildValueByPath(xmlFile, "exists"), MavenJDOMUtil.findChildValueByPath(xmlFile, "missing")));
}
profile.setActivation(activation);
}
readModelBody(profile, profile.getBuild(), each);
}
}
Aggregations