Hello,

Martin Stephan wrote:
> 
> So I'm trying to do automated version numbering and again, I guess,
> there are much better ways but I'm trying to understand why the code
> below is not working when I call 'gradle minor jar'.
> 

Adam has already addressed your DAG related points/questions, but I thought
I'd explain how I'm handling version numbering.

I've got a "release" plugin, which is responsible for tagging code and
uploading artifacts to the right place. I've created my own Version class
which has methods for incrementing the build number (with understanding of
"SNAPSHOT").

Release tweaks the init task in the Release tasks constructor:

                Task initTask = project.getTasksByName("init",
false).iterator().next();

                initTask.doFirst(new TaskAction() {
                        @Override
                        public void execute(Task task)
                        {
                               
if(task.getProject().getBuild().getTaskGraph().hasTask(":release"))
                                {
                                        configureVersion(task);
                                }
                        }
                });
 
"configureVersion({})" increments the build number.

Release also depends upon the dist task, so if "release" is invoked

                gradle release -Dsome_arguments

1) the task added to the initTasks pre-execution (doFirst) step is executed,
incrementing the build number
2) the jar/dists/lib tasks are executed. These use the version number that
has been incremented in the initTask.doFirst method
3) if everything finished OK, the release plugin saves the new version do
disk and commits it to SCM.

This is obviously done in an external plugin, but you can achieve the same
thing directly in the build.gradle file.

Phil.



-- 
View this message in context: 
http://www.nabble.com/DAG%2C-doFirst%28%29-tp20255970p20257021.html
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to