On Jul 21, 2009, at 9:14 PM, Philip Crotwell wrote:

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?

No. But I agree that we should change the internal repository naming schema. There is a Jira for this: http://jira.codehaus.org/browse/GRADLE-564 . This will be fixed in 0.7.1.


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) }
}

A good solution to this problem would be to have an additional method in the configuration that returns an object which returns the artifact metadata (name, version, ...) together with the artifact file. This is something we will offer in 0.8:

What should work already is something like:

defaultConf = configurations.default
defaultConf.files { dep -> dep instanceof ExternalDependency }.each { file ->
        ant.copy(file: file, todir: libDir)
}

configurations.default.allDependencies(ProjectDependency).each { projectDep ->
    projectDep.projectConfiguration.allArtifacts.each { artifact ->
        ant.copy(file: artifact.file, todir: libDir)
    }
    projectDep. projectConfiguration.each { file ->
        ant.copy(file: file, todir: libDir)
    }
}

If you have nested project dependencies you need a recursion here.

As said, in 0.7.1 the internal repository will have versioned file names and in 0.8 you will additionally have access to the artifact metadata and can then easily define your own naming schema for the copied files.

- Hans

--
Hans Dockter
Gradle Project Manager
http://www.gradle.org




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




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

   http://xircles.codehaus.org/manage_email


Reply via email to