下面列出了怎么用org.gradle.api.tasks.compile.GroovyCompile的API类实例代码及写法,或者点击链接到github查看源代码。
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);
}
});
}
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);
}
});
}
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);
}
});
}
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);
}
});
}
private void configureCompileDefaults() {
project.getTasks().withType(GroovyCompile.class, new Action<GroovyCompile>() {
public void execute(final GroovyCompile compile) {
compile.getConventionMapping().map("groovyClasspath", new Callable<Object>() {
public Object call() throws Exception {
return groovyRuntime.inferGroovyClasspath(compile.getClasspath());
}
});
}
});
}
private void configureCompileDefaults() {
project.getTasks().withType(GroovyCompile.class, new Action<GroovyCompile>() {
public void execute(final GroovyCompile compile) {
compile.getConventionMapping().map("groovyClasspath", new Callable<Object>() {
public Object call() throws Exception {
return groovyRuntime.inferGroovyClasspath(compile.getClasspath());
}
});
}
});
}
private void configureCompileDefaults() {
project.getTasks().withType(GroovyCompile.class, new Action<GroovyCompile>() {
public void execute(final GroovyCompile compile) {
compile.getConventionMapping().map("groovyClasspath", new Callable<Object>() {
public Object call() throws Exception {
return groovyRuntime.inferGroovyClasspath(compile.getClasspath());
}
});
}
});
}
private void configureCompileDefaults() {
project.getTasks().withType(GroovyCompile.class, new Action<GroovyCompile>() {
public void execute(final GroovyCompile compile) {
compile.getConventionMapping().map("groovyClasspath", new Callable<Object>() {
public Object call() throws Exception {
return groovyRuntime.inferGroovyClasspath(compile.getClasspath());
}
});
}
});
}