Hans,

Thanks for the feedback.
Concerning the issue I had with compile returning a "cannot find symbol", it was caused by a bug in javac:

http://bugs.sun.com/view_bug.do?bug_id=6707323

Changing the import order solved the issue.

It seems that eclipse does not have this issue. This makes me wonder what compiler eclipse is using.

Further question concerning compile:

The ant task javac has different attributes such as "compiler", "depend", etc.
How can I set these from within gradle ?

- Ron

Hans Dockter wrote:
Hi Ron,

apologies that you had to wait that long for a response.

On Dec 13, 2008, at 10:14 PM, rzo wrote:

The classpath now seems to be correctly set, but I am getting "cannot find symbol". The error is however not in all classes where the symbol (class name) is used. This gives me the impression that the classes are compiled in the wrong order.

BTW: within eclipse the project compiles with the same classpath with no errors.

rzo wrote:
Found part of the problem:

The pattern for file matching should be:

~/.*\.jar/


rzo wrote:
Hello,

I am new to Gradle and have little knowledge of Ant or Maven.
I am missing an example for a simple script which would just compile and jar a project. The only helpful example I found : http://www.alittlemadness.com/2008/11/28/maven-pain-gradle/

I am trying the following script. But I cannot get Gradle to use the classpath. I also had to comment out the name, since this causes an exception (Readonly property) So the next question is: how do I tell Gradle the name of the jar to generate ?

If the archive name should be different than the project name (which is by default the root directory name), you have to set:

archivesBaseName = 'myArchiveName'



- Ron

build.gradle:

defaultTasks "libs"
//name = 'test'
archivesBaseName = ''

This is correct (if you assign a real name to it).


version = 'alpha-4.2'

usePlugin('java')
sourceCompatibility = 1.5

targetCompatibility = 1.5
srcDirNames = ['.']



List findAllJars() {
      result = []
      new File('lib').eachDirRecurse(
      {
          dir ->
          dir.eachFileMatch(
          '.*\\.jar',
          {
            file ->
            result.add(file)
          })
      })
      result
      }

compile.unmanagedClasspath = findAllJars()

This should work (although there are alternative approaches for your use case). What is printed out in case of: println(findAllJars())?

What you could do alternatively is:

dependencies {
addFlatDirResolver('myLibResolver', 'dir1', 'dir2').addArtifactPattern('[artifact].[ext]') // This notation looks a bit strange: The usual notation is "groupId:jarName:version". If you store your dependencies in a flat directory groupId can be left out. If you don't use versions the same applies to versions. But you still need the colons.
         compile ":log4j::1.2.13", ...
        test ...
}

But I clearly admit that Gradle is not as straight forward as it should be in supporting this simple use case. We too much assume a Maven like approach, were your jars are somewhere in a repository, all have a version number, and you list the jars you are using explicitly. Although we think it makes usually sense, to be explicit and expressive about the jars you are using, this should not hinder us in supporting situations where people want to do it differently.

We know already how we can improve this. We want to get rid of the whole unmanaged classpath stuff and offer something like this:

dependencies {
    compile findAllJars()
        test findAllTestJars()
}

And everything else would work fine for you out of the box.

- Hans

--
Hans Dockter
Gradle Project lead
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