Hi Szczepan,
Thanks for your patience.
I created a minimal project setup to clarify and to reproduce the issues.
Gradle produces two artifacts for my base project:
1. baseproject-0.1.0-SNAPSHOT.jar containing an interface MyService and
2. baseproject-0.1.0-SNAPSHOT-testsupport.jar containing an implementing
class DummyService.
In my other project I use the following dependency snippet from the
build.gradle:
dependencies {
compile 'playground.tth:baseproject:0.1.0-SNAPSHOT'
testCompile 'playground.tth:baseproject:0.1.0-SNAPSHOT:testsupport'
testCompile 'junit:junit:4.7'
}
'gradle eclipse' fetches indeed both baseproject jars. However, neither
the gradle nor the eclipse classpath contain both jars.
To verify, I added a MyClient class to src/main/java referencing a
MyService and a MyClientTest unit test to src/test/java referencing a
concrete DummyService.
Results:
* 'gradle compileJava' runs successfully
* 'gradle compileTestJava' fails since 'class file for
playground.tth.MyService not found'
* after patching .classpath by adding a classpathentry for
baseproject-0.1.0-SNAPSHOT.jar by hand, the project can be built and the
test can be executed within Eclipse.
'gradle --dependencies' does not distinguish classifiers.
Therefore, I still think that using the same project with different
artifacts within the same dependency scope is not a valid gradle usecase.
Best regards,
Thomas
Am 14.03.2011 17:44, schrieb szczepiq:
>Well, I guess gradle simply does not support to reference several
artifacts for the same project with different classifiers within the
same configuration.
>This works only well as long as I do not try to access resources from
the main jar from within the unit tests.
That's strange... Given that both jars (main & testsupport) are
resolvable Gradle should be able to build. At least it builds ok for me
:) Can you double check both jars are located in your local repo or
gradle cache?
Nevertheless I think that eclipse .classpath generation misbehaves and
adds only one dependency instead of two. Can you file a jira ticket?
Cheers!
Szczepan
I think you're right I was able . It seems it is a problem with an
eclipse plugin
On Mon, Mar 14, 2011 at 4:21 PM, Thomas Thevis <thevis.ml
<http://thevis.ml>@googlemail.com <http://googlemail.com>> wrote:
Hello Szczepan,
I have to correct my initial statement:
> dependencies {
> compile 'my.group:baseproject:1.0'
> testCompile 'my.group:baseproject:1.0:testsupport'
> }
>
> This works well for plain gradle tasks. I can compile both
main and
> test classes. Tests can be run without problems.
This works only well as long as I do not try to access resources
from the main jar from within the unit tests.
Well, I guess gradle simply does not support to reference several
artifacts for the same project with different classifiers within the
same configuration.
> Do you mean that in your case the .classpath content depends on the
> order of entries in dependencies { } ?
Yes. My eclipse classpath contains all the libs which are referenced
from the 'testCompile' configuration. Based on the first guess from
above, I assume that only one of the two candidate artifacts will
make it to the final dependency list and which one seems to depend
on the order of declaration within the dependencies {} block.
Therefore, I ended up putting the test support related code into its
own package within the main jar. The main disadvantage is that I had
to promote some dependencies from 'testCompile' to 'compile'
configuration which is obviously kind of bad for a base project.
If anyone has a better idea, please let me know.
Thanks,
Thomas
Am 14.03.2011 15:44, schrieb szczepiq:
Hello,
>However, the eclipse plugin does not add both jars as libs to the
classpath entries. Instead, only the one which comes last in the
dependencies configuration is added.
Do you mean that in your case the .classpath content depends on the
order of entries in dependencies { } ?
Can you check if both jars (the main & testsupport) are in .gradle
caches or the local maven repo?
I couldn't reproduce this issue. Given both jars are resolvable then
.classpath was created with both entries. Interestingly, if the
'classified' jar was not resolvable then gradle eclipse executed OK,
however it crated .classpath without the 'classified' jar.
Hope that helps!
Szczepan
On Sun, Mar 13, 2011 at 2:09 PM, Thomas Thevis <thevis.ml
<http://thevis.ml>
<http://thevis.ml>@googlemail.com <http://googlemail.com>
<http://googlemail.com>> wrote:
Hello all,
for a base java project consisting mainly of interfaces and
abstract
classes I created both a baseproject-1.0.jar and a
baseproject-1.0-testsupport.jar which is made up of mock
implementations and intended to be used for unit tests.
In another project I want to declare dependencies as follows:
dependencies {
compile 'my.group:baseproject:1.0'
testCompile 'my.group:baseproject:1.0:testsupport'
}
This works well for plain gradle tasks. I can compile both
main and
test classes. Tests can be run without problems.
However, the eclipse plugin does not add both jars as libs
to the
classpath entries. Instead, only the one which comes last in the
dependencies configuration is added.
Is this a bug in the eclipse plugin or am I using it the
wrong way?
If it is a bug, does anyone know a workaround?
BTW: I'm using gradle-0.9.1 and gradle-1.0-milestone-1.
Thanks for any help!
Thomas
---------------------------------------------------------------------
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