I am trying to convert a fairly complex Ant build script that also
incorporates Maven tasks into a unified Gradle build. The end-product of the
build is to generate at least one, and up to two WAR files, which are
basically the same, except for some configuration settings files. 

We have a set of files that define the properties for each particular
deployed machine, of the name <machine>.properties. They containing property
definitions of the format "{env}.{setting}=value" where {env} can be one of
the two application environment prefixes we use (for purposes of this
example, we could just call them "foo" and "bar" - so typical lines would be
like 

  foo.dbName=PROD01 
  foo.dbHost=db23.foo.com 
  bar.dbName=TEST55 
  bar.dbHost=db24.test.foo.com 

and so on. If a machine has an environment disabled, there is just one
entry: 

  foo.disabled=true 

and so we don't create any env-specific configuration files from the
templates and 
properties, nor the final 'foo.war'. 

So far, my Gradle script has an 'all' task, which just does a simple loop of 
the form 
   ['foo', 'bar'].each { env -> .....}   

in which it processes the above configuration file, creates a Properties
object with the "{env}." prefix stripped out for the keys, and then calls a
small Groovy method called gen_config(envName, props) to create the various
env-specific XML files in 'target/tmp-${env}'.  The 'all' task has a
dependency on 'compileJava', so my classes have already been built. However,
at this point, I am not able to figure out how to manually invoke the 'war'
task to build one or both of 'foo.war' and/or 'bar.war', using the contents
of 'target/classes' and 'target/${env}-tmp'. 

I have read and re-read the manual and list archives, in particular, about
the Configuration and Execution phases but still don't understand if it's
possible to create dynamic separate tasks to build 'foo.war' and 'bar.war',
given that my 'all' task is already running, and I believe it is too late to
attach a dependency to it. Can I simply invoke the 'war' task manually with
the configuration specifiers to use the necessary files? 

I did attempt doing something like 
  task buildWar(type: War, envName, props) { ...} 
with the hope that I could pass arguments in the task invocation, but had no
success. Can Tasks 
have argument lists? 

Thanks for any help you can give. 

Rich 
-- 
View this message in context: 
http://gradle.1045684.n5.nabble.com/Manually-invoking-a-task-tp3319973p3319973.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