On 22/06/10 3:14 AM, Simon Tardell wrote:
Hello,
I just started looking at Gradle so forgive me if I ask the obvious
(though I did make an effort before posting...).
I have a multi-module project built by a master ant-script that call
the individual modules' build.xml in order. Each individual build.xml
picks up the jars it needs from the dist directories of modules that
built before it. Now I want to turn this monster into gradle, gradually.
Basically I want to use the existing build.xml in a module, if a
build.gradle does not exist (if a build.gradle exists the build.xml
should be ignored). The imported project should then somehow be
decorated with declaration of the artifacts it produces so that I can
pick it up from depending build.gradles (I understand this happens
magically if you use the java plugin e.g.). In my case I know that the
produced artifacts will be all the jars in the dist directory of the
module, so it should be possible to express generically.
So, my question is then: How do I declare the jars I built as
artifacts, and can I do that in a generic way so that I can pass it to
allprojects?
You could do something like this, in the root build.gradle (this is not
tested, but should give you a starting point):
import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact
allprojects {
if (buildFile.isFile()) {
// project has a build script, so skip it
return
}
ant.import('build.xml')
def jarFile = ....
def jarFileNameWithoutExtension = ...
def taskThatProducesTheJar = ...
def config = configurations.add('default')
config.addArtifact(new
DefaultPublishArtifact(jarFileNameWithoutExtension, 'jar', 'jar', null,
new Date(), jarFile, taskThatProducesTheJar))
}
It's a little awkward to add an artifact. We will make this easier in
after the Gradle 0.9 release.
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email