Thanks very much for that. I'll give this a test over the weekend. Is there an expected timeline for Gradle 0.9? Also, has there been any previous discussion about 'Target Platforms'? Or was that part of the discussion about the 'Java Application' plugin?
Thanks, - Andrew Thorburn On Tue, Dec 1, 2009 at 12:31 PM, Adam Murdoch <[email protected]> wrote: > > There's no declarative way to do this, you'd need to do some scripting. It > would be nice if Gradle had the concept of target platforms, so it could > take care of most of this for you. > > Here's a rough idea of how you might do this. This is untested, but should > give you some ideas: > > usePlugin 'java' > > targetPlatforms = ['windows-32', 'windows-64' ... ] > > targetPlatforms.each { platform -> > // add the configuration for the platform > > configurations.add(platform).extendsFrom(configurations.compile) > > // add the tasks > > task "${platform}-jar"(type: Jar) { > from sourceSets.main.classes > baseName = "myproject-${platform}" > } > > File imageDir = new File(buildDir, "distImage") > > task "${platform}-distImage"(type: Copy) { > dependsOn "${platform}-jar" > from("${platform}-jar".archivePath) { > into imageDir > } > } > > task "${platform}-zip"(type: Zip) { > dependsOn "${platform}-distImage" > fileset(dir: imageDir) > baseName = "myproject-${platform}" > } > > // ... same again for the Tar task ... > > // configure the bits we don't know until later > afterEvaluate { > Set platformLibs = configurations[platform].files - > configurations.compile.files > > "${platform}-jar" { > Collection classpath = configurations.compile.collect { > "lib/$it.name" } + platformLibs.collect { "lib/$platform/$it.name" } > manifest.mainAttributes['Class-Path'] = classpath.join(' ') > } > > "${platform}-distImage" { > from(configurations.compile) { > into "$imageDir/lib" > } > from(platformLibs) { > into "$imageDir/lib/$platform" > } > } > } > } > > > This will be quite a bit simpler in Gradle 0.9, as the API for archive tasks > is a lot more flexible. You won't need, for example, the distImage task. Or > the afterEvaluate {} closure. > >> If not, I'd be happy to try and write a plugin for this >> (again, given the time...), but I'm not sure what the best approach >> would be... >> >> > > I think the missing bit is the concept of a target platform. This, combined > with a 'java-application' plugin, or a 'java-library' plugin (both of which > we've talked about before) would solve the problem. Each java project would > have an associated set of target platforms. The set would default to > something like 'unspecified' or 'platform-independent' or something. A > 'platform' might be an os/arch combination, or a java version, or a > database, or a groovy version, or some combination of these. > > Then, a 'java-application' plugin would generate a distribution for each > target platform, which would look pretty much like what you've described > above. A 'java-library' plugin would do a similar thing. > > > -- > Adam Murdoch > Gradle Developer > http://www.gradle.org > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
