[ANT] Building of sources fails because of dependency chain resolution

76 views
Skip to first unread message

Christian Vogel

unread,
Aug 20, 2012, 10:35:22 AM8/20/12
to bndtool...@googlegroups.com
Hi,

I know that the title is not saying much, but I didnt know how I can exactly describe my problem as a title.

Following scenario:

* Bundle A has a class BaseException in package a.exceptions which will be exported
* Bundle B has a class InvalidException which extends the BaseException in package b.exceptions which will be exported (Bundle A is on -buildpath)
* Bundle C has a class ClassC with a method "public void doS() throws InvalidException {}" (Bundle B is on -buildpath)

In Eclipse all bundles are correctly build without problems. If I use the console and Ant with clean projects (no bin, bin_test, generated folder) and executes "ant build" I'm getting compiler error:

Buildfile: C:\Users\christian.vogel\indigo_workspace\build.xml

build:

init:
[bndprepare] home .bnd/settings.json C:\Users\christian.vogel
     [echo] Enter project A

dependencies:
   [subant] No sub-builds to iterate on

compile:
    [javac] Compiling 1 source file to C:\Users\christian.vogel\indigo_workspace\A\bin
    [javac] C:\Users\christian.vogel\indigo_workspace\A\src\a\exceptions\BaseException.java

build:

init:
[bndprepare] home .bnd/settings.json C:\Users\christian.vogel
     [echo] Enter project C

dependencies:

init:
[bndprepare] home .bnd/settings.json C:\Users\christian.vogel
     [echo] Enter project A

dependencies:

compile:

build:

init:
[bndprepare] home .bnd/settings.json C:\Users\christian.vogel
     [echo] Enter project B

dependencies:

compile:
    [javac] Compiling 1 source file to C:\Users\christian.vogel\indigo_workspace\B\bin
    [javac] C:\Users\christian.vogel\indigo_workspace\B\src\b\exceptions\InvalidException.java

build:

compile:
    [javac] Compiling 1 source file to C:\Users\christian.vogel\indigo_workspace\C\bin
    [javac] C:\Users\christian.vogel\indigo_workspace\C\src\c\ClassC.java
    [javac] C:\Users\christian.vogel\indigo_workspace\C\src\c\ClassC.java:6: cannot access a.exceptions.BaseException
    [javac] class file for a.exceptions.BaseException not found
    [javac]     public void doS() throws InvalidException {
    [javac]                 ^
    [javac] 1 error

If I add Bundle A on Bundle C -buildpath as well it works. But I do not want to add a dependency to Bundle A since Bundle C only uses classes from Bundle B. Is it a bug in Bndtools or Bnd? What can I do?

I think its very crucial and should be reviewed, because if its stay as it is, then I have to add dependencies which are only implicitly as well. :(

Regards.
Christian

Christian Vogel

unread,
Aug 20, 2012, 10:36:26 AM8/20/12
to bndtool...@googlegroups.com
Totally forgot to say, that I'm using current Jenkins build of Bndtools.

derheld42

unread,
Aug 25, 2012, 5:53:16 PM8/25/12
to bndtool...@googlegroups.com

I believe since you are inheriting from the base exception in package A, then package C can only use the exception from package B if it also uses package A.

i.e. perhaps you have other things in Package A that you don't want Package C to have access to. Perhaps the better solution is to pull the base exception out into another bundle?

Just some thoughts.

Carter
 
Reply all
Reply to author
Forward
0 new messages