Skip to content

Instantly share code, notes, and snippets.

@jandsu
Created Jan 14, 2015
Embed
What would you like to do?
Gradle: unexpected UP-TO-DATE task while output file is missing
apply plugin: 'java'
ext {
dest = file( "${buildDir}/generated-files" )
}
task generate(type:JavaExec, dependsOn: [classes]) {
def destFile = new File(dest, "foo.txt")
outputs.file destFile
main 'org.foo.bar.FooMain'
classpath sourceSets.main.runtimeClasspath
args destFile
doFirst {
dest.mkdirs()
}
}
package org.foo.bar;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
public class FooMain
{
public static void main( String[] args )
throws FileNotFoundException, UnsupportedEncodingException
{
boolean skip = false;
if ( !skip )
{
System.out.println( "Writing file" );
PrintWriter writer = new PrintWriter( args[0], "UTF-8" );
writer.println( "Hello World!" );
writer.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment