use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class PlayRun method run.
@TaskAction
public void run() {
String deploymentId = getPath();
DeploymentRegistry deploymentRegistry = getDeploymentRegistry();
PlayApplicationDeploymentHandle deploymentHandle = deploymentRegistry.get(deploymentId, PlayApplicationDeploymentHandle.class);
if (deploymentHandle == null) {
PlayRunSpec spec = new DefaultPlayRunSpec(runtimeClasspath, changingClasspath, applicationJar, assetsJar, assetsDirs, workingDir.get().getAsFile(), getForkOptions(), getHttpPort());
PlayApplicationRunner playApplicationRunner = playToolProvider.get(PlayApplicationRunner.class);
deploymentHandle = deploymentRegistry.start(deploymentId, DeploymentRegistry.ChangeBehavior.BLOCK, PlayApplicationDeploymentHandle.class, spec, playApplicationRunner);
InetSocketAddress playAppAddress = deploymentHandle.getPlayAppAddress();
String playUrl = "http://localhost:" + playAppAddress.getPort() + "/";
LOGGER.warn("Running Play App ({}) at {}", getPath(), playUrl);
}
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class ApiJar method createApiJar.
@TaskAction
public void createApiJar() throws IOException {
// Make sure all entries are always written in the same order
final List<File> sourceFiles = sortedSourceFiles();
final ApiClassExtractor apiClassExtractor = new ApiClassExtractor(getExportedPackages());
withResource(new JarOutputStream(new BufferedOutputStream(new FileOutputStream(getOutputFile()), 65536)), new ErroringAction<JarOutputStream>() {
@Override
protected void doExecute(final JarOutputStream jos) throws Exception {
writeManifest(jos);
writeClasses(jos);
}
private void writeManifest(JarOutputStream jos) throws IOException {
writeEntry(jos, "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n".getBytes());
}
private void writeClasses(JarOutputStream jos) throws Exception {
for (File sourceFile : sourceFiles) {
if (!isClassFile(sourceFile)) {
continue;
}
ClassReader classReader = new PatchedClassReader(readFileToByteArray(sourceFile));
if (!apiClassExtractor.shouldExtractApiClassFrom(classReader)) {
continue;
}
byte[] apiClassBytes = apiClassExtractor.extractApiClassFrom(classReader);
if (apiClassBytes == null) {
// Should be excluded
continue;
}
String internalClassName = classReader.getClassName();
String entryPath = internalClassName + ".class";
writeEntry(jos, entryPath, apiClassBytes);
}
}
private void writeEntry(JarOutputStream jos, String name, byte[] bytes) throws IOException {
JarEntry je = new JarEntry(name);
// Setting time to 0 because we need API jars to be identical independently of
// the timestamps of class files
je.setTime(0);
je.setSize(bytes.length);
jos.putNextEntry(je);
jos.write(bytes);
jos.closeEntry();
}
});
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class CreateStaticLibrary method link.
// TODO: Need to track version/implementation of ar tool.
@TaskAction
public void link() {
StaticLibraryArchiverSpec spec = new DefaultStaticLibraryArchiverSpec();
spec.setTempDir(getTemporaryDir());
spec.setOutputFile(getOutputFile().get().getAsFile());
spec.objectFiles(getSource());
spec.args(getStaticLibArgs().get());
BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
spec.setOperationLogger(operationLogger);
Compiler<StaticLibraryArchiverSpec> compiler = createCompiler();
WorkResult result = BuildOperationLoggingCompilerDecorator.wrap(compiler).execute(spec);
setDidWork(result.getDidWork());
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class StripSymbols method stripSymbols.
// TODO: Need to track version/implementation of symbol strip tool.
@TaskAction
public void stripSymbols() {
BuildOperationLogger operationLogger = getServices().get(BuildOperationLoggerFactory.class).newOperationLogger(getName(), getTemporaryDir());
StripperSpec spec = new DefaultStripperSpec();
spec.setBinaryFile(binaryFile.get().getAsFile());
spec.setOutputFile(outputFile.get().getAsFile());
spec.setOperationLogger(operationLogger);
Compiler<StripperSpec> symbolStripper = createCompiler();
symbolStripper = BuildOperationLoggingCompilerDecorator.wrap(symbolStripper);
WorkResult result = symbolStripper.execute(spec);
setDidWork(result.getDidWork());
}
use of org.gradle.api.tasks.TaskAction in project gradle by gradle.
the class GenerateMavenPom method doGenerate.
@TaskAction
public void doGenerate() {
MavenPomInternal pomInternal = (MavenPomInternal) getPom();
MavenPomFileGenerator pomGenerator = new MavenPomFileGenerator(pomInternal.getProjectIdentity(), getVersionRangeMapper());
pomGenerator.setPackaging(pomInternal.getPackaging());
for (MavenDependency mavenDependency : pomInternal.getApiDependencyManagement()) {
pomGenerator.addApiDependencyManagement(mavenDependency);
}
for (MavenDependency mavenDependency : pomInternal.getRuntimeDependencyManagement()) {
pomGenerator.addRuntimeDependencyManagement(mavenDependency);
}
for (MavenDependencyInternal runtimeDependency : pomInternal.getApiDependencies()) {
pomGenerator.addApiDependency(runtimeDependency);
}
for (MavenDependencyInternal runtimeDependency : pomInternal.getRuntimeDependencies()) {
pomGenerator.addRuntimeDependency(runtimeDependency);
}
pomGenerator.withXml(pomInternal.getXmlAction());
pomGenerator.writeTo(getDestination());
}
Aggregations