Gradle Build :to check compilation output


(Dwivedi) #1

Hi,

I am trying to create jar from Gradle script which is dependent on another task java Compile.
In Case of javaComile does not do anything i want stop creating jar as there is no change .

1 > is there any method in Gradle to check the javaCompile has done anything or not …
2 > is there any way to check any change in project structure .


(Schalk Cronjé) #2

That behaviour is already there. If javaCompile is up-to-date and processesResources is up-to-date, I would expect jar to be up-to-date as well (in a standard Java project).

As to (2) you have various ways of checking whether systems are up to date. However you should specify what to check, nt actually try to check (let Gradle do the latter). You have the typical dependsOn, but you can also you task.inputs anfd task.outputs to specify for things to check.


(Dwivedi) #3

Thanx for reply .Actually am trying to check for any change in the project like xml images java txt any thing .If change create the jar if no change do not create the jar .How we will check before creating the jar so that we will create jar only when if there is change in the project. Can u pls guide me with any example .


(Schalk Cronjé) #4

In a normal Java project, Gradle will already do all of that for you. If you are planning to include images etc. in your JAR file and they are under src/main/resources they will be copied by the processResources task if any of them changes. The jar task will execute if the processResources task was not up to date. it will also execute if the javaCompile task executed.