Skip to content

Commit

Permalink
State file fixes
Browse files Browse the repository at this point in the history
Skip state file writing when there are no source files and the state
file does not already exist.

This fixes an issue where a freezej state file would be written when
slice2freezej was never executed and did not exit. This created a
bogus state file which would fail on the next build.
  • Loading branch information
externl committed Jan 20, 2017
1 parent ba6b388 commit aa56aca
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/main/groovy/com/zeroc/gradle/icebuilder/slice/SliceTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class SliceTask extends DefaultTask {
}

processJava()

processFreezeJ(project.slice.freezej)
processFreezeJ()
}

@InputFiles
Expand All @@ -65,12 +64,14 @@ class SliceTask extends DefaultTask {
return project.slice.output
}

def processFreezeJ(freezej) {
def processFreezeJ() {
def freezej = project.slice.freezej

// Set of source files and all dependencies.
Set files = []
if(project.slice.freezej.files) {
files.addAll(project.slice.freezej.files)
getS2FDependencies(project.slice.freezej).values().each({ files.addAll(it) })
if(freezej.files) {
files.addAll(freezej.files)
getS2FDependencies(freezej).values().each({ files.addAll(it) })
}

def state = new FreezeJBuildState()
Expand Down Expand Up @@ -111,6 +112,12 @@ class SliceTask extends DefaultTask {
if(freezej.files) {
LOGGER.info("running slice2freezej on the following slice files")
freezej.files.each { LOGGER.info(" ${it}") }
} else if (!stateFile.isFile()) {
// The state file has never been written and and we have no
// files to process. No reason to continue as it will only
// write an empty dependency file.
LOGGER.info("nothing to do")
return
}

// List of generated java source files.
Expand Down Expand Up @@ -392,6 +399,14 @@ class SliceTask extends DefaultTask {
processJavaSet(it, s2jDependencies, state, generated, built, sourceSet)
}

if(built.isEmpty() && !stateFile.isFile()) {
// The state file has never been written and and we have no
// files to process. No reason to continue as it will only
// write an empty dependency file.
LOGGER.info("nothing to do")
return
}

// The set of generated files to remove.
Set oldGenerated = []

Expand Down Expand Up @@ -580,7 +595,7 @@ class SliceTask extends DefaultTask {
}

if(!file.isFile()) {
throw new GradleException("${it}: cannot stat")
throw new GradleException("${file}: cannot stat")
}

def t = file.lastModified()
Expand Down

0 comments on commit aa56aca

Please sign in to comment.