You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Stefan Podkowinski <sp...@gmail.com> on 2010/10/11 11:54:30 UTC
[Ivy IDE] source file resolution fails
Can someone please advise what to do to make the source resolution
feature work in Ivy IDE? For each artrifact ivy will download the
appropriate sources to the local cache e.g.:
$HOME/.ivy2/cache/org.springframework/org.springframework.core/jars/org.springframework.core-3.0.4.RELEASE.jar
$HOME/.ivy2/cache/org.springframework/org.springframework.core/srcs/org.springframework.core-sources-3.0.4.RELEASE.jar
However, when I'm trying to open a class from the ivy classpath in
Eclipse, the source file cannot be resolved:
"Source not found"
"The JAR of this class belongs to container 'ivy.xml [*]' which does
not allow modifications to source attachments on its entries"
I noticed that there are some related options under Ivy > Classpath:
Sources types: source
Sources suffixes: -source,-sources,-src
Using Ivy 2.2.0 (20100923230623) and IvyDE 2.1.0.201008101807.
This is really driving me nuts as I have no clues where ivyde is
actually looking for the sources. Any ideas?
Re: [Ivy IDE] source file resolution fails
Posted by Stefan Podkowinski <sp...@gmail.com>.
The ivy.xml I'm using throughout my projects looks more or less like this:
<ivy-module version="2.0">
<info organisation="${ivy.organisation}" module="${ivy.module}"
revision="${ivy.new.revision}"/>
<configurations>
<conf name="default" visibility="public" description="runtime
dependencies and master artifact can be used with this conf"
extends="runtime,master"/>
<conf name="master" visibility="public" description="contains only
the artifact published by this module itself, with no transitive
dependencies"/>
<conf name="compile" visibility="public" description="this is the
default scope, used if none is specified. Compile dependencies are
available in all classpaths."/>
<conf name="provided" visibility="public" description="this is much
like compile, but indicates you expect the JDK or a container to
provide it. It is only available on the compilation classpath, and is
not transitive."/>
<conf name="runtime" visibility="public" description="this scope
indicates that the dependency is not required for compilation, but is
for execution. It is in the runtime and test classpaths, but not the
compile classpath." extends="compile"/>
<conf name="test" visibility="private" description="this scope
indicates that the dependency is not required for normal use of the
application, and is only available for the test compilation and
execution phases." extends="runtime"/>
<conf name="system" visibility="public" description="this scope is
similar to provided except that you have to provide the JAR which
contains it explicitly. The artifact is always available and is not
looked up in a repository."/>
<conf name="sources" visibility="public" description="this
configuration contains the source artifact of this module, if any."/>
<conf name="javadoc" visibility="public" description="this
configuration contains the javadoc artifact of this module, if any."/>
<conf name="optional" visibility="public" description="contains all
optional dependencies"/>
</configurations>
<publications>
<artifact name="${ivy.module}" conf="*"/>
</publications>
<dependencies>
<dependency org="org.springframework"
name="org.springframework.spring-library" rev="3.0.4.RELEASE"/>
<dependency org="org.springframework.security"
name="org.springframework.security.core" rev="3.0.3.RELEASE" />
<dependency org="org.springframework.security"
name="org.springframework.security.config" rev="3.0.3.RELEASE" />
... [ other dependencies ] ...
<exclude module="org.springframework.security"/>
<exclude module="com.springsource.oracle.jdbc"/>
<exclude module="com.springsource.javax.servlet"/>
<exclude module="com.springsource.com.google.common.collect"/>
</dependencies>
</ivy-module>
Placeholders are read from a property file so I only have to change
the dependencies between projects.
On Mon, Oct 11, 2010 at 1:48 PM, David Harrigan <dh...@gmail.com> wrote:
> Hi Sefan
>
> What does your ivy.xml look like?
>
> -=david=-
>
> On 11 October 2010 10:54, Stefan Podkowinski <sp...@gmail.com> wrote:
>> Can someone please advise what to do to make the source resolution
>> feature work in Ivy IDE? For each artrifact ivy will download the
>> appropriate sources to the local cache e.g.:
>>
>> $HOME/.ivy2/cache/org.springframework/org.springframework.core/jars/org.springframework.core-3.0.4.RELEASE.jar
>> $HOME/.ivy2/cache/org.springframework/org.springframework.core/srcs/org.springframework.core-sources-3.0.4.RELEASE.jar
>>
>> However, when I'm trying to open a class from the ivy classpath in
>> Eclipse, the source file cannot be resolved:
>> "Source not found"
>> "The JAR of this class belongs to container 'ivy.xml [*]' which does
>> not allow modifications to source attachments on its entries"
>>
>> I noticed that there are some related options under Ivy > Classpath:
>> Sources types: source
>> Sources suffixes: -source,-sources,-src
>>
>> Using Ivy 2.2.0 (20100923230623) and IvyDE 2.1.0.201008101807.
>>
>> This is really driving me nuts as I have no clues where ivyde is
>> actually looking for the sources. Any ideas?
>>
>
>
>
> --
> I prefer encrypted and signed messages. KeyID: B20A22F9
> Fingerprint: 110A F423 3647 54E2 880F ADAD 1C52 85BF B20A 22F9
>
> "It is not usually until you've built and used a version of the
> program that you understand the issues well enough to get the design
> right." - Rob Pike, Brian Kernighan.
>
RE: How to exclude sources when building using Ant
Posted by David Sills <DS...@datasourceinc.com>.
Interesting, I'll look at those. I agree that if the copying could be
avoided, so much the better.
-----Original Message-----
From: Mitch Gitman [mailto:mgitman@gmail.com]
Sent: Monday, October 11, 2010 11:40 AM
To: ivy-user@ant.apache.org
Subject: Re: How to exclude sources when building using Ant
I recall suggesting on this list the introduction of an exclude-type
attribute on post-resolve tasks (retrieve, cachepath, cachefileset). But
certainly, the type attribute, which implicitly does an include, works
as
long as you know what types you want to include.
I do have to take issue one part of Steve's answer. While there's
nothing
literally wrong with it, I find the ivy:retrieve task to be an ungainly
compromise geared toward users who don't quite embrace or trust Ivy. The
retrieve task is introducing an extra middleman into the process by
copying
the files associated with a conf into a specified location when those
files
are already in the Ivy cache. So you have an extra set of files to
maintain
and invite synchronization/consistency problems with, which is only
mitigated somewhat by the use of the sync attribute. Worse, inevitably
if
you're doing anything slightly complicated with Ivy, which you're going
to
have to do if you're using Ivy in a real-world scenario, those extra
directories and trying to combine them just gets in the way.
Instead, for Ant I'd recommend ivy:cachepath and ivy:cachefileset.
Re: How to exclude sources when building using Ant
Posted by Mitch Gitman <mg...@gmail.com>.
I recall suggesting on this list the introduction of an exclude-type
attribute on post-resolve tasks (retrieve, cachepath, cachefileset). But
certainly, the type attribute, which implicitly does an include, works as
long as you know what types you want to include.
I do have to take issue one part of Steve's answer. While there's nothing
literally wrong with it, I find the ivy:retrieve task to be an ungainly
compromise geared toward users who don't quite embrace or trust Ivy. The
retrieve task is introducing an extra middleman into the process by copying
the files associated with a conf into a specified location when those files
are already in the Ivy cache. So you have an extra set of files to maintain
and invite synchronization/consistency problems with, which is only
mitigated somewhat by the use of the sync attribute. Worse, inevitably if
you're doing anything slightly complicated with Ivy, which you're going to
have to do if you're using Ivy in a real-world scenario, those extra
directories and trying to combine them just gets in the way.
Instead, for Ant I'd recommend ivy:cachepath and ivy:cachefileset.
On Mon, Oct 11, 2010 at 7:44 AM, Steve Miller <th...@gmail.com> wrote:
> <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" sync="true"
> type="jar" conf="*"/>
>
> Here's what I use. This task will pull all the artifacts for the most
> recently called resolve command.
>
> - This pattern says, put all my retrieved artifact files in the lib
> dir, under its conf folder. So libdir/compile/commons-lang.jar for
> example.
> - Using sync="true", it will delete old artifacts that were retrieved
> on a previous retrieve before pulling the current.
> - Using type="jar", I told it to only pull the jar files, not the
> sources or other types of artifacts.
> - Using conf="*" which says to retrieve the artifacts for all
> configurations. Using the pattern above, you would end up with several
> configuration folders under the lib dir. * is the default setting, so
> the conf attribute can be excluded.
>
> After the retrieve, you are left with a bunch a folders under lib,
> each which is a set of artifacts. So now in ant, it's easy to build a
> classpath from the folder structure.
>
> <classpath>
> <fileset dir="libdir">
> <include name="compile/*.jar"/> <!-- Where compile is the
> configuration with the jars needed to compile -->
> </fileset>
> </classpath>
>
>
RE: How to exclude sources when building using Ant
Posted by David Sills <DS...@datasourceinc.com>.
Steve:
Even looking at the docs under artifact (I have no idea how I'd have
gotten there from the "type" attribute in the Ant task) I can only infer
that there are two defined types. Nowhere is it spelled out that there
are only the two types, or what either actually means in practice.
I have no difficulty with "spelled out" - I prefer it, in general. But
then Ivy adds magic into the mix (e.g., one set of JAR files with a
particular naming convention [the source JAR files] gets silently
removed when the type="jar" - what if I wanted all source JAR files, but
no source *.java files?) and it becomes frustrating.
David Sills
Re: How to exclude sources when building using Ant
Posted by Steve Miller <th...@gmail.com>.
Yes, the artifact docs have more specifics.
http://ant.apache.org/ivy/history/2.0.0-alpha2/ivyfile/artifact.html
To be clear, each module defines its artifacts. Part of each artifact
definition is its type. The only predefined types I know of are jar
and ivy. Any others will be defined in the ivy files for the modules
you are depending on. I know source is a common one.
<artifact name="foo-src" type="source" ext="zip" conf="src" />
As the docs say, if you don't define the 'ext' param, it takes the
type. So in this example, it will look for an artifact named
foo-src.source. But here they defined it as zip, so it looks for
foo-src.zip. I guess the items you mentioned defined it as jar for
the source artifact.
Unfortunately DM is not as simple at it would seem. But once you get
it, you understand why it needs the complexity. (spelled out ->
flexibility)
On Mon, Oct 11, 2010 at 10:53 AM, David Sills <DS...@datasourceinc.com> wrote:
> Steve:
>
> Thanks, that was exactly what I needed.
>
> This is precisely the sort of difficulty I've been having. The
> definition of the "type" attribute of the retrieve Ant task in the
> documentation is "comma separated list of accepted artifact types".
> Fine, but how do I know what the list of accepted types is, or what any
> of the values listed means? (The source files are JAR files, as well,
> but are somehow magically excluded when "jar" is the type.)
>
> Of course, I could be being really dense and missing something, but this
> is the sort of thing I plan to go through and work on when time permits.
>
> David Sills
>
>
RE: How to exclude sources when building using Ant
Posted by David Sills <DS...@datasourceinc.com>.
Steve:
Thanks, that was exactly what I needed.
This is precisely the sort of difficulty I've been having. The
definition of the "type" attribute of the retrieve Ant task in the
documentation is "comma separated list of accepted artifact types".
Fine, but how do I know what the list of accepted types is, or what any
of the values listed means? (The source files are JAR files, as well,
but are somehow magically excluded when "jar" is the type.)
Of course, I could be being really dense and missing something, but this
is the sort of thing I plan to go through and work on when time permits.
David Sills
Re: How to exclude sources when building using Ant
Posted by Steve Miller <th...@gmail.com>.
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" sync="true"
type="jar" conf="*"/>
Here's what I use. This task will pull all the artifacts for the most
recently called resolve command.
- This pattern says, put all my retrieved artifact files in the lib
dir, under its conf folder. So libdir/compile/commons-lang.jar for
example.
- Using sync="true", it will delete old artifacts that were retrieved
on a previous retrieve before pulling the current.
- Using type="jar", I told it to only pull the jar files, not the
sources or other types of artifacts.
- Using conf="*" which says to retrieve the artifacts for all
configurations. Using the pattern above, you would end up with several
configuration folders under the lib dir. * is the default setting, so
the conf attribute can be excluded.
After the retrieve, you are left with a bunch a folders under lib,
each which is a set of artifacts. So now in ant, it's easy to build a
classpath from the folder structure.
<classpath>
<fileset dir="libdir">
<include name="compile/*.jar"/> <!-- Where compile is the
configuration with the jars needed to compile -->
</fileset>
</classpath>
On Mon, Oct 11, 2010 at 8:38 AM, David Sills <DS...@datasourceinc.com> wrote:
> All:
>
> I have finally managed to successfully integrate at least a beginner's
> setup for Ivy into my project, after a bit of head-banging. However,
> another problem has arisen.
>
> What really helped me was that since I was using Spring, I was able to
> build the Spring codebase, which enabled me to see a real project with
> Ivy in action. That seemed to help a lot (also, a bunch of additional
> JAR files were downloaded in the process, which went immediately into my
> cache).
>
> Now I am getting the imports I need (and some I don't actually need)
> using ivy:retrieve in Ant. No objection to having the license files, but
> I really don't need the *-source-*.jar files (which are, however, in the
> cache, and it's not such a bad thing, having them).
>
> I'm not quite understanding how not to retrieve these files during my
> build. Any suggestions would be welcome.
>
> David Sills
>
>
How to exclude sources when building using Ant
Posted by David Sills <DS...@datasourceinc.com>.
All:
I have finally managed to successfully integrate at least a beginner's
setup for Ivy into my project, after a bit of head-banging. However,
another problem has arisen.
What really helped me was that since I was using Spring, I was able to
build the Spring codebase, which enabled me to see a real project with
Ivy in action. That seemed to help a lot (also, a bunch of additional
JAR files were downloaded in the process, which went immediately into my
cache).
Now I am getting the imports I need (and some I don't actually need)
using ivy:retrieve in Ant. No objection to having the license files, but
I really don't need the *-source-*.jar files (which are, however, in the
cache, and it's not such a bad thing, having them).
I'm not quite understanding how not to retrieve these files during my
build. Any suggestions would be welcome.
David Sills
Re: [Ivy IDE] source file resolution fails
Posted by David Harrigan <dh...@gmail.com>.
Hi Sefan
What does your ivy.xml look like?
-=david=-
On 11 October 2010 10:54, Stefan Podkowinski <sp...@gmail.com> wrote:
> Can someone please advise what to do to make the source resolution
> feature work in Ivy IDE? For each artrifact ivy will download the
> appropriate sources to the local cache e.g.:
>
> $HOME/.ivy2/cache/org.springframework/org.springframework.core/jars/org.springframework.core-3.0.4.RELEASE.jar
> $HOME/.ivy2/cache/org.springframework/org.springframework.core/srcs/org.springframework.core-sources-3.0.4.RELEASE.jar
>
> However, when I'm trying to open a class from the ivy classpath in
> Eclipse, the source file cannot be resolved:
> "Source not found"
> "The JAR of this class belongs to container 'ivy.xml [*]' which does
> not allow modifications to source attachments on its entries"
>
> I noticed that there are some related options under Ivy > Classpath:
> Sources types: source
> Sources suffixes: -source,-sources,-src
>
> Using Ivy 2.2.0 (20100923230623) and IvyDE 2.1.0.201008101807.
>
> This is really driving me nuts as I have no clues where ivyde is
> actually looking for the sources. Any ideas?
>
--
I prefer encrypted and signed messages. KeyID: B20A22F9
Fingerprint: 110A F423 3647 54E2 880F ADAD 1C52 85BF B20A 22F9
"It is not usually until you've built and used a version of the
program that you understand the issues well enough to get the design
right." - Rob Pike, Brian Kernighan.