Java 类org.gradle.api.internal.IConventionAware 实例源码

项目:Reer    文件:OsgiPluginConvention.java   
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
项目:Reer    文件:CompareGradleBuildsPlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    final ReportingExtension reportingExtension = project.getExtensions().findByType(ReportingExtension.class);

    project.getTasks().withType(CompareGradleBuilds.class, new Action<CompareGradleBuilds>() {
        @Override
        public void execute(final CompareGradleBuilds task) {
            ((IConventionAware) task).getConventionMapping().map("reportDir", new Callable<File>() {
                @Override
                public File call() throws Exception {
                    return reportingExtension.file(task.getName());
                }
            });
        }
    });

    project.getTasks().create("compareGradleBuilds", CompareGradleBuilds.class);
}
项目:Reer    文件:JacocoPlugin.java   
public void apply(ProjectInternal project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    this.project = project;
    addJacocoConfigurations();
    JacocoAgentJar agent = instantiator.newInstance(JacocoAgentJar.class, project);
    JacocoPluginExtension extension = project.getExtensions().create(PLUGIN_EXTENSION_NAME, JacocoPluginExtension.class, project, agent);
    final ReportingExtension reportingExtension = (ReportingExtension) project.getExtensions().getByName(ReportingExtension.NAME);
    ((IConventionAware) extension).getConventionMapping().map("reportsDir", new Callable<File>() {
        @Override
        public File call() {
            return reportingExtension.file("jacoco");
        }
    });

    configureAgentDependencies(agent, extension);
    configureTaskClasspathDefaults(extension);
    applyToDefaultTasks(extension);
    configureDefaultOutputPathForJacocoMerge();
    configureJacocoReportsDefaults(extension);
    addDefaultReportTasks(extension);
}
项目:Reer    文件:JacocoPlugin.java   
/**
 * Configures the classpath for Jacoco tasks using the 'jacocoAnt' configuration. Uses the version information declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly
 * declared.
 *
 * @param extension the JacocoPluginExtension
 */
private void configureTaskClasspathDefaults(final JacocoPluginExtension extension) {
    final Configuration config = this.project.getConfigurations().getAt(ANT_CONFIGURATION_NAME);
    project.getTasks().withType(JacocoBase.class, new Action<JacocoBase>() {
        @Override
        public void execute(JacocoBase task) {
            ((IConventionAware) task).getConventionMapping().map("jacocoClasspath", Callables.returning(config));
        }
    });
    config.defaultDependencies(new Action<DependencySet>() {
        @Override
        public void execute(DependencySet dependencies) {
            dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.ant:" + extension.getToolVersion()));
        }
    });
}
项目:Reer    文件:JacocoPlugin.java   
private void configureJacocoReportDefaults(final JacocoPluginExtension extension, final JacocoReport reportTask) {
    reportTask.getReports().all(new Action<Report>() {
        @Override
        public void execute(final Report report) {
            ConventionMapping mapping = ((IConventionAware) report).getConventionMapping();
            mapping.map("enabled", Callables.returning(report.getName().equals("html")));
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                mapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), reportTask.getName() + "/" + report.getName());
                    }
                });
            } else {
                mapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName());
                    }
                });
            }
        }
    });
}
项目:Reer    文件:SigningExtension.java   
/**
 * Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.
 */
protected void addSignatureSpecConventions(SignatureSpec spec) {
    if (!(spec instanceof IConventionAware)) {
        throw new InvalidUserDataException("Cannot add conventions to signature spec \'" + String.valueOf(spec) + "\' as it is not convention aware");
    }

    ConventionMapping conventionMapping = ((IConventionAware) spec).getConventionMapping();
    conventionMapping.map("signatory", new Callable<Signatory>() {
        public Signatory call() {
            return getSignatory();
        }
    });
    conventionMapping.map("signatureType", new Callable<SignatureType>() {
        public SignatureType call() {
            return getSignatureType();
        }
    });
    conventionMapping.map("required", new Callable<Boolean>() {
        public Boolean call() {
            return isRequired();
        }
    });
}
项目:Reer    文件:ApplicationPlugin.java   
@Override
public void apply(final Project project) {
    this.project = project;
    project.getPluginManager().apply(JavaPlugin.class);
    project.getPluginManager().apply(DistributionPlugin.class);

    addPluginConvention();
    addRunTask();
    addCreateScriptsTask();

    Distribution distribution = ((DistributionContainer) project.getExtensions().getByName("distributions")).getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME);

    ((IConventionAware) distribution).getConventionMapping().map("baseName", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            return pluginConvention.getApplicationName();
        }
    });
    configureDistSpec(distribution.getContents());
    configureInstallTask(project.getTasks().getAt(TASK_INSTALL_NAME));
}
项目:Pushjet-Android    文件:OsgiPluginConvention.java   
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
项目:Pushjet-Android    文件:OsgiPluginConvention.java   
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
项目:JGiven    文件:JGivenPlugin.java   
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask,
        final ReportingExtension reportingExtension ) {
    ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping();
    mapping.map( "results", new Callable<File>() {
        @Override
        public File call() {
            return test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir();
        }
    } );
    mapping.getConventionValue( reportTask.getReports(), "reports", false ).all( new Action<Report>() {
        @Override
        public void execute( final Report report ) {
            ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping();
            reportMapping.map( "destination", new Callable<File>() {
                @Override
                public File call() {
                    return reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() );
                }
            } );
        }
    } );
}
项目:Reer    文件:RhinoPlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(JavaScriptBasePlugin.class);

    JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class);
    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class);

    final Configuration configuration = addClasspathConfiguration(project.getConfigurations());
    configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension);

    ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping();
    conventionMapping.map("classpath", new Callable<Configuration>() {
        public Configuration call() {
            return configuration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {
        public String call() {
            return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION;
        }
    });

    project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() {
        public void execute(RhinoShellExec task) {
            task.getConventionMapping().map("classpath", new Callable<FileCollection>() {
                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("main", new Callable<String>() {
                public String call() {
                    return RhinoExtension.RHINO_SHELL_MAIN;
                }
            });
            task.setClasspath(rhinoExtension.getClasspath());
        }
    });
}
项目:Reer    文件:EnvJsPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);

    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    final EnvJsExtension envJsExtension = ((ExtensionAware) jsExtension).getExtensions().create(EnvJsExtension.NAME, EnvJsExtension.class);

    final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), envJsExtension);
    final ConventionMapping conventionMapping = ((IConventionAware) envJsExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {
        public Configuration call() {
            return configuration;
        }

    });
    conventionMapping.map("version", new Callable<String>() {
        public String call() {
            return EnvJsExtension.DEFAULT_DEPENDENCY_VERSION;
        }
    });

    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);

    project.getTasks().withType(BrowserEvaluate.class, new Action<BrowserEvaluate>() {
        public void execute(BrowserEvaluate task) {
            ((IConventionAware) task).getConventionMapping().map("evaluator", new Callable<EnvJsBrowserEvaluator>() {
                public EnvJsBrowserEvaluator call() {
                    RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);
                    File workDir = project.getProjectDir();
                    Factory<File> envJsFactory = new Factory<File>() {
                        public File create() {
                            return envJsExtension.getJs().getSingleFile();
                        }
                    };
                    return new EnvJsBrowserEvaluator(handleFactory, rhinoExtension.getClasspath(), envJsFactory, project.getGradle().getStartParameter().getLogLevel(), workDir);
                }
            });
        }
    });
}
项目:Reer    文件:JacocoAgentJar.java   
private FileCollection getAgentConfConventionValue() {
    if (this instanceof IConventionAware) {
        return ((IConventionAware) this).getConventionMapping().getConventionValue(agentConf, "agentConf", false);
    }
    // For unit tests
    return agentConf;
}
项目:Reer    文件:JacocoPlugin.java   
/**
 * Configures the agent dependencies using the 'jacocoAnt' configuration. Uses the version declared in 'toolVersion' of the Jacoco extension if no dependencies are explicitly declared.
 *
 * @param extension the extension that has the tool version to use
 */
private void configureAgentDependencies(JacocoAgentJar jacocoAgentJar, final JacocoPluginExtension extension) {
    Configuration config = project.getConfigurations().getAt(AGENT_CONFIGURATION_NAME);
    ((IConventionAware) jacocoAgentJar).getConventionMapping().map("agentConf", Callables.returning(config));
    config.defaultDependencies(new Action<DependencySet>() {
        @Override
        public void execute(DependencySet dependencies) {
            dependencies.add(project.getDependencies().create("org.jacoco:org.jacoco.agent:" + extension.getToolVersion()));
        }
    });
}
项目:Reer    文件:JacocoPlugin.java   
public Object configureDefaultOutputPathForJacocoMerge() {
    return project.getTasks().withType(JacocoMerge.class, new Action<JacocoMerge>() {
        @Override
        public void execute(final JacocoMerge task) {
            ConventionMapping mapping = ((IConventionAware) task).getConventionMapping();
            mapping.map("destinationFile", new Callable<File>() {
                @Override
                public File call() {
                    return new File(project.getBuildDir(), "/jacoco/" + task.getName() + ".exec");
                }
            });
        }
    });
}
项目:Reer    文件:JacocoPlugin.java   
private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
    final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalise(task.getName()) + "Report", JacocoReport.class);
    reportTask.executionData(task);
    reportTask.sourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main"));
    ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
    taskMapping.getConventionValue(reportTask.getReports(), "reports", false).all(new Action<Report>() {
        @Override
        public void execute(final Report report) {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            // reportMapping.map('enabled', Callables.returning(true));
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                reportMapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
                    }
                });
            } else {
                reportMapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
                    }
                });
            }
        }
    });
}
项目:Reer    文件:DistributionPlugin.java   
@Override
public void apply(final ProjectInternal project) {
    project.getPluginManager().apply(BasePlugin.class);
    DefaultDistributionContainer distributions = project.getExtensions().create("distributions", DefaultDistributionContainer.class, Distribution.class, instantiator, fileOperations);

    // TODO - refactor this action out so it can be unit tested
    distributions.all(new Action<Distribution>() {
        @Override
        public void execute(final Distribution dist) {
            ((IConventionAware) dist).getConventionMapping().map("baseName", new Callable<Object>() {
                @Override
                public Object call() throws Exception {
                    return dist.getName().equals(MAIN_DISTRIBUTION_NAME) ? project.getName() : String.format("%s-%s", project.getName(), dist.getName());
                }
            });

            dist.getContents().from("src/" + dist.getName() + "/dist");
            String zipTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_ZIP_NAME : dist.getName() + "DistZip";
            Task zipTask = configureArchiveTask(project, zipTaskName, dist, Zip.class);
            String tarTaskName = MAIN_DISTRIBUTION_NAME.equals(dist.getName()) ? TASK_DIST_TAR_NAME : dist.getName() + "DistTar";
            Task tarTask = configureArchiveTask(project, tarTaskName, dist, Tar.class);
            addAssembleTask(project, dist, zipTask, tarTask);
            addInstallTask(project, dist);
        }
    });
    distributions.create(MAIN_DISTRIBUTION_NAME);
}
项目:Reer    文件:JavaBasePlugin.java   
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList();
    pluginConvention.getSourceSets().all(new Action<SourceSet>() {
        public void execute(final SourceSet sourceSet) {
            ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

            ConfigurationContainer configurations = project.getConfigurations();

            defineConfigurationsForSourceSet(sourceSet, configurations);
            definePathsForSourceSet(sourceSet, outputConventionMapping, project);

            createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project);
            createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project);
            createBinaryLifecycleTask(sourceSet, project);

            DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName());
            ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory);

            Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
            DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath);
            JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources());

            binary.addSourceSet(javaSourceSet);
            binary.addSourceSet(resourceSet);

            attachTasksToBinary(binary, sourceSet, project);
            binaries.add(binary);
        }
    });
    return new BridgedBinaries(binaries);
}
项目:putnami-gradle-plugin    文件:GwtDevTask.java   
public void configureCodeServer(final Project project, final PutnamiExtension extention) {
    final DevOption options = extention.getDev();
    options.init(project);

    ConventionMapping convention = ((IConventionAware) this).getConventionMapping();
    convention.map("modules", new Callable<List<String>>() {
        @Override
        public List<String> call()  {
            return extention.getModule();
        }
    });
}
项目:putnami-gradle-plugin    文件:GwtSetUpTask.java   
public void configure(final PutnamiExtension extension) {
    ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

    mapping.map("modules", new Callable<List<String>>() {
        @Override
        public List<String> call()  {
            return extension.getModule();
        }
    });
}
项目:putnami-gradle-plugin    文件:GwtCompileTask.java   
public void configure(final Project project, final PutnamiExtension extention) {
    final CompilerOption options = extention.getCompile();
    options.init(getProject());
    options.setLocalWorkers(evalWorkers(options));

    JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    final FileCollection sources = getProject()
        .files(project.files(mainSourceSet.getOutput().getResourcesDir()))
        .plus(project.files(mainSourceSet.getOutput().getClassesDirs()))
        .plus(getProject().files(mainSourceSet.getAllSource().getSrcDirs()));

    ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

    mapping.map("modules", new Callable<List<String>>() {
        @Override
        public List<String> call()  {
            return extention.getModule();
        }
    });
    mapping.map("war", new Callable<File>() {
        @Override
        public File call()  {
            return options.getWar();
        }
    });
    mapping.map("src", new Callable<FileCollection>() {
        @Override
        public FileCollection call()  {
            return sources;
        }
    });
}
项目:putnami-gradle-plugin    文件:GwtCheckTask.java   
public void configure(final Project project, final PutnamiExtension extention) {
    final CompilerOption options = extention.getCompile();

    options.init(getProject());

    JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    final FileCollection sources = getProject()
        .files(project.files(mainSourceSet.getOutput().getResourcesDir()))
        .plus(project.files(mainSourceSet.getOutput().getClassesDirs()))
        .plus(getProject().files(mainSourceSet.getAllSource().getSrcDirs()));

    ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

    mapping.map("modules", new Callable<List<String>>() {
        @Override
        public List<String> call() {
            return extention.getModule();
        }
    });
    mapping.map("war", new Callable<File>() {
        @Override
        public File call()  {
            return new File(getProject().getBuildDir(), "out");
        }
    });
    mapping.map("src", new Callable<FileCollection>() {
        @Override
        public FileCollection call()  {
            return sources;
        }
    });
}
项目:JGiven    文件:JGivenPlugin.java   
private void configureJGivenReportDefaults( Project project ) {
    project.getTasks().withType( JGivenReportTask.class, new Action<JGivenReportTask>() {
        @Override
        public void execute( JGivenReportTask reportTask ) {
            reportTask.getReports().all( new Action<Report>() {
                @Override
                public void execute( final Report report ) {
                    ConventionMapping mapping = ( (IConventionAware) report ).getConventionMapping();
                    mapping.map( "enabled", Callables.returning( report.getName().equals( JGivenHtmlReportImpl.NAME ) ) );
                }
            } );
        }
    } );
}
项目:gradle-avro-plugin    文件:AvroBasePlugin.java   
private static ConventionMapping conventionMapping(Object conventionAware) {
    // TODO: try other alternatives to convention mapping
    // Convention mapping is an internal API.
    // Other options here:
    // http://forums.gradle.org/gradle/topics/how_can_i_do_convention_mappings_from_java_without_depending_on_an_internal_api
    return ((IConventionAware) conventionAware).getConventionMapping();
}
项目:gradle-avro-plugin    文件:AvroPlugin.java   
private static ConventionMapping conventionMapping(Object conventionAware) {
    // TODO: try other alternatives to convention mapping
    // Convention mapping is an internal API.
    // Other options here:
    // http://forums.gradle.org/gradle/topics/how_can_i_do_convention_mappings_from_java_without_depending_on_an_internal_api
    return ((IConventionAware) conventionAware).getConventionMapping();
}
项目:Reer    文件:AbstractCodeQualityPlugin.java   
protected static ConventionMapping conventionMappingOf(Object object) {
    return ((IConventionAware) object).getConventionMapping();
}
项目:Reer    文件:JsHintPlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);

    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    final JsHintExtension jsHintExtension = ((ExtensionAware) jsExtension).getExtensions().create(JsHintExtension.NAME, JsHintExtension.class);
    final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), jsHintExtension);

    ConventionMapping conventionMapping = ((IConventionAware) jsHintExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {
        public Configuration call() {
            return configuration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {
        public String call() {
            return JsHintExtension.DEFAULT_DEPENDENCY_VERSION;
        }
    });

    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
    final ReportingExtension reportingExtension = project.getExtensions().getByType(ReportingExtension.class);

    project.getTasks().withType(JsHint.class, new Action<JsHint>() {
        public void execute(final JsHint task) {
            task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {
                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("jsHint", new Callable<FileCollection>() {
                public FileCollection call() {
                    return jsHintExtension.getJs();
                }
            });
            task.getConventionMapping().map("jsonReport", new Callable<File>() {
                public File call() {
                    return reportingExtension.file(task.getName() + "/report.json");
                }
            });
        }
    });
}
项目:Reer    文件:CoffeeScriptBasePlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);

    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);

    ExtensionContainer extensionContainer = ((ExtensionAware) jsExtension).getExtensions();
    final CoffeeScriptExtension csExtension = extensionContainer.create(CoffeeScriptExtension.NAME, CoffeeScriptExtension.class);
    final Configuration jsConfiguration = addJsConfiguration(project.getConfigurations(), project.getDependencies(), csExtension);

    ConventionMapping conventionMapping = ((IConventionAware) csExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {
        @Override
        public Configuration call() {
            return jsConfiguration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {
        @Override
        public String call() {
            return CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_VERSION;
        }
    });

    final RhinoExtension rhinoExtension = extensionContainer.getByType(RhinoExtension.class);

    project.getTasks().withType(CoffeeScriptCompile.class, new Action<CoffeeScriptCompile>() {
        @Override
        public void execute(CoffeeScriptCompile task) {
            task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {
                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("coffeeScriptJs", new Callable<FileCollection>() {
                public FileCollection call() {
                    return csExtension.getJs();
                }
            });
        }
    });
}
项目:Reer    文件:JacocoPluginExtension.java   
/**
 * Applies Jacoco to the given task.
 * Configuration options will be provided on a task extension named 'jacoco'.
 * Jacoco will be run as an agent during the execution of the task.
 *
 * @param task the task to apply Jacoco to.
 * @see JacocoPluginExtension#TASK_EXTENSION_NAME
 */
public <T extends Task & JavaForkOptions> void applyTo(final T task) {
    final String taskName = task.getName();
    logger.debug("Applying Jacoco to " + taskName);
    final JacocoTaskExtension extension = task.getExtensions().create(TASK_EXTENSION_NAME, JacocoTaskExtension.class, agent, task);
    ((IConventionAware) extension).getConventionMapping().map("destinationFile", new Callable<File>() {
        @Override
        public File call() {
            return project.file(String.valueOf(project.getBuildDir()) + "/jacoco/" + taskName + ".exec");
        }
    });
    task.getInputs().property("jacoco.enabled", new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return extension.isEnabled();
        }
    });
    task.getInputs().property("jacoco.jvmArgs", new Callable<String>() {
        @Override
        public String call() throws Exception {
            return extension.getAsJvmArg();
        }
    });
    TaskInternal taskInternal = (TaskInternal) task;
    taskInternal.getOutputs().doNotCacheIf(new Spec<Task>() {
        @Override
        public boolean isSatisfiedBy(Task element) {
            // Do not cache Test task if Jacoco doesn't produce its output as files
            return extension.isEnabled() && extension.getOutput() != JacocoTaskExtension.Output.FILE;
        }
    });
    taskInternal.getOutputs().files(new Callable<Map<?, ?>>() {
        @Override
        public Map<?, ?> call() throws Exception {
            ImmutableMap.Builder<String, File> builder = ImmutableMap.builder();
            if (extension.isEnabled() && extension.getOutput() == JacocoTaskExtension.Output.FILE) {
                File destinationFile = extension.getDestinationFile();
                if (destinationFile != null) {
                    builder.put("destinationFile", destinationFile);
                }
                File classDumpFile = extension.getClassDumpFile();
                if (classDumpFile != null) {
                    builder.put("classDumpFile", classDumpFile);
                }
            }
            return builder.build();
        }
    }).withPropertyName("jacocoFiles");
    taskInternal.prependParallelSafeAction(new Action<Task>() {
        @Override
        public void execute(Task input) {
            if (extension.isEnabled()) {
                task.jvmArgs(extension.getAsJvmArg());
            }
        }
    });
}
项目:Reer    文件:EclipsePlugin.java   
private void configureEclipseClasspath(final Project project, final EclipseModel model) {
    model.setClasspath(instantiator.newInstance(EclipseClasspath.class, project));
    ((IConventionAware) model.getClasspath()).getConventionMapping().map("defaultOutputDir", new Callable<File>() {
        @Override
        public File call() {
            return new File(project.getProjectDir(), "bin");
        }

    });

    final EclipsePlugin eclipsePlugin = this;
    project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
        @Override
        public void execute(JavaBasePlugin javaBasePlugin) {
            maybeAddTask(project, eclipsePlugin, ECLIPSE_CP_TASK_NAME, GenerateEclipseClasspath.class, new Action<GenerateEclipseClasspath>() {
                @Override
                public void execute(final GenerateEclipseClasspath task) {
                    //task properties:
                    task.setDescription("Generates the Eclipse classpath file.");
                    task.setInputFile(project.file(".classpath"));
                    task.setOutputFile(project.file(".classpath"));

                    //model properties:
                    task.setClasspath(model.getClasspath());
                    task.getClasspath().setFile(new XmlFileContentMerger(task.getXmlTransformer()));
                    task.getClasspath().setSourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets());

                    AfterEvaluateHelper.afterEvaluateOrExecute(project, new Action<Project>() {
                        @Override
                        public void execute(Project p) {
                            // keep the ordering we had in earlier gradle versions
                            Set<String> containers = Sets.newLinkedHashSet();
                            containers.add("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/" + model.getJdt().getJavaRuntimeName() + "/");
                            containers.addAll(task.getClasspath().getContainers());
                            task.getClasspath().setContainers(containers);
                        }

                    });

                    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
                        @Override
                        public void execute(JavaPlugin javaPlugin) {
                            configureJavaClasspath(project, task);
                        }

                    });

                    configureScalaDependencies(project, task);
                }

            });
        }

    });
}
项目:Reer    文件:EclipsePlugin.java   
private void configureEclipseJdt(final Project project, final EclipseModel model) {
    final EclipsePlugin eclipsePlugin = this;
    project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
        @Override
        public void execute(JavaBasePlugin javaBasePlugin) {
            maybeAddTask(project, eclipsePlugin, ECLIPSE_JDT_TASK_NAME, GenerateEclipseJdt.class, new Action<GenerateEclipseJdt>() {
                @Override
                public void execute(GenerateEclipseJdt task) {
                    //task properties:
                    task.setDescription("Generates the Eclipse JDT settings file.");
                    task.setOutputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
                    task.setInputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
                    //model properties:
                    EclipseJdt jdt = task.getJdt();
                    model.setJdt(jdt);
                    ConventionMapping conventionMapping = ((IConventionAware) jdt).getConventionMapping();
                    conventionMapping.map("sourceCompatibility", new Callable<JavaVersion>() {
                        @Override
                        public JavaVersion call() {
                            return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceCompatibility();
                        }

                    });
                    conventionMapping.map("targetCompatibility", new Callable<JavaVersion>() {
                        @Override
                        public JavaVersion call() {
                            return project.getConvention().getPlugin(JavaPluginConvention.class).getTargetCompatibility();
                        }

                    });
                    conventionMapping.map("javaRuntimeName", new Callable<String>() {
                        @Override
                        public String call() {
                            return "JavaSE-" + project.getConvention().getPlugin(JavaPluginConvention.class).getTargetCompatibility();
                        }

                    });
                }

            });
        }

    });
}
项目:Reer    文件:EclipseWtpPlugin.java   
private void configureEclipseWtpFacet(final Project project, final EclipseModel eclipseModel) {
    maybeAddTask(project, this, ECLIPSE_WTP_FACET_TASK_NAME, GenerateEclipseWtpFacet.class, new Action<GenerateEclipseWtpFacet>() {
        @Override
        public void execute(final GenerateEclipseWtpFacet task) {
            //task properties:
            task.setDescription("Generates the Eclipse WTP facet settings file.");
            task.setInputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));
            task.setOutputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));

            //model properties:
            eclipseModel.getWtp().setFacet(task.getFacet());

            project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
                @Override
                public void execute(JavaPlugin javaPlugin) {
                    if (hasWarOrEarPlugin(project)) {
                        return;
                    }

                    ((IConventionAware) task.getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
                        @Override
                        public List<Facet> call() throws Exception {
                            return Lists.newArrayList(
                                new Facet(Facet.FacetType.fixed, "jst.java", null),
                                new Facet(Facet.FacetType.installed, "jst.utility", "1.0"),
                                new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceCompatibility()))
                            );
                        }
                    });
                }

            });
            project.getPlugins().withType(WarPlugin.class, new Action<WarPlugin>() {
                @Override
                public void execute(WarPlugin warPlugin) {
                    ((IConventionAware) task.getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
                        @Override
                        public List<Facet> call() throws Exception {
                            return Lists.newArrayList(
                                new Facet(Facet.FacetType.fixed, "jst.java", null),
                                new Facet(Facet.FacetType.fixed, "jst.web", null),
                                new Facet(Facet.FacetType.installed, "jst.web", "2.4"),
                                new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceCompatibility()))
                            );
                        }
                    });
                }

            });
            project.getPlugins().withType(EarPlugin.class, new Action<EarPlugin>() {
                @Override
                public void execute(EarPlugin earPlugin) {
                    ((IConventionAware) task.getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
                        @Override
                        public List<Facet> call() throws Exception {
                            return Lists.newArrayList(
                                new Facet(Facet.FacetType.fixed, "jst.ear", null),
                                new Facet(Facet.FacetType.installed, "jst.ear", "5.0")
                            );
                        }
                    });
                }

            });
        }

    });
}
项目:Reer    文件:IdeaPlugin.java   
private void configureIdeaModule(final Project project) {
    final GenerateIdeaModule task = project.getTasks().create("ideaModule", GenerateIdeaModule.class);
    task.setDescription("Generates IDEA module files (IML)");
    IdeaModuleIml iml = new IdeaModuleIml(task.getXmlTransformer(), project.getProjectDir());
    final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
    task.setModule(module);

    ideaModel.setModule(module);
    ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
    conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet();
        }
    });
    conventionMapping.map("name", new Callable<String>() {
        @Override
        public String call() throws Exception {
            return project.getName();
        }
    });
    conventionMapping.map("contentRoot", new Callable<File>() {
        @Override
        public File call() throws Exception {
            return project.getProjectDir();
        }
    });
    conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet();
        }
    });
    conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
        @Override
        public Set<File> call() throws Exception {
            return Sets.newHashSet(project.getBuildDir(), project.file(".gradle"));
        }
    });

    conventionMapping.map("pathFactory", new Callable<PathFactory>() {
        @Override
        public PathFactory call() throws Exception {
            final PathFactory factory = new PathFactory();
            factory.addPathVariable("MODULE_DIR", task.getOutputFile().getParentFile());
            for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
                factory.addPathVariable(entry.getKey(), entry.getValue());
            }
            return factory;
        }

    });

    addWorker(task);
}
项目:android-gradle-plugins    文件:AbstractAndroidCodeQualityPlugin.java   
protected static ConventionMapping conventionMappingOf(Object object) {
    return ((IConventionAware) object).getConventionMapping();
}
项目:Pushjet-Android    文件:ConventionValue.java   
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);
项目:Pushjet-Android    文件:ConventionValue.java   
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);