Hi

Thanks, that helped. All external dependencies and the artifact of the
current project are put in the lib dir correctly. However, this is a
multiproject with dependencies like:

dependencies {
    compile project(':seisFile') {
        transitive = true
    }
}

but instead of seisFile-1.0.6.jar in the lib dir, I get seisFile.jar.
The default configuration for the dependency project has:
.gradle/internal-repository/edu.sc.seis/seisFile/1.0.6/jars/seisFile.jar
but the jar does not have the version in the filename, so the simple
ant.copy doesn't either.

I have this task now, which parses the path of the file to get the
version number, but this seems a bit of a hack, and probably very
fragile. Is there a way to get jarfiles with the version without
parsing this path?

Or is the internal-repository configurable to have the version as part
of the filename?

task copyToLib(dependsOn: libs) << {
    libDir = new File('test/output/lib')
    libDir.mkdirs()
    configurations.default.each { File file ->
        outFile = ''        splitPath = file.path.split("/")
                if (splitPath[-6] == 'internal-repository') {
                    outFile = splitPath[-4]+'-'+splitPath[-3]+'.jar'
                } else {
                    outFile = file.name
                }
        ant.copy(file: file.path, toFile: new File(libDir, outFile))
    }
    configurations.default.allArtifacts.each { artifact ->
ant.copy(file: artifact.file, todir: libDir) }
}

thanks,
Philip

On Tue, Jul 21, 2009 at 12:10 PM, Hans Dockter<[email protected]> wrote:
>
> On Jul 21, 2009, at 5:11 PM, Philip Crotwell wrote:
>
>> Hi
>>
>> What I want to do is to create a lib directory that contains all of
>> the jars for a project, both directly generated as well as
>> dependencies. The idea is to the create a distribution tar that
>> contains a lib dir with all needed jars and a bin that contains
>> scripts to run using the items in lib. I have a simple copy task that
>> mostly does this, but jars from dependency multi-projects do not have
>> the version, while jars from dependencies do. This is because jar
>> files in .gradle/internal-repository do not have the version in the
>> filename, ie they are named something like:
>> .gradle/internal-repository/edu.sc.seis/seisFile/1.0.6/jars/seisFile.jar
>>
>> I realize the version is in the directory name, but wouldn't it be
>> better also to name the actual jar along with the recommendations
>> within the user guide, ie seisFile-1.0.6.jar?
>>
>> task copyToLib(dependsOn: uploadArchives) << {
>>   libDir = new File('test/output/lib')
>>   libDir.mkdirs()
>>   configurations.default.each { File file -> ant.copy(file:
>> file.path, toDir: libDir) }
>>   repositories { flatDir(dirs: libDir) }
>> }
>>
>> uploadArchives {
>>   libDir = new File('test/output/lib')
>>   libDir.mkdirs()
>>   repositories {
>>      flatDir(dirs: libDir)
>>   }
>> }
>>
>> Or is there a better way of creating a lib dir with all needed jars
>> and with the name-version.jar naming scheme? Perhaps something similar
>> to uploadArchives that handles dependencies?
>
> There is probably a better way.
>
> task copyToLib(dependsOn: libs) {
>   libDir = new File('test/output/lib')
>   libDir.mkdirs()
>   configurations.default.each { ... }
>   configurations.default.allArtifacts.each { artifact ->
>      ant.copy(file: artifact.file, todir: libDir)
>   }
> }
>
> You don't need the uploading for this.
>
> BTW: For 0.8 we want to provide methods to a configuration that allows you
> to copy things: configurations.default.copy(...)
>
> - Hans
>
> --
> Hans Dockter
> Gradle Project Manager
> 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


Reply via email to