Skip to content

Instantly share code, notes, and snippets.

@abeggchr
Last active Aug 29, 2015
Embed
What would you like to do?
package com.mine.tasks;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import org.apache.commons.io.FileUtils;
public class TaskWithEnum extends DefaultTask {
public enum Language {
DE, FR, IT, EN;
}
private Language[] languages = Language.values();
@TaskAction
public void translate() {
getLogger().info(getLanguages().toString());
try {
FileUtils.writeStringToFile(getTempFile(), "data");
} catch (IOException e) {
getLogger().error(e.getMessage());
}
}
@Input
public Language[] getLanguages() {
return Arrays.copyOf(languages, languages.length);
}
@OutputFile
public File getTempFile() {
return new File(getProject().getBuildDir(), "hi.txt");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment