Skip to content

Instantly share code, notes, and snippets.

@jandsu
Created January 14, 2015 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandsu/978bd8a995c9c3b06de5 to your computer and use it in GitHub Desktop.
Save jandsu/978bd8a995c9c3b06de5 to your computer and use it in GitHub Desktop.
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