use of org.gradle.api.XmlProvider in project gradle by gradle.
the class IdeaScalaConfigurer method configure.
public void configure() {
rootProject.getGradle().addBuildListener(new BuildAdapter() {
public void projectsEvaluated(Gradle gradle) {
VersionNumber ideaTargetVersion = findIdeaTargetVersion();
final boolean useScalaSdk = ideaTargetVersion == null || IDEA_VERSION_WHEN_SCALA_SDK_WAS_INTRODUCED.compareTo(ideaTargetVersion) <= 0;
final Collection<Project> scalaProjects = findProjectsApplyingIdeaAndScalaPlugins();
final Map<String, ProjectLibrary> scalaCompilerLibraries = Maps.newHashMap();
rootProject.getTasks().getByName("ideaProject").doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
if (scalaProjects.size() > 0) {
scalaCompilerLibraries.clear();
scalaCompilerLibraries.putAll(resolveScalaCompilerLibraries(scalaProjects, useScalaSdk));
declareUniqueProjectLibraries(Sets.newLinkedHashSet(scalaCompilerLibraries.values()));
}
}
});
rootProject.configure(scalaProjects, new Action<Project>() {
@Override
public void execute(final Project project) {
project.getExtensions().getByType(IdeaModel.class).getModule().getIml().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
if (useScalaSdk) {
declareScalaSdk(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
} else {
declareScalaFacet(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
}
}
});
}
});
}
});
}
use of org.gradle.api.XmlProvider in project gradle by gradle.
the class DefaultDeploymentDescriptor method readFrom.
@Override
public DeploymentDescriptor readFrom(Reader reader) {
try {
Node appNode = createParser().parse(reader);
version = (String) appNode.attribute("version");
for (final Node child : Cast.<List<Node>>uncheckedCast(appNode.children())) {
String childLocalName = localNameOf(child);
if (childLocalName.equals("application-name")) {
applicationName = child.text();
} else if (childLocalName.equals("initialize-in-order")) {
initializeInOrder = Boolean.valueOf(child.text());
} else if (childLocalName.equals("description")) {
description = child.text();
} else if (childLocalName.equals("display-name")) {
displayName = child.text();
} else if (childLocalName.equals("library-directory")) {
libraryDirectory = child.text();
} else if (childLocalName.equals("module")) {
EarModule module = null;
for (Node moduleNode : Cast.<List<Node>>uncheckedCast(child.children())) {
String moduleNodeLocalName = localNameOf(moduleNode);
if (moduleNodeLocalName.equals("web")) {
String webUri = childNodeText(moduleNode, "web-uri");
String contextRoot = childNodeText(moduleNode, "context-root");
module = new DefaultEarWebModule(webUri, contextRoot);
modules.add(module);
moduleTypeMappings.put(module.getPath(), "web");
} else if (moduleNodeLocalName.equals("alt-dd")) {
assert module != null;
module.setAltDeployDescriptor(moduleNode.text());
} else {
module = new DefaultEarModule(moduleNode.text());
modules.add(module);
moduleTypeMappings.put(module.getPath(), moduleNodeLocalName);
}
}
} else if (childLocalName.equals("security-role")) {
String roleName = childNodeText(child, "role-name");
String description = childNodeText(child, "description");
securityRoles.add(new DefaultEarSecurityRole(roleName, description));
} else {
withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
xmlProvider.asNode().append(child);
}
});
}
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
} catch (SAXException ex) {
throw new UncheckedException(ex);
} finally {
IOUtils.closeQuietly(reader);
}
return this;
}
use of org.gradle.api.XmlProvider in project gradle by gradle.
the class IvyPluginPublishingRules method createIvyMarkerPublication.
private void createIvyMarkerPublication(PluginDeclaration declaration, final IvyPublication mainPublication, PublicationContainer publications) {
String pluginId = declaration.getId();
IvyPublication publication = publications.create(declaration.getName() + "PluginMarkerIvy", IvyPublication.class);
publication.setOrganisation(pluginId);
publication.setModule(pluginId + PLUGIN_MARKER_SUFFIX);
publication.descriptor(new Action<IvyModuleDescriptorSpec>() {
@Override
public void execute(IvyModuleDescriptorSpec descriptor) {
descriptor.withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.getElementsByTagName("dependencies").item(0);
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Attr org = document.createAttribute("org");
org.setValue(mainPublication.getOrganisation());
dependency.getAttributes().setNamedItem(org);
Attr name = document.createAttribute("name");
name.setValue(mainPublication.getModule());
dependency.getAttributes().setNamedItem(name);
Attr rev = document.createAttribute("rev");
rev.setValue(mainPublication.getRevision());
dependency.getAttributes().setNamedItem(rev);
}
});
}
});
}
use of org.gradle.api.XmlProvider in project gradle by gradle.
the class MavenPluginPublishingRules method createMavenMarkerPublication.
private void createMavenMarkerPublication(PluginDeclaration declaration, final MavenPublication coordinates, PublicationContainer publications) {
String pluginId = declaration.getId();
MavenPublication publication = publications.create(declaration.getName() + "PluginMarkerMaven", MavenPublication.class);
publication.setArtifactId(pluginId + PLUGIN_MARKER_SUFFIX);
publication.setGroupId(pluginId);
publication.getPom().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.appendChild(document.createElement("dependencies"));
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Node groupId = dependency.appendChild(document.createElement("groupId"));
groupId.setTextContent(coordinates.getGroupId());
Node artifactId = dependency.appendChild(document.createElement("artifactId"));
artifactId.setTextContent(coordinates.getArtifactId());
Node version = dependency.appendChild(document.createElement("version"));
version.setTextContent(coordinates.getVersion());
}
});
}
Aggregations