List Info

Thread: jar files




jar files
user name
2006-09-21 21:05:47
Has anyone used boost-build to create jar files?  One of my
co-workers 
is compiling .java files into .class files and then making a
.jar file 
out of the .class files.  The problem is the paths in the
class files.  
He basically needs to strip off everything but the original
relative 
path.  E.g., for apago/foo.java, he gets 
....../link-static/threading-multi/apago/foo.class and he
needs to pass 
just apago/foo.class to the jar creation program.

I was looking through the BB code to see if I could find
something 
similar, but I didn't find anything (which, of course,
doesn't mean it's 
not there).

Thanks,

Phillip
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
jar files
user name
2006-09-22 05:50:49
On Friday 22 September 2006 01:05, Phillip Seaver wrote:
> Has anyone used boost-build to create jar files?  One
of my co-workers
> is compiling .java files into .class files and then
making a .jar file
> out of the .class files.  The problem is the paths in
the class files.
> He basically needs to strip off everything but the
original relative
> path.  E.g., for apago/foo.java, he gets
> ....../link-static/threading-multi/apago/foo.class and
he needs to pass
> just apago/foo.class to the jar creation program.

Isn't this the matter for passing right -C options to jar?
Of course, 
computing the right options might not be straight-forward.
Or maybe not -- 
would
 
    jar
   -C ..../link-static/threading-multi  
   <all .class file>

work?

- Volodya

-- 
Vladimir Prus
http://vladimir_pru
s.blogspot.com
Boost.Build V2: http://boost.org/boost-
build2
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
jar files
user name
2006-09-25 16:45:04
Vladimir Prus wrote, on 9/22/2006 1:50 AM:
> On Friday 22 September 2006 01:05, Phillip Seaver
wrote:
>   
>> Has anyone used boost-build to create jar files? 
One of my co-workers
>> is compiling .java files into .class files and then
making a .jar file
>> out of the .class files.  The problem is the paths
in the class files.
>> He basically needs to strip off everything but the
original relative
>> path.  E.g., for apago/foo.java, he gets
>> ....../link-static/threading-multi/apago/foo.class
and he needs to pass
>> just apago/foo.class to the jar creation program.
>>     
>
> Isn't this the matter for passing right -C options to
jar? Of course, 
> computing the right options might not be
straight-forward. Or maybe not -- 
> would
>  
>     jar
>    -C ..../link-static/threading-multi  
>    <all .class file>
>
> work?
>
> - Volodya

Not quite.  javac creates filenames relative to the source
directory, so 
for ./apago/foo.java, "javac -d "
creates 
/apago/foo.class.  So, I think I need my own
javac generator 
that "knows" where the output files end up.  As
I understand it, I'll 
need to override the "run" method to accomplish
this.  I'll then need to 
make the .class filenames I pass to the jar command relative
to the .jar 
file.

Here's what I have in my class's run method:

        rule run ( project name ? : property-set : sources *
)
        {
                local s = $(sources[1]) ;
                local a = [ new action $(s) : java.javac : 
$(property-set) ] ;
                name ?= [ $(s).name ] ;
                local sp = [ $(s).project ] ;
                local source-root = [ $(sp).get
source-location ] ;
                source-root = [ path.root $(source-root) [
path.pwd ] ] ;
                local d = $(s).path ;
                d = [ path.root $(name) $(d) ]
;
                d = [ path.root $(d) [ path.pwd ] ] ;
                local relative = [ path.relative-to
$(source-root) $(d) ] ;
                local targets = [ new file-target $(name=$(relat
ive)) 
: CLASS : $(project) : $(a) ] ;
                return $(targets) ;
        }


Am I on the right track?  Or do I need to go somewhere else
and start 
again?  

Thanks,

Phillip
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
jar files
user name
2006-09-25 17:56:04
On Monday 25 September 2006 20:45, Phillip Seaver wrote:
> Vladimir Prus wrote, on 9/22/2006 1:50 AM:
> > On Friday 22 September 2006 01:05, Phillip Seaver
wrote:
> >> Has anyone used boost-build to create jar
files?  One of my co-workers
> >> is compiling .java files into .class files and
then making a .jar file
> >> out of the .class files.  The problem is the
paths in the class files.
> >> He basically needs to strip off everything but
the original relative
> >> path.  E.g., for apago/foo.java, he gets
> >>
....../link-static/threading-multi/apago/foo.class and he
needs to pass
> >> just apago/foo.class to the jar creation
program.
> >
> > Isn't this the matter for passing right -C
options to jar? Of course,
> > computing the right options might not be
straight-forward. Or maybe not
> > -- would
> >
> >     jar
> >    -C ..../link-static/threading-multi
> >    <all .class file>
> >
> > work?
> >
> > - Volodya
>
> Not quite.  javac creates filenames relative to the
source directory, so
> for ./apago/foo.java, "javac -d
" creates
> /apago/foo.class.  

Ah, I read your original email as saying you've some
problem with jar, like 
having extra directories in path. 

> So, I think I need my own javac generator 
> that "knows" where the output files end up.
 

So, you want to give javac a directory full of java files,
have it 
create .class files in builddir.

> As I understand it, I'll 
> need to override the "run" method to
accomplish this.  I'll then need to
> make the .class filenames I pass to the jar command
relative to the .jar
> file.
>
> Here's what I have in my class's run method:
>
>         rule run ( project name ? : property-set :
sources * )
>         {
>                 local s = $(sources[1]) ;
>                 local a = [ new action $(s) :
java.javac :
> $(property-set) ] ;
>                 name ?= [ $(s).name ] ;
>                 local sp = [ $(s).project ] ;
>                 local source-root = [ $(sp).get
source-location ] ;
>                 source-root = [ path.root
$(source-root) [ path.pwd ] ] ;
>                 local d = $(s).path ;
>                 d = [ path.root $(name) $(d) ]
;
>                 d = [ path.root $(d) [ path.pwd ] ] ;
>                 local relative = [ path.relative-to
$(source-root) $(d) ] ;
>                 local targets = [ new file-target
$(name=$(relat
ive))
>
> : CLASS : $(project) : $(a) ] ;
>
>                 return $(targets) ;
>         }
>
>
> Am I on the right track?  Or do I need to go somewhere
else and start
> again?  

I'm afraid so. A single .java file can result in multiple
.class files being 
produced. One language feature that I know does this is
'anonymous classes'. 
I think the if you have several classes in one .java file
you'll get 
several .class files too, but this case might be handled by
regexp, while 
detecting anonymous classes is harder.

SCons is supposed to have a parser that works,  which I
attach. It seems to be 
standlone, so you probably can call it when using
Python-enabled bjam.

Even then, I think the right interface would be to specify a
source directory, 
not a single .java file. I think that compiling a single
.java file might not 
work, since other classes the compiled file depends on might
not be compiled 
yet. I'm not sure about this though.

-  Volodya

-- 
Vladimir Prus
http://vladimir_pru
s.blogspot.com
Boost.Build V2: http://boost.org/boost-
build2
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
jar files
user name
2006-09-25 18:57:08
Vladimir Prus wrote, on 9/25/2006 1:56 PM:
> On Monday 25 September 2006 20:45, Phillip Seaver
wrote:
>   
>> Vladimir Prus wrote, on 9/22/2006 1:50 AM:
>>     
>>> On Friday 22 September 2006 01:05, Phillip
Seaver wrote:
>>>       
>>>> Has anyone used boost-build to create jar
files?  One of my co-workers
>>>> is compiling .java files into .class files
and then making a .jar file
>>>> out of the .class files.  The problem is
the paths in the class files.
>>>> He basically needs to strip off everything
but the original relative
>>>> path.  E.g., for apago/foo.java, he gets
>>>>
....../link-static/threading-multi/apago/foo.class and he
needs to pass
>>>> just apago/foo.class to the jar creation
program.
>>>>         
>>> Isn't this the matter for passing right -C
options to jar? Of course,
>>> computing the right options might not be
straight-forward. Or maybe not
>>> -- would
>>>
>>>     jar
>>>    -C ..../link-static/threading-multi
>>>    <all .class file>
>>>
>>> work?
>>>
>>> - Volodya
>>>       
>> Not quite.  javac creates filenames relative to the
source directory, so
>> for ./apago/foo.java, "javac -d
" creates
>> /apago/foo.class.  
>>     
>
> Ah, I read your original email as saying you've some
problem with jar, like 
> having extra directories in path. 
>   

With the way things are currently being done, the jar action
gets passed 
.class names without the directory structure that javac
creates, so 
that's a problem too.

>> So, I think I need my own javac generator 
>> that "knows" where the output files end
up.  
>>     
>
> So, you want to give javac a directory full of java
files, have it 
> create .class files in builddir.
>   

Actually, we pass javac a single .java at a time.

>> Am I on the right track?  Or do I need to go
somewhere else and start
>> again?  
>>     
>
> I'm afraid so. A single .java file can result in
multiple .class files being 
> produced. One language feature that I know does this is
'anonymous classes'. 
> I think the if you have several classes in one .java
file you'll get 
> several .class files too, but this case might be
handled by regexp, while 
> detecting anonymous classes is harder.
>   

True.  You can have multiple classes in a .java file,
including inner 
classes, each of which results in a .java file.  I didn't
know that 
before you brought it up.  (I'm not a java programmer  ).

> SCons is supposed to have a parser that works,  which I
attach. It seems to be 
> standlone, so you probably can call it when using
Python-enabled bjam.
>   

You seem to have forgotten to attach it.  :->  How do I
get a 
python-enabled bjam?

> Even then, I think the right interface would be to
specify a source directory, 
> not a single .java file. I think that compiling a
single .java file might not 
> work, since other classes the compiled file depends on
might not be compiled 
> yet. I'm not sure about this though.
>
> -  Volodya

I think it would need to do dependency scanning, too.  On
the other 
hand, if all I'm ever doing with the .class files is
putting them in a 
.jar file, the javac command could be part of the jar
actions...

Thanks,

Phillip
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )