本文整理匯總了Java中org.gradle.api.Action類的典型用法代碼示例。如果您正苦於以下問題:Java Action類的具體用法?Java Action怎麽用?Java Action使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Action類屬於org.gradle.api包,在下文中一共展示了Action類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createExecutableTask
import org.gradle.api.Action; //導入依賴的package包/類
public static void createExecutableTask(final NativeBinarySpecInternal binary, final File executableFile) {
String taskName = binary.getNamingScheme().getTaskName("link");
binary.getTasks().create(taskName, LinkExecutable.class, new Action<LinkExecutable>() {
@Override
public void execute(LinkExecutable linkTask) {
linkTask.setDescription("Links " + binary.getDisplayName());
linkTask.setToolChain(binary.getToolChain());
linkTask.setTargetPlatform(binary.getTargetPlatform());
linkTask.setOutputFile(executableFile);
linkTask.setLinkerArgs(binary.getLinker().getArgs());
linkTask.lib(new BinaryLibs(binary) {
@Override
protected FileCollection getFiles(NativeDependencySet nativeDependencySet) {
return nativeDependencySet.getLinkFiles();
}
});
binary.builtBy(linkTask);
}
});
}
示例2: doRender
import org.gradle.api.Action; //導入依賴的package包/類
private void doRender(final RenderableDependency node, boolean last, Set<Object> visited) {
Set<? extends RenderableDependency> children = node.getChildren();
final boolean alreadyRendered = !visited.add(node.getId());
if (alreadyRendered) {
legendRenderer.setHasCyclicDependencies(true);
}
renderer.visit(new Action<StyledTextOutput>() {
public void execute(StyledTextOutput output) {
nodeRenderer.renderNode(output, node, alreadyRendered);
}
}, last);
if (!alreadyRendered) {
renderChildren(children, visited);
}
}
示例3: onApply
import org.gradle.api.Action; //導入依賴的package包/類
@Override
protected void onApply(Project project) {
getLifecycleTask().setDescription("Generates all Eclipse files.");
getCleanTask().setDescription("Cleans all Eclipse files.");
EclipseModel model = project.getExtensions().create("eclipse", EclipseModel.class);
configureEclipseProject(project, model);
configureEclipseJdt(project, model);
configureEclipseClasspath(project, model);
postProcess("eclipse", new Action<Gradle>() {
@Override
public void execute(Gradle gradle) {
performPostEvaluationActions();
}
});
applyEclipseWtpPluginOnWebProjects(project);
}
示例4: execute
import org.gradle.api.Action; //導入依賴的package包/類
public void execute(Action<? super BufferedWriter> action) {
try {
File parentFile = file.getParentFile();
if (parentFile != null) {
if (!parentFile.mkdirs() && !parentFile.isDirectory()) {
throw new IOException(String.format("Unable to create directory '%s'", parentFile));
}
}
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));
try {
action.execute(writer);
} finally {
writer.close();
}
} catch (Exception e) {
throw new UncheckedIOException(String.format("Could not write to file '%s'.", file), e);
}
}
示例5: internalCreateArtifactRepository
import org.gradle.api.Action; //導入依賴的package包/類
@Override
protected ArtifactRepository internalCreateArtifactRepository(RepositoryHandler repositoryHandler) {
return repositoryHandler.ivy(new Action<IvyArtifactRepository>() {
@Override
public void execute(IvyArtifactRepository ivyArtifactRepository) {
ivyArtifactRepository.setName(getArtifactRepositoryName());
ivyArtifactRepository.setUrl(getUrl());
Credentials credentials = authenticationSupport().getConfiguredCredentials();
if (credentials != null) {
((AuthenticationSupportedInternal)ivyArtifactRepository).setConfiguredCredentials(credentials);
ivyArtifactRepository.authentication(new Action<AuthenticationContainer>() {
@Override
public void execute(AuthenticationContainer authenticationContainer) {
authenticationContainer.addAll(authenticationSupport().getConfiguredAuthentication());
}
});
}
}
});
}
示例6: addPlaceholderAction
import org.gradle.api.Action; //導入依賴的package包/類
public <T extends TaskInternal> void addPlaceholderAction(final String placeholderName, final Class<T> taskType, final Action<? super T> configure) {
if (!modelNode.hasLink(placeholderName)) {
final ModelType<T> taskModelType = ModelType.of(taskType);
ModelPath path = MODEL_PATH.child(placeholderName);
modelNode.addLink(
ModelRegistrations.of(path)
.action(ModelActionRole.Create, new TaskCreator<T>(placeholderName, taskType, configure, taskModelType))
.withProjection(new UnmanagedModelProjection<T>(taskModelType))
.descriptor(new SimpleModelRuleDescriptor("tasks.addPlaceholderAction(" + placeholderName + ")"))
.build()
);
}
if (findByNameWithoutRules(placeholderName) == null) {
placeholders.add(placeholderName);
}
}
示例7: configureExtensionRule
import org.gradle.api.Action; //導入依賴的package包/類
private void configureExtensionRule() {
final ConventionMapping extensionMapping = conventionMappingOf(extension);
extensionMapping.map("sourceSets", Callables.returning(new ArrayList()));
extensionMapping.map("reportsDir", new Callable<File>() {
@Override
public File call() {
return project.getExtensions().getByType(ReportingExtension.class).file(getReportName());
}
});
withBasePlugin(new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
extensionMapping.map("sourceSets", new Callable<SourceSetContainer>() {
@Override
public SourceSetContainer call() {
return getJavaPluginConvention().getSourceSets();
}
});
}
});
}
示例8: render
import org.gradle.api.Action; //導入依賴的package包/類
private void render(final Project project, GraphRenderer renderer, boolean lastChild,
final StyledTextOutput textOutput) {
renderer.visit(new Action<StyledTextOutput>() {
public void execute(StyledTextOutput styledTextOutput) {
styledTextOutput.text(StringUtils.capitalize(project.toString()));
if (GUtil.isTrue(project.getDescription())) {
textOutput.withStyle(Description).format(" - %s", project.getDescription());
}
}
}, lastChild);
renderer.startChildren();
List<Project> children = getChildren(project);
for (Project child : children) {
render(child, renderer, child == children.get(children.size() - 1), textOutput);
}
renderer.completeChildren();
}
示例9: configureConfigurations
import org.gradle.api.Action; //導入依賴的package包/類
private void configureConfigurations(final Project project) {
ConfigurationContainer configurations = project.getConfigurations();
project.setProperty("status", "integration");
Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).
setDescription("Configuration for archive artifacts.");
configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).
setDescription("Configuration for default artifacts.");
final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
"defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
);
configurations.all(new Action<Configuration>() {
public void execute(Configuration configuration) {
configuration.getArtifacts().all(new Action<PublishArtifact>() {
public void execute(PublishArtifact artifact) {
defaultArtifacts.addCandidate(artifact);
}
});
}
});
}
示例10: execute
import org.gradle.api.Action; //導入依賴的package包/類
@Override
public WorkResult execute(final LinkerSpec spec) {
LinkerSpec transformedSpec = specTransformer.transform(spec);
List<String> args = argsTransformer.transform(transformedSpec);
invocationContext.getArgAction().execute(args);
new VisualCppOptionsFileArgsWriter(spec.getTempDir()).execute(args);
final CommandLineToolInvocation invocation = invocationContext.createInvocation(
"linking " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {
@Override
public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
buildQueue.add(invocation);
}
});
return new SimpleWorkResult(true);
}
示例11: process
import org.gradle.api.Action; //導入依賴的package包/類
public void process(SerializableCoffeeScriptCompileSpec spec) {
Scriptable coffeeScriptScope = parse(spec.getCoffeeScriptJs(), "UTF-8", new Action<Context>() {
public void execute(Context context) {
context.setOptimizationLevel(-1);
}
});
String encoding = spec.getOptions().getEncoding();
CoffeeScriptCompileDestinationCalculator destinationCalculator = new CoffeeScriptCompileDestinationCalculator(spec.getDestinationDir());
for (RelativeFile target : spec.getSource()) {
String source = readFile(target.getFile(), encoding);
String output = compile(coffeeScriptScope, source, target.getRelativePath().getPathString());
writeFile(output, destinationCalculator.transform(target.getRelativePath()), encoding);
}
}
示例12: configureCompileDefaults
import org.gradle.api.Action; //導入依賴的package包/類
private static void configureCompileDefaults(final Project project, final ScalaRuntime scalaRuntime) {
project.getTasks().withType(ScalaCompile.class, new Action<ScalaCompile>() {
@Override
public void execute(final ScalaCompile compile) {
compile.getConventionMapping().map("scalaClasspath", new Callable<FileCollection>() {
@Override
public FileCollection call() throws Exception {
return scalaRuntime.inferScalaClasspath(compile.getClasspath());
}
});
compile.getConventionMapping().map("zincClasspath", new Callable<Configuration>() {
@Override
public Configuration call() throws Exception {
Configuration config = project.getConfigurations().getAt(ZINC_CONFIGURATION_NAME);
if (config.getDependencies().isEmpty()) {
project.getDependencies().add("zinc", "com.typesafe.zinc:zinc:" + DefaultScalaToolProvider.DEFAULT_ZINC_VERSION);
}
return config;
}
});
}
});
}
示例13: parse
import org.gradle.api.Action; //導入依賴的package包/類
public static Scriptable parse(File source, String encoding, Action<Context> contextConfig) {
Context context = Context.enter();
if (contextConfig != null) {
contextConfig.execute(context);
}
Scriptable scope = context.initStandardObjects();
try {
Reader reader = new InputStreamReader(new FileInputStream(source), encoding);
try {
context.evaluateReader(scope, reader, source.getName(), 0, null);
} finally {
reader.close();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
Context.exit();
}
return scope;
}
示例14: apply
import org.gradle.api.Action; //導入依賴的package包/類
@Override
public void apply(Project rootProject) {
final String circleReportsDir = System.getenv("CIRCLE_TEST_REPORTS");
if (circleReportsDir == null) {
return;
}
configureBuildFailureFinalizer(rootProject, circleReportsDir);
final StyleTaskTimer timer = new StyleTaskTimer();
rootProject.getGradle().addListener(timer);
rootProject.allprojects(new Action<Project>() {
@Override
public void execute(final Project project) {
project.getTasks().withType(Checkstyle.class, new Action<Checkstyle>() {
@Override
public void execute(Checkstyle checkstyleTask) {
configureCheckstyleTask(project, checkstyleTask, circleReportsDir, timer);
}
});
project.getTasks().withType(FindBugs.class, new Action<FindBugs>() {
@Override
public void execute(FindBugs findbugsTask) {
configureFindbugsTask(project, findbugsTask, circleReportsDir, timer);
}
});
}
});
}
示例15: configureFindbugsTask
import org.gradle.api.Action; //導入依賴的package包/類
private void configureFindbugsTask(
final Project project,
final FindBugs findbugsTask,
final String circleReportsDir,
final StyleTaskTimer timer) {
// Ensure XML output is enabled
findbugsTask.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
for (SingleFileReport report : findbugsTask.getReports()) {
report.setEnabled(false);
}
FindBugsXmlReport xmlReport = (FindBugsXmlReport) findbugsTask.getReports().findByName("xml");
xmlReport.setEnabled(true);
xmlReport.setWithMessages(true);
}
});
// Configure the finalizer task
CircleStyleFinalizer finalizer = createTask(
project.getTasks(),
findbugsTask.getName() + "CircleFinalizer",
CircleStyleFinalizer.class);
if (finalizer == null) {
// Already registered (happens if the user applies us to the root project and subprojects)
return;
}
finalizer.setReportParser(FindBugsReportHandler.PARSER);
finalizer.setStyleTask(findbugsTask);
finalizer.setReporting(findbugsTask);
finalizer.setStyleTaskTimer(timer);
finalizer.setTargetFile(new File(
new File(circleReportsDir, "findbugs"),
project.getName() + "-" + findbugsTask.getName() + ".xml"));
findbugsTask.finalizedBy(finalizer);
}