use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenModuleBuilderTest method testAddingParentWithInheritedProperties.
public void testAddingParentWithInheritedProperties() throws Exception {
if (!hasMavenInstallation())
return;
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
setModuleNameAndRoot("module", getProjectPath() + "/module");
setParentProject(myProjectPom);
setInheritedOptions(true, true);
createNewModule(new MavenId("org.foo", "module", "1.0"));
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + " <parent>\n" + " <artifactId>project</artifactId>\n" + " <groupId>test</groupId>\n" + " <version>1</version>\n" + " </parent>\n" + " <modelVersion>4.0.0</modelVersion>\n" + "\n" + " <artifactId>module</artifactId>\n" + "\n" + "\n" + "</project>", VfsUtil.loadText(myProjectRoot.findFileByRelativePath("module/pom.xml")));
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenModuleBuilderTest method testInheritJdkFromProject.
public void testInheritJdkFromProject() throws Exception {
if (!hasMavenInstallation())
return;
createNewModule(new MavenId("org.foo", "module", "1.0"));
ModuleRootManager manager = ModuleRootManager.getInstance(getModule("module"));
assertTrue(manager.isSdkInherited());
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenModuleBuilderTest method testAddingManagedProjectIfNoArrgerator.
public void testAddingManagedProjectIfNoArrgerator() throws Exception {
if (!hasMavenInstallation())
return;
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
assertEquals(1, myProjectsManager.getProjectsTreeForTests().getManagedFilesPaths().size());
setModuleNameAndRoot("module", getProjectPath() + "/module");
setAggregatorProject(null);
createNewModule(new MavenId("org.foo", "module", "1.0"));
myProjectRoot.findFileByRelativePath("module/pom.xml");
assertEquals(2, myProjectsManager.getProjectsTreeForTests().getManagedFilesPaths().size());
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenModuleBuilderTest method testAddingParent.
public void testAddingParent() throws Exception {
if (!hasMavenInstallation())
return;
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
setModuleNameAndRoot("module", getProjectPath() + "/module");
setParentProject(myProjectPom);
createNewModule(new MavenId("org.foo", "module", "1.0"));
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + " <parent>\n" + " <artifactId>project</artifactId>\n" + " <groupId>test</groupId>\n" + " <version>1</version>\n" + " </parent>\n" + " <modelVersion>4.0.0</modelVersion>\n" + "\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>module</artifactId>\n" + " <version>1.0</version>\n" + "\n" + "\n" + "</project>", VfsUtil.loadText(myProjectRoot.findFileByRelativePath("module/pom.xml")));
}
use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.
the class MavenPropertyResolver method doResolveProperty.
@Nullable
private static String doResolveProperty(String propName, MavenProjectsManager projectsManager, MavenProject mavenProject, Properties additionalProperties) {
boolean hasPrefix = false;
String unprefixed = propName;
if (propName.startsWith("pom.")) {
unprefixed = propName.substring("pom.".length());
hasPrefix = true;
} else if (propName.startsWith("project.")) {
unprefixed = propName.substring("project.".length());
hasPrefix = true;
}
MavenProject selectedProject = mavenProject;
while (unprefixed.startsWith("parent.")) {
MavenId parentId = selectedProject.getParentId();
if (parentId == null)
return null;
unprefixed = unprefixed.substring("parent.".length());
if (unprefixed.equals("groupId")) {
return parentId.getGroupId();
}
if (unprefixed.equals("artifactId")) {
return parentId.getArtifactId();
}
if (unprefixed.equals("version")) {
return parentId.getVersion();
}
selectedProject = projectsManager.findProject(parentId);
if (selectedProject == null)
return null;
}
if (unprefixed.equals("basedir") || (hasPrefix && mavenProject == selectedProject && unprefixed.equals("baseUri"))) {
return selectedProject.getDirectory();
}
if ("java.home".equals(propName)) {
String jreDir = MavenUtil.getModuleJreHome(projectsManager, mavenProject);
if (jreDir != null) {
return jreDir;
}
}
if ("java.version".equals(propName)) {
String javaVersion = MavenUtil.getModuleJavaVersion(projectsManager, mavenProject);
if (javaVersion != null) {
return javaVersion;
}
}
String result;
result = MavenUtil.getPropertiesFromMavenOpts().get(propName);
if (result != null)
return result;
result = MavenServerUtil.collectSystemProperties().getProperty(propName);
if (result != null)
return result;
result = selectedProject.getModelMap().get(unprefixed);
if (result != null)
return result;
result = additionalProperties.getProperty(propName);
if (result != null)
return result;
result = mavenProject.getProperties().getProperty(propName);
if (result != null)
return result;
if ("settings.localRepository".equals(propName)) {
return mavenProject.getLocalRepository().getAbsolutePath();
}
return null;
}
Aggregations