Java 类org.gradle.api.XmlProvider 实例源码

项目:Reer    文件:GenerateProjectFileTask.java   
@Override
protected void configure(VisualStudioProjectFile projectFile) {
    DefaultVisualStudioProject vsProject = visualStudioProject;
    projectFile.setGradleCommand(buildGradleCommand());
    projectFile.setProjectUuid(vsProject.getUuid());

    for (File sourceFile : vsProject.getSourceFiles()) {
        projectFile.addSourceFile(sourceFile);
    }

    for (File resourceFile : vsProject.getResourceFiles()) {
        projectFile.addResource(resourceFile);
    }

    for (File headerFile : vsProject.getHeaderFiles()) {
        projectFile.addHeaderFile(headerFile);
    }

    for (VisualStudioProjectConfiguration configuration : vsProject.getConfigurations()) {
        projectFile.addConfiguration(configuration);
    }

    for (Action<? super XmlProvider> xmlAction : vsProject.getProjectFile().getXmlActions()) {
        getXmlTransformer().addAction(xmlAction);
    }
}
项目:Reer    文件:GenerateFiltersFileTask.java   
@Override
protected void configure(final VisualStudioFiltersFile filtersFile) {
    DefaultVisualStudioProject vsProject = visualStudioProject;

    for (File sourceFile : vsProject.getSourceFiles()) {
        filtersFile.addSource(sourceFile);
    }

    for (File headerFile : vsProject.getHeaderFiles()) {
        filtersFile.addHeader(headerFile);
    }

    for (Action<? super XmlProvider> xmlAction : vsProject.getFiltersFile().getXmlActions()) {
        getXmlTransformer().addAction(xmlAction);
    }
}
项目:Reer    文件:MavenPluginPublishingRules.java   
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());
        }
    });
}
项目:Reer    文件:IdeaScalaConfigurer.java   
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());
                            }
                        }
                    });
                }
            });
        }
    });
}
项目:shipkit    文件:PomCustomizer.java   
/**
 * Customizes the pom. The method requires following properties on root project to function correctly:
 */
public static void customizePom(final Project project, final ShipkitConfiguration conf, final MavenPublication publication) {
    publication.getPom().withXml(new Action<XmlProvider>() {
        public void execute(XmlProvider xml) {
            String archivesBaseName = (String) project.getProperties().get("archivesBaseName");
            File contributorsFile = contributorsFile(project);
            LOG.info("  Read project contributors from file: " + contributorsFile.getAbsolutePath());

            // It can happens that contributorsFile doesn't exist e.g. when shipkit.team.contributors is NOT empty
            ProjectContributorsSet contributorsFromGitHub = new ProjectContributorsSerializer()
                    .deserialize(IOUtil.readFullyOrDefault(contributorsFile, "[]"));
            LOG.info("  Customizing pom for publication " + publication.getName() + " in " + project.toString() +
                    "\n   - Module name (project.archivesBaseName): " + archivesBaseName +
                    "\n   - Description (project.description): " + project.getDescription() +
                    "\n   - GitHub repository (project.rootProject.shipkit.gitHub.repository): "
                            + conf.getGitHub().getRepository() +
                    "\n   - Developers (project.rootProject.shipkit.team.developers): "
                            + StringUtil.join(conf.getTeam().getDevelopers(), ", ") +
                    "\n   - Contributors (project.rootProject.shipkit.team.contributors): "
                            + StringUtil.join(conf.getTeam().getContributors(), ", ") +
                    "\n   - Contributors read from GitHub: "
                            + StringUtil.join(contributorsFromGitHub.toConfigNotation(), ", "));

            customizePom(xml.asNode(), conf, archivesBaseName, project.getDescription(), contributorsFromGitHub);
        }
    });
}
项目:goomph    文件:ConfigMisc.java   
/** Creates an XML string from a groovy.util.Node. */
public static void modifyXmlInPlace(File file, Action<XmlProvider> action) throws IOException {
    String original = Files.toString(file, StandardCharsets.UTF_8);

    XmlTransformer transformer = new XmlTransformer();
    transformer.addAction(action);
    try (OutputStream output = Files.asByteSink(file).openBufferedStream()) {
        transformer.transform(original, output);
    }
}
项目:gradle-defaults    文件:MavenPublishPublications.java   
private static void configPom(Project project, XmlProvider xmlProvider) {
    val extension = defaultsExtension(project);

    val node = xmlProvider.asNode();
    name(node, project);
    description(node, project);
    siteUrl(node, extension);
    organization(node, extension);
    licenses(node, extension);
    developers(node, extension);
    contributors(node, extension);
    scm(node, extension);
    dependencies(node, project);
}
项目:gradle-defaults    文件:ExtIntellijPlugin.java   
private static void customizeProjectXml(Project project, XmlProvider provider) {
    val rootNode = provider.asNode();

    addGradleHome(project, rootNode);

    setupCodeStyle(rootNode, String.valueOf(codeStyleExtension(project).getIndentSize()));
    setupCompiler(project, rootNode);
}
项目:Reer    文件:DefaultVisualStudioProject.java   
public void withXml(Action<? super XmlProvider> action) {
    actions.add(action);
}
项目:Reer    文件:DefaultVisualStudioProject.java   
public List<Action<? super XmlProvider>> getXmlActions() {
    return actions;
}
项目:Reer    文件:DefaultMavenPom.java   
public DefaultMavenPom withXml(final Action<XmlProvider> action) {
    withXmlActions.addAction(action);
    return this;
}
项目:Reer    文件:MavenPomFileGenerator.java   
public MavenPomFileGenerator withXml(final Action<XmlProvider> action) {
    xmlTransformer.addAction(action);
    return this;
}
项目:Reer    文件:DefaultMavenPom.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlAction.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to generated POM", action));
}
项目:Reer    文件:DefaultMavenPom.java   
public Action<XmlProvider> getXmlAction() {
    return xmlAction;
}
项目:Reer    文件:DefaultDeploymentDescriptor.java   
@Override
public DeploymentDescriptor withXml(Action<? super XmlProvider> action) {
    transformer.addAction(action);
    return this;
}
项目:Reer    文件:DefaultIvyModuleDescriptorSpec.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlActions.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to Ivy module descriptor", action));
}
项目:Reer    文件:DefaultIvyModuleDescriptorSpec.java   
public Action<XmlProvider> getXmlAction() {
    return xmlActions;
}
项目:Reer    文件:IvyDescriptorFileGenerator.java   
public IvyDescriptorFileGenerator withXml(final Action<XmlProvider> action) {
    xmlTransformer.addAction(action);
    return this;
}
项目:Reer    文件:XmlTransformer.java   
public void addAction(Action<? super XmlProvider> provider) {
    actions.add(provider);
}
项目:Reer    文件:XmlTransformer.java   
public void apply(Iterable<Action<? super XmlProvider>> actions) {
    for (Action<? super XmlProvider> action : actions) {
        action.execute(this);
    }
}
项目:gradle-project-config    文件:EclipseConfigPlugin.java   
/**
 * Configure the classpath XML document
 *
 * @param xml XML document to configure
 */
protected void configureClasspathXml(XmlProvider xml) {
    Element root = xml.asElement();
    NodeList classpathentries = root.getElementsByTagName("classpathentry");

    getLogger().debug("Checking classpath entries for {}", getProject());

    for (Node classpathentry : Nodes.elements(classpathentries)) {
        String kind = Nodes.attributeValue(classpathentry, "kind");
        String path = Nodes.attributeValue(classpathentry, "path");

        getLogger().debug("Checking classpath entry '{}' of kind '{}'", path, kind);

        switch (kind) {
            case "lib": {
                if (GRADLE_JAR_PATTERN.matcher(path).find()) {
                    configureLibraryEntry((Element) classpathentry, path, "gradle-api-annotations");
                }
                else {
                    File file = new File(path);
                    Optional<ProjectElement<ResolvedArtifact>> artifact = Projects.findResolvedArtifact(
                            getProject().getAllprojects(), p -> true, a -> a.getFile().equals(file));

                    artifact.ifPresent(a -> {
                        getLogger().debug("Resolved classpath to artifact '{}'", a.getElement().getId());

                        configureLibraryEntry((Element) classpathentry, path,
                                a.getElement().getName() + "-annotations");
                    });
                }

                break;
            }

            case "con": {
                if (path.startsWith("org.eclipse.jdt.launching.JRE_CONTAINER/")) {
                    configureLibraryEntry((Element) classpathentry, path, "jdk-annotations");
                }

                break;
            }

            case "src": {
                configureSourceEntry((Element) classpathentry);
            }
        }
    }
}
项目:goomph    文件:OomphIdeExtension.java   
/**
 * Modifies the xml that was written in a previous call to {@link #workspaceFile(String, Object)} or
 * {@link #workspaceXml(String, Action)}. However, 
 */
@SuppressWarnings("unchecked")
public void workspaceXml(String destination, Action<XmlProvider> xmlSupplier) {
    workspaceXmls.merge(destination, xmlSupplier, (before, after) -> Actions.composite(before, after));
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public DefaultMavenPom withXml(final Action<XmlProvider> action) {
    withXmlActions.addAction(action);
    return this;
}
项目:Pushjet-Android    文件:MavenPomFileGenerator.java   
public MavenPomFileGenerator withXml(final Action<XmlProvider> action) {
    xmlTransformer.addAction(action);
    return this;
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlAction.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to generated POM", action));
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public Action<XmlProvider> getXmlAction() {
    return xmlAction;
}
项目:Pushjet-Android    文件:DefaultIvyModuleDescriptorSpec.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlActions.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to Ivy module descriptor", action));
}
项目:Pushjet-Android    文件:DefaultIvyModuleDescriptorSpec.java   
public Action<XmlProvider> getXmlAction() {
    return xmlActions;
}
项目:Pushjet-Android    文件:XmlTransformer.java   
public void addAction(Action<? super XmlProvider> provider) {
    actions.add(provider);
}
项目:Pushjet-Android    文件:XmlTransformer.java   
public void addAction(Closure closure) {
    actions.add(new ClosureBackedAction<XmlProvider>(closure));
}
项目:Pushjet-Android    文件:XmlTransformer.java   
public void apply(Iterable<Action<? super XmlProvider>> actions) {
    for (Action<? super XmlProvider> action : actions) {
        action.execute(this);
    }
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public DefaultMavenPom withXml(final Action<XmlProvider> action) {
    withXmlActions.addAction(action);
    return this;
}
项目:Pushjet-Android    文件:MavenPomFileGenerator.java   
public MavenPomFileGenerator withXml(final Action<XmlProvider> action) {
    xmlTransformer.addAction(action);
    return this;
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlAction.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to generated POM", action));
}
项目:Pushjet-Android    文件:DefaultMavenPom.java   
public Action<XmlProvider> getXmlAction() {
    return xmlAction;
}
项目:Pushjet-Android    文件:DefaultIvyModuleDescriptor.java   
public void withXml(Action<? super XmlProvider> action) {
    xmlActions.add(new UserCodeAction<XmlProvider>("Could not apply withXml() to Ivy module descriptor", action));
}
项目:Pushjet-Android    文件:DefaultIvyModuleDescriptor.java   
public Action<XmlProvider> getXmlAction() {
    return xmlActions;
}
项目:Pushjet-Android    文件:IvyDescriptorFileGenerator.java   
public IvyDescriptorFileGenerator withXml(final Action<XmlProvider> action) {
    xmlTransformer.addAction(action);
    return this;
}
项目:Pushjet-Android    文件:XmlTransformer.java   
public void addAction(Action<? super XmlProvider> provider) {
    actions.add(provider);
}
项目:Pushjet-Android    文件:XmlTransformer.java   
public void addAction(Closure closure) {
    actions.add(new ClosureBackedAction<XmlProvider>(closure));
}