Java 类org.gradle.api.internal.plugins.DslObject 实例源码

项目:Reer    文件:AbstractOptions.java   
public Map<String, Object> optionMap() {
    final Map<String, Object> map = Maps.newHashMap();
    Class<?> currClass = new DslObject(this).getDeclaredType();
    while (currClass != AbstractOptions.class) {
        for (final Field field : currClass.getDeclaredFields()) {
            if (isOptionField(field)) {
                DeprecationLogger.whileDisabled(new Runnable() {
                    @Override
                    public void run() {
                        addValueToMapIfNotNull(map, field);
                    }
                });
            }
        }
        currClass = currClass.getSuperclass();
    }
    return map;
}
项目:Reer    文件:GroovyBasePlugin.java   
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        public void execute(SourceSet sourceSet) {
            final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory);
            new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);

            groovySourceSet.getGroovy().srcDir("src/" + sourceSet.getName() + "/groovy");
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return groovySourceSet.getGroovy().contains(element.getFile());
                }
            });
            sourceSet.getAllJava().source(groovySourceSet.getGroovy());
            sourceSet.getAllSource().source(groovySourceSet.getGroovy());

            String compileTaskName = sourceSet.getCompileTaskName("groovy");
            GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
            javaBasePlugin.configureForSourceSet(sourceSet, compile);
            compile.dependsOn(sourceSet.getCompileJavaTaskName());
            compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source.");
            compile.setSource(groovySourceSet.getGroovy());

            project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
        }
    });
}
项目:Reer    文件:JavaBasePlugin.java   
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
    DslObject htmlReport = new DslObject(test.getReports().getHtml());
    DslObject xmlReport = new DslObject(test.getReports().getJunitXml());

    xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), test.getName());
        }
    });
    htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestReportDir(), test.getName());
        }
    });
    test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), test.getName() + "/binary");
        }
    });
    test.workingDir(project.getProjectDir());
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
        public void execute(final GenerateMavenPom generatePomTask) {
            generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
            generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            generatePomTask.setPom(publication.getPom());

            ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
            descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
                }
            });

            // Wire the generated pom into the publication.
            publication.setPomFile(generatePomTask.getOutputs().getFiles());
        }
    });
}
项目:Pushjet-Android    文件:ProjectPropertySettingBuildLoader.java   
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }

    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        try {
            project.setProperty(entry.getKey(), entry.getValue());
        } catch (MissingPropertyException e) {
            if (!entry.getKey().equals(e.getProperty())) {
                throw e;
            }
            // Ignore and define as an extra property
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
项目:Pushjet-Android    文件:GroovyBasePlugin.java   
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        public void execute(SourceSet sourceSet) {
            final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver);
            new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);

            groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName()));
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return groovySourceSet.getGroovy().contains(element.getFile());
                }
            });
            sourceSet.getAllJava().source(groovySourceSet.getGroovy());
            sourceSet.getAllSource().source(groovySourceSet.getGroovy());

            String compileTaskName = sourceSet.getCompileTaskName("groovy");
            GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
            javaBasePlugin.configureForSourceSet(sourceSet, compile);
            compile.dependsOn(sourceSet.getCompileJavaTaskName());
            compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName()));
            compile.setSource(groovySourceSet.getGroovy());

            project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
        }
    });
}
项目:Pushjet-Android    文件:LegacyJavaComponentPlugin.java   
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() {
        public void execute(JvmResourceSet resourceSet) {
            Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class);
            resourcesTask.setDescription(String.format("Processes %s.", resourceSet));
            new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
                public File call() throws Exception {
                    return binary.getResourcesDir();
                }
            });
            binary.getTasks().add(resourcesTask);
            binary.builtBy(resourcesTask);
            resourcesTask.from(resourceSet.getSource());
        }
    });
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
    DslObject htmlReport = new DslObject(test.getReports().getHtml());
    DslObject xmlReport = new DslObject(test.getReports().getJunitXml());

    xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestResultsDir();
        }
    });
    htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestReportDir();
        }
    });
    test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName()));
        }
    });
    test.workingDir(project.getProjectDir());
}
项目:Pushjet-Android    文件:MavenPublishTaskModelRule.java   
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class);
    generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
    generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    generatePomTask.setPom(publication.getPom());

    ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
    descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
        }
    });

    // Wire the generated pom into the publication.
    publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
项目:Pushjet-Android    文件:ProjectPropertySettingBuildLoader.java   
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }

    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        if (project.hasProperty(entry.getKey())) {
            project.setProperty(entry.getKey(), entry.getValue());    
        } else {
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
项目:Pushjet-Android    文件:GroovyBasePlugin.java   
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        public void execute(SourceSet sourceSet) {
            final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver);
            new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);

            groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName()));
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return groovySourceSet.getGroovy().contains(element.getFile());
                }
            });
            sourceSet.getAllJava().source(groovySourceSet.getGroovy());
            sourceSet.getAllSource().source(groovySourceSet.getGroovy());

            String compileTaskName = sourceSet.getCompileTaskName("groovy");
            GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
            javaBasePlugin.configureForSourceSet(sourceSet, compile);
            compile.dependsOn(sourceSet.getCompileJavaTaskName());
            compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName()));
            compile.setSource(groovySourceSet.getGroovy());

            project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
        }
    });
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
    DslObject htmlReport = new DslObject(test.getReports().getHtml());
    DslObject xmlReport = new DslObject(test.getReports().getJunitXml());

    xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestResultsDir();
        }
    });
    htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestReportDir();
        }
    });
    test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName()));
        }
    });
    test.workingDir(project.getProjectDir());
}
项目:Reer    文件:BuildDashboardPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
项目:Reer    文件:MavenPlugin.java   
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
项目:Reer    文件:MavenPlugin.java   
private void configureInstall(Project project) {
    Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
    Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
    installUpload.setConfiguration(configuration);
    MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
    repositories.mavenInstaller();
    installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
项目:Reer    文件:HelpTasksPlugin.java   
@Defaults
void addDefaultDependenciesReportConfiguration(@Path("tasks.dependencyInsight") DependencyInsightReportTask task, final ServiceRegistry services) {
    new DslObject(task).getConventionMapping().map("configuration", new Callable<Object>() {
        public Object call() {
            BuildableJavaComponent javaProject = services.get(ComponentRegistry.class).getMainComponent();
            return javaProject == null ? null : javaProject.getCompileDependencies();
        }
    });
}
项目:Reer    文件:TaskDetailPrinter.java   
private Class getDeclaredTaskType(Task original) {
    Class clazz = new DslObject(original).getDeclaredType();
    if (clazz.equals(DefaultTask.class)) {
        return org.gradle.api.Task.class;
    } else {
        return clazz;
    }
}
项目:Reer    文件:TestNGTestFramework.java   
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
项目:Reer    文件:IvyArtifactNotationParserFactory.java   
private DefaultIvyArtifact createDefaultIvyArtifact(File file, String extension, String type, String classifier) {
    DefaultIvyArtifact ivyArtifact = instantiator.newInstance(
            DefaultIvyArtifact.class,
            file, null, extension, type, classifier
    );
    new DslObject(ivyArtifact).getConventionMapping().map("name", new Callable<String>() {
        public String call() throws Exception {
            return publicationIdentity.getModule();
        }
    });
    return ivyArtifact;
}
项目:Reer    文件:GroovyPlugin.java   
private void configureGroovydoc(final Project project) {
    Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class);
    groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code.");
    groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);

    JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()));

    GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
    groovyDoc.setSource(groovySourceSet.getGroovy());
}
项目:Reer    文件:JavaBasePlugin.java   
private void createProcessResourcesTaskForBinary(final SourceSet sourceSet, SourceDirectorySet resourceSet, final Project target) {
    Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
    resourcesTask.setDescription("Processes " + resourceSet + ".");
    new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
        public File call() throws Exception {
            return sourceSet.getOutput().getResourcesDir();
        }
    });
    resourcesTask.from(resourceSet);
}
项目:gradle-clojure    文件:ClojureBasePlugin.java   
private void configureSourceSetDefaults(Project project) {
  project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
    ClojureSourceSet clojureSourceSet = new DefaultClojureSourceSet("clojure", sourceDirectorySetFactory);
    new DslObject(sourceSet).getConvention().getPlugins().put("clojure", clojureSourceSet);

    clojureSourceSet.getClojure().srcDir(String.format("src/%s/clojure", sourceSet.getName()));
    // in case the clojure source overlaps with the resources source, exclude any clojure code
    // from resources
    sourceSet.getResources().getFilter().exclude(element -> clojureSourceSet.getClojure().contains(element.getFile()));
    sourceSet.getAllSource().source(clojureSourceSet.getClojure());

    String compileTaskName = sourceSet.getCompileTaskName("clojure");
    ClojureCompile compile = project.getTasks().create(compileTaskName, ClojureCompile.class);
    compile.setDescription(String.format("Compiles the %s Clojure source.", sourceSet.getName()));
    compile.setSource(clojureSourceSet.getClojure());

    // TODO presumably at some point this will allow providers, so we should switch to that
    // instead of convention mapping
    compile.getConventionMapping().map("classpath", () -> {
      return sourceSet.getCompileClasspath()
          .plus(project.files(sourceSet.getJava().getOutputDir()))
          .plus(project.files(sourceSet.getOutput().getResourcesDir()));
    });
    // TODO switch to provider
    compile.getConventionMapping().map("namespaces", compile::findNamespaces);

    SourceSetUtil.configureOutputDirectoryForSourceSet(sourceSet, clojureSourceSet.getClojure(), compile, project);

    compile.dependsOn(project.getTasks().getByName(sourceSet.getCompileJavaTaskName()));
    compile.dependsOn(project.getTasks().getByName(sourceSet.getProcessResourcesTaskName()));
    project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compile);
  });
}
项目:Pushjet-Android    文件:BuildDashboardPlugin.java   
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
项目:Pushjet-Android    文件:MavenPlugin.java   
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
项目:Pushjet-Android    文件:MavenPlugin.java   
private void configureInstall(Project project) {
    Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
    Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
    installUpload.setConfiguration(configuration);
    MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
    repositories.mavenInstaller();
    installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
项目:Pushjet-Android    文件:TaskDetailPrinter.java   
private Class getDeclaredTaskType(Task original) {
    Class clazz = new DslObject(original).getDeclaredType();
    if (clazz.equals(DefaultTask.class)) {
        return org.gradle.api.Task.class;
    } else {
        return clazz;
    }
}
项目:Pushjet-Android    文件:IvyArtifactNotationParserFactory.java   
private DefaultIvyArtifact createDefaultIvyArtifact(File file, String extension, String type, String classifier) {
    DefaultIvyArtifact ivyArtifact = instantiator.newInstance(
            DefaultIvyArtifact.class,
            file, null, extension, type, classifier
    );
    new DslObject(ivyArtifact).getConventionMapping().map("name", new Callable<String>() {
        public String call() throws Exception {
            return publicationIdentity.getModule();
        }
    });
    return ivyArtifact;
}
项目:Pushjet-Android    文件:TestNGTestFramework.java   
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
项目:Pushjet-Android    文件:GroovyPlugin.java   
private void configureGroovydoc(final Project project) {
    Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class);
    groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code.");
    groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);

    JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()));

    GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
    groovyDoc.setSource(groovySourceSet.getGroovy());
}
项目:Pushjet-Android    文件:LegacyJavaComponentPlugin.java   
private void setClassesDirConvention(ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    ConventionMapping conventionMapping = new DslObject(binary).getConventionMapping();
    conventionMapping.map("classesDir", new Callable<File>() {
        public File call() throws Exception {
            return new File(new File(target.getBuildDir(), "classes"), namingScheme.getOutputDirectoryBase());
        }
    });
}
项目:Pushjet-Android    文件:BuildDashboardPlugin.java   
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
项目:Pushjet-Android    文件:MavenPlugin.java   
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
项目:Pushjet-Android    文件:MavenPlugin.java   
private void configureInstall(Project project) {
    Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
    Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
    installUpload.setConfiguration(configuration);
    MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
    repositories.mavenInstaller();
    installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
项目:Pushjet-Android    文件:TaskDetailPrinter.java   
private Class getDeclaredTaskType(Task original) {
    Class clazz = new DslObject(original).getDeclaredType();
    if (clazz.equals(DefaultTask.class)) {
        return org.gradle.api.Task.class;
    } else {
        return clazz;
    }
}
项目:Pushjet-Android    文件:IvyArtifactNotationParserFactory.java   
private DefaultIvyArtifact createDefaultIvyArtifact(File file, String extension, String type, String classifier) {
    DefaultIvyArtifact ivyArtifact = instantiator.newInstance(
            DefaultIvyArtifact.class,
            file, null, extension, type, classifier
    );
    // TODO:DAZ Find a good way to handle this with lazy configuration
    new DslObject(ivyArtifact).getConventionMapping().map("name", new Callable<String>() {
        public String call() throws Exception {
            return publicationIdentity.getModule();
        }
    });
    return ivyArtifact;
}
项目:Pushjet-Android    文件:IvyPublicationTasksModelRule.java   
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
项目:Pushjet-Android    文件:TestNGTestFramework.java   
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
项目:Pushjet-Android    文件:GroovyPlugin.java   
private void configureGroovydoc(final Project project) {
    Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class);
    groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code.");
    groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);

    JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()));

    GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
    groovyDoc.setSource(groovySourceSet.getGroovy());
}
项目:spotless    文件:GroovyExtension.java   
/** If the user hasn't specified the files yet, we'll assume he/she means all of the groovy files. */
@Override
protected void setupTask(SpotlessTask task) {
    if (target == null) {
        JavaPluginConvention convention = getProject().getConvention().getPlugin(JavaPluginConvention.class);
        if (convention == null || !getProject().getPlugins().hasPlugin(GroovyBasePlugin.class)) {
            throw new GradleException("You must apply the groovy plugin before the spotless plugin if you are using the groovy extension.");
        }
        //Add all Groovy files (may contain Java files as well)

        FileCollection union = getProject().files();
        for (SourceSet sourceSet : convention.getSourceSets()) {
            GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
            if (excludeJava) {
                union = union.plus(groovySourceSet.getAllGroovy());
            } else {
                union = union.plus(groovySourceSet.getGroovy());
            }
        }
        target = union;
    } else if (excludeJava) {
        throw new IllegalArgumentException("'excludeJava' is not supported in combination with a custom 'target'.");
    }
    // LicenseHeaderStep completely blows apart package-info.java/groovy - this common-sense check
    // ensures that it skips both. See https://github.com/diffplug/spotless/issues/1
    steps.replaceAll(step -> {
        if (LicenseHeaderStep.name().equals(step.getName())) {
            return step.filterByFile(SerializableFileFilter.skipFilesNamed("package-info.java", "package-info.groovy"));
        } else {
            return step;
        }
    });
    super.setupTask(task);
}
项目:gradle-velocity-plugin    文件:VelocityPlugin.java   
private void apply(@Nonnull final Project project, @Nonnull SourceSet sourceSet, @Nonnull final VelocityPluginExtension extension) {
    final VelocitySourceSet velocitySourceSet = new VelocitySourceSet(sourceSet.getName(), fileResolver);
    new DslObject(sourceSet).getConvention().getPlugins().put("velocity", velocitySourceSet);
    final String srcDir = String.format("src/%s/velocity", sourceSet.getName());
    velocitySourceSet.getVelocity().srcDir(srcDir);
    sourceSet.getAllSource().source(velocitySourceSet.getVelocity());

    final String velocityTaskName = sourceSet.getTaskName("process", "Velocity");
    VelocityTask velocityTask = project.getTasks().create(velocityTaskName, VelocityTask.class, new Action<VelocityTask>() {
        @Override
        public void execute(VelocityTask task) {
            task.setDescription("Preprocesses velocity template files.");

            task.conventionMapping("includeDirs", new Callable<List<File>>() {
                @Override
                public List<File> call() {
                    List<Object> includeDirs = extension.includeDirs;
                    if (includeDirs == null)
                        return null;
                    List<File> out = new ArrayList<File>();
                    for (Object includeDir : includeDirs)
                        out.add(project.file(includeDir));
                    return out;
                }
            });

            task.conventionMapping("contextValues", new Callable<Map<String, Object>>() {
                @Override
                public Map<String, Object> call() {
                    return extension.contextValues;
                }
            });
        }
    });

    velocityTask.setSource(velocitySourceSet.getVelocity());

    final String outputDirectoryName = String.format("%s/generated-sources/antlr/%s",
            project.getBuildDir(), sourceSet.getName());
    File outputDir = new File(outputDirectoryName);
    velocityTask.setOutputDir(outputDir);
    sourceSet.getJava().srcDir(outputDir);

    project.getTasks().getByName(sourceSet.getCompileJavaTaskName()).dependsOn(velocityTask);
}