use of org.gradle.api.tasks.TaskAction in project spring-boot by spring-projects.
the class RepackageTask method repackage.
@TaskAction
public void repackage() {
Project project = getProject();
SpringBootPluginExtension extension = project.getExtensions().getByType(SpringBootPluginExtension.class);
ProjectLibraries libraries = getLibraries();
project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
}
use of org.gradle.api.tasks.TaskAction in project spring-boot by spring-projects.
the class FindMainClassTask method setMainClassNameProperty.
@TaskAction
public void setMainClassNameProperty() {
Project project = getProject();
if (!project.hasProperty("mainClassName") || project.property("mainClassName") == null) {
String mainClass = findMainClass();
if (project.hasProperty("mainClassName")) {
project.setProperty("mainClassName", mainClass);
} else {
ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project.getExtensions().getByName("ext");
extraProperties.set("mainClassName", mainClass);
}
}
}
use of org.gradle.api.tasks.TaskAction in project gradle-eta by typelead.
the class EtaResolveDependencies method resolveDependencies.
@TaskAction
public void resolveDependencies() {
/* Create the destination directory if it doesn't exist. */
File workingDir = getDestinationDirectory();
if (!workingDir.exists() && !workingDir.mkdirs()) {
throw new GradleException("Unable to create destination directory: " + workingDir.getAbsolutePath());
}
/* Remove the cabal.project.freeze file from a previous run, if it exists. */
File existingFreezeFile = getFreezeConfigFile();
if (existingFreezeFile.exists() && !existingFreezeFile.delete()) {
throw new GradleException("Unable to delete existing freeze file: " + existingFreezeFile.getAbsolutePath());
}
/* Generate the .cabal & cabal.project files. */
final WriteResult[] writeResults = new WriteResult[2];
DependencyUtils.foldEtaDependencies(project, dependencies.get(), (directDeps, projectDeps) -> {
writeResults[0] = CabalHelper.generateCabalFile(getProject().getName(), getProject().getVersion().toString(), directDeps, workingDir);
}, gitDeps -> {
writeResults[1] = CabalHelper.generateCabalProjectFile(gitDeps, workingDir);
});
/* Delete existing *.cabal files to avoid errors when changing the project
name. */
final File oldCabalFile = writeResults[0].getFile();
project.delete(project.fileTree(workingDir, fileTree -> {
fileTree.include("*.cabal");
fileTree.exclude(fileTreeElement -> {
try {
return fileTreeElement.getFile().getCanonicalPath().equals(oldCabalFile.getCanonicalPath());
} catch (IOException e) {
return true;
}
});
}));
/* Only run the freeze command if the cabal files have changed or the
Eta version state has changed. */
boolean changed = writeResults[0].isChanged() || writeResults[0].isChanged() || getVersionsChanged();
if (changed) {
/* Fork an etlas process to freeze the dependencies. */
EtlasCommand etlas = new EtlasCommand(getProject());
etlas.getWorkingDirectory().set(workingDir);
etlas.freeze();
}
setDidWork(changed);
}
use of org.gradle.api.tasks.TaskAction in project gradle-eta by typelead.
the class EtaSetupEnvironment method setupEnvironment.
@TaskAction
public void setupEnvironment() {
EtlasCommand etlas = new EtlasCommand(getProject());
ResolvedExecutable etlasExec = resolveEtlas();
/* This is a bootstrap step since we need to populate
this property in order for the following etlas
invocation to work. */
resolvedEtlas.set(etlasExec);
ensureTelemetryPreferencesAndUpdate(etlas);
if (etlasExec.getVersion() == null) {
etlasExec.setVersion(etlas.numericVersion());
}
ResolvedExecutable etaExec = resolveEta(etlas);
resolvedEta.set(etaExec);
if (etaExec.isFresh()) {
getProject().getLogger().lifecycle("Installing Eta v" + etaExec.getVersion());
etlas.installEta();
}
boolean changed = SnapshotUtils.takeSnapshotAndCompare(getVersionsSnapshot(), etaExec, etlasExec, getEtaSpec(), getEtlasSpec());
resolvedEtaInfo.set(fetchEtaInfo(etlas, etaExec, changed));
versionsChanged.set(Boolean.valueOf(changed));
setDidWork(changed);
}
use of org.gradle.api.tasks.TaskAction in project curiostack by curioswitch.
the class DeployConfigMapTask method exec.
@TaskAction
public void exec() {
ImmutableDeploymentExtension config = getProject().getExtensions().getByType(DeploymentExtension.class);
final ImmutableDeploymentConfiguration deploymentConfig = config.getTypes().getByName(type);
Map<String, RpcAcl> aclMap = deploymentConfig.rpcAcls().entrySet().stream().map(entry -> new SimpleImmutableEntry<>(entry.getKey(), ImmutableRpcAcl.builder().rate(entry.getValue()).build())).collect(toImmutableMap(Entry::getKey, Entry::getValue));
final String serializedAcls;
try {
serializedAcls = OBJECT_MAPPER.writeValueAsString(aclMap);
} catch (JsonProcessingException e) {
throw new UncheckedIOException("Could not serialize acls.", e);
}
ConfigMap configMap = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("rpcacls").withNamespace(deploymentConfig.namespace()).build()).withData(ImmutableMap.of("rpcacls.json", serializedAcls)).build();
KubernetesClient client = new DefaultKubernetesClient();
client.resource(configMap).createOrReplace();
}
Aggregations