Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1483

Tasks of type JavaExec fails to honor inputs/outputs

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.0-milestone-2
    • Fix Version/s: 1.0-milestone-9

      Description

      The following task will always run regardless:

      /** Generate webservice source files from wsdl **/
      wsdlDir = file("src/main/resources/wsdl")
      wsdlFile = file("$wsdlDir/SakWS.wsdl")
      jaxbBindingsFile = file("$wsdlDir/jaxbBindings.xml")
      task wsdl2Java(type: JavaExec) {    
          inputs.files configurations.cxfCodeGenLibs, wsdlFile, jaxbBindingsFile
          outputs.files generatedWsdlDir
          main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
          classpath = configurations.cxfCodeGenLibs
          args '-b', jaxbBindingsFile,
                  '-d', generatedWsdlDir,
                  '-xjc-Xts',
                  wsdlFile
      }
      compileJava.dependsOn wsdl2Java
      

        Activity

        rundis Magnus Rundberget created issue -
        Hide
        rundis Magnus Rundberget added a comment - - edited

        This workaround from Adam fixes it;

        outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()  
        
        Show
        rundis Magnus Rundberget added a comment - - edited This workaround from Adam fixes it; outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
        pniederw Peter Niederwieser made changes -
        Field Original Value New Value
        Description The following task will always run regardless:
        /** Generate webservice source files from wsdl **/
        wsdlDir = file("src/main/resources/wsdl")
        wsdlFile = file("$wsdlDir/SakWS.wsdl")
        jaxbBindingsFile = file("$wsdlDir/jaxbBindings.xml")
        task wsdl2Java(type: JavaExec) {
            inputs.files configurations.cxfCodeGenLibs, wsdlFile, jaxbBindingsFile
            outputs.files generatedWsdlDir
            main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
            classpath = configurations.cxfCodeGenLibs
            args '-b', jaxbBindingsFile,
                    '-d', generatedWsdlDir,
                    '-xjc-Xts',
                    wsdlFile
        }
        compileJava.dependsOn wsdl2Java
        The following task will always run regardless:

        {code}
        /** Generate webservice source files from wsdl **/
        wsdlDir = file("src/main/resources/wsdl")
        wsdlFile = file("$wsdlDir/SakWS.wsdl")
        jaxbBindingsFile = file("$wsdlDir/jaxbBindings.xml")
        task wsdl2Java(type: JavaExec) {
            inputs.files configurations.cxfCodeGenLibs, wsdlFile, jaxbBindingsFile
            outputs.files generatedWsdlDir
            main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
            classpath = configurations.cxfCodeGenLibs
            args '-b', jaxbBindingsFile,
                    '-d', generatedWsdlDir,
                    '-xjc-Xts',
                    wsdlFile
        }
        compileJava.dependsOn wsdl2Java
        {code}
        Hide
        pniederw Peter Niederwieser added a comment -

        Is there any particular reason why we set upToDateWhen {false} for JavaExec?

        Show
        pniederw Peter Niederwieser added a comment - Is there any particular reason why we set upToDateWhen {false } for JavaExec?
        daz Daz DeBoer made changes -
        Workflow jira [ 12905 ] jira with pivotal tracker [ 14473 ]
        Hide
        ldaley Luke Daley added a comment -

        The javaexec task can now be made incremental if you declare some outputs.

        Out of the box it does not declare any outputs so will not be incremental.

        Show
        ldaley Luke Daley added a comment - The javaexec task can now be made incremental if you declare some outputs. Out of the box it does not declare any outputs so will not be incremental.
        ldaley Luke Daley made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Luke Daley [ ldaley ]
        Fix Version/s 1.0-milestone-9 [ 10161 ]
        Resolution Fixed [ 1 ]
        Hide
        mirinae Warren Muller added a comment -

        M6 and M8 did not work for me with:
        outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
        Trying gradle-1.0-milestone-9-20120227005038+0100 (last nights) did not work either. i.e. rebuilds every time
        I am using a slightly more generic version:
        Not all code included but this is the gist of it

                // mc, cp, ag defined above as being set by iteration through a map of settings
        	tasks.add(name: "wsdl2Java${k.capitalize()}",type: JavaExec) {
        		description="Generates Java source for wsdl:${k}=${v.file}"
        		outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
        		outputs.files generatedWsdlDir
        		inputs.files configurations.compile, wsdlFile
        		main = mc
        		classpath = cp
        		args = ag
        		logger.debug "main=${main},classpath=${classpath},args=${args}"
        	}
        	clean.dependsOn "cleanWsdl2Java${k.capitalize()}"
        	project."compile${wsdlSrcSetName.capitalize()}Java".dependsOn "wsdl2Java${k.capitalize()}"
        
        Show
        mirinae Warren Muller added a comment - M6 and M8 did not work for me with: outputs.upToDateSpec = new org.gradle.api.specs.AndSpec() Trying gradle-1.0-milestone-9-20120227005038+0100 (last nights) did not work either. i.e. rebuilds every time I am using a slightly more generic version: Not all code included but this is the gist of it // mc, cp, ag defined above as being set by iteration through a map of settings tasks.add(name: "wsdl2Java${k.capitalize()}" ,type: JavaExec) { description= "Generates Java source for wsdl:${k}=${v.file}" outputs.upToDateSpec = new org.gradle.api.specs.AndSpec() outputs.files generatedWsdlDir inputs.files configurations.compile, wsdlFile main = mc classpath = cp args = ag logger.debug "main=${main},classpath=${classpath},args=${args}" } clean.dependsOn "cleanWsdl2Java${k.capitalize()}" project. "compile${wsdlSrcSetName.capitalize()}Java" .dependsOn "wsdl2Java${k.capitalize()}"
        Hide
        miken MikeN added a comment -

        M6 and M7 work for me with

        outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
        
        Show
        miken MikeN added a comment - M6 and M7 work for me with outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
        ldaley Luke Daley made changes -
        Workflow jira with pivotal tracker [ 14473 ] jira with pivotal tracker (no resolved, only closed) [ 17745 ]
        Status Resolved [ 5 ] Closed [ 6 ]
        ldaley Luke Daley made changes -
        Workflow jira with pivotal tracker (no resolved, only closed) [ 17745 ] Copy of jira with pivotal tracker (no closed, only resolved) [ 20372 ]
        Status Closed [ 6 ] Resolved [ 5 ]

          People

          • Assignee:
            ldaley Luke Daley
            Reporter:
            rundis Magnus Rundberget
          • Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development