Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Buckminster » Building war from ant
Building war from ant [message #381447] Wed, 10 December 2008 09:59 Go to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
Hello,

I'm trying to build a war archive from a ant action but I miss some jars.
Here is my CSpec action :
> <public name="deploy" actor="ant">
> <actorProperties>
> <property key="buildFile" value="make/build.xml"/>
> </actorProperties>
> <prerequisites alias="input">
> <attribute name="java.binaries"/>
> <attribute name="eclipse.build.requirements"/>
> </prerequisites>
> </public>

and my ant target
> <target name="deploy">
> <delete dir="deploy" />
> <mkdir dir="deploy" />
> <mkdir dir="deploy/lib" />
> <mkdir dir="deploy/classes" />
> <!-- copying .class files -->
> <buckminster.copy todir="deploy/classes" includeemptydirs="false">
> <buckminster.filesetgroup value="${fs:input}" />
> </buckminster.copy>
> <!-- cleaning some unused folders -->
> <delete dir="deploy/classes/libIn"/>
> <delete dir="deploy/classes/META-INF"/>
> <!-- copying the libs -->
> <buckminster.copy todir="deploy/lib" flatten="true" includeemptydirs="false">
> <buckminster.valuepath value="${fs:input}" />
> <fileset dir="libIn" includes="**/*.jar"/>
> </buckminster.copy>
> <!-- building the war -->
> <war destfile="deploy/mywar.war" webxml="WebContent/WEB-INF/web.xml">
> <classes dir="deploy/classes" />
> <lib dir="deploy/lib"/>
> </war>
> </target>

However, I miss a few jars in my lib folder : those that are on the component's build path. How can I get those entries ?
Note that the jar on the build path are exported but it doesn't change anything.

Best regards,
Guillaume
Re: Building war from ant [message #381625 is a reply to message #381447] Wed, 10 December 2008 22:45 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Guillaume,
It's hard to say without knowing a bit more. When you say that the jar's are on the build-path. What
build path are you referring to? What kind of project is it? Is it a plain java project or an OSGi
project? I'm guessing OSGi since you're using the "eclipse.build.requirements" which I recognize as
one of the attributes generated by the PDE integration. If that's the case, did you include the jars
in the bin.includes in your build.properties?

Many questions...

Regards,
Thomas Hallgren


Guillaume CHATELET wrote:
> Hello,
>
> I'm trying to build a war archive from a ant action but I miss some jars.
> Here is my CSpec action :
>> <public name="deploy" actor="ant">
>> <actorProperties>
>> <property key="buildFile" value="make/build.xml"/>
>> </actorProperties>
>> <prerequisites alias="input">
>> <attribute name="java.binaries"/>
>> <attribute name="eclipse.build.requirements"/>
>> </prerequisites>
>> </public>
>
> and my ant target
>> <target name="deploy">
>> <delete dir="deploy" />
>> <mkdir dir="deploy" />
>> <mkdir dir="deploy/lib" />
>> <mkdir dir="deploy/classes" />
>> <!-- copying .class files -->
>> <buckminster.copy todir="deploy/classes"
>> includeemptydirs="false">
>> <buckminster.filesetgroup value="${fs:input}" />
>> </buckminster.copy>
>> <!-- cleaning some unused folders -->
>> <delete dir="deploy/classes/libIn"/>
>> <delete dir="deploy/classes/META-INF"/>
>> <!-- copying the libs -->
>> <buckminster.copy todir="deploy/lib" flatten="true"
>> includeemptydirs="false">
>> <buckminster.valuepath value="${fs:input}" />
>> <fileset dir="libIn" includes="**/*.jar"/>
>> </buckminster.copy>
>> <!-- building the war -->
>> <war destfile="deploy/mywar.war"
>> webxml="WebContent/WEB-INF/web.xml">
>> <classes dir="deploy/classes" />
>> <lib dir="deploy/lib"/>
>> </war>
>> </target>
>
> However, I miss a few jars in my lib folder : those that are on the
> component's build path. How can I get those entries ?
> Note that the jar on the build path are exported but it doesn't change
> anything.
>
> Best regards,
> Guillaume
Re: Building war from ant [message #381627 is a reply to message #381625] Thu, 11 December 2008 09:42 Go to previous messageGo to next message
Guillaume Chatelet is currently offline Guillaume ChateletFriend
Messages: 146
Registered: July 2009
Senior Member
My projects were plugins that's why I used "eclipse.build.requirements" as you stated. What I assumed was I can manage my dependencies within eclipse with the Java build path of my projects.

The "Java build path" is used to compile the project so I need those libraries. Let's assume I have to project with dependencies :
ProjectA depends on ProjectB

ProjectB has libraries that are needed also by ProjectA. What I first did was to include those libraries into projectB's java build path and then export them with the "Order and export" tab of the project's properties. This way, in ProjectA if I ask for "java.binaries" and "eclipse.build.requirement" I gather the libraries for ProjectA and ProjectB.

At least that's what I thought because "java.binaries" on ProjectA did not contain the libraries of ProjectA...
It works on ProjectB because ProjectA depends on B and B's libraries are marked as exported. However ProjectA is my main project so marking my libraries as exported would work for projects depending on ProjectA but not for ProjectA itself.

Actually I spent quite a long time trying to figure out what was behind autogenerated targets ( "java.binaries", "java.binary.archives", "eclipse.build.requirements" ) what was from Buckminster, what was from Eclipse, how was those targets related (too bad there's no documentation). I even dug into the code to search for the available actions.

What I concluded is that I couldn't use Eclipse "java build path" to manage my libraries within ant. Moreover "java build path" is for build, that is : libraries needed to compile the code and I also needed runtime libraries to be deployed to my Tomcat server so this would have resolved just half of my problems.

The way I resolved the issue is to add my runtime and compile time libraries to buckminster's java.binaries in an <alterGroup> node :
> <alterGroups>
> <public name="java.binaries">
> <attribute name="java.binary.archives" component="org.restlet"/>
> <attribute name="java.binary.archives" component="com.noelios.restlet"/>
> <attribute name="java.binary.archives" component="com.noelios.restlet/com.noelios.restlet.ext.servlet "/>
> <attribute name="guice.jar" component="guice-1.0"/>
> <attribute name="java.binary.archives" component="junit"/>
> </public>
> </alterGroups>

And a deploy action that uses it :
> <public name="deploy" actor="ant">
> <actorProperties>
> <property key="buildFile" value="make/build.xml"/>
> </actorProperties>
> <prerequisites alias="input">
> <attribute name="java.binaries"/>
> <attribute name="eclipse.build.requirements"/>
> </prerequisites>
> </public>

the deploy action has "java.binaries" and "eclipse.build.requirements prerequisites" which allows me to gather the libraries of all my projects into an fs:input property.

What do you think about this solution ? Is it the right one ? Actually I did use plugins because I thought this way I could just use Eclipse to manage my dependencies and libraries and that Buckminster would have magically gathered them through some good chosen artifacts, but actually I haven't succeeded.

Any feedback welcome : )
Guillaume

Thomas Hallgren wrote:
> Hi Guillaume,
> It's hard to say without knowing a bit more. When you say that the jar's
> are on the build-path. What build path are you referring to? What kind
> of project is it? Is it a plain java project or an OSGi project? I'm
> guessing OSGi since you're using the "eclipse.build.requirements" which
> I recognize as one of the attributes generated by the PDE integration.
> If that's the case, did you include the jars in the bin.includes in your
> build.properties?
>
> Many questions...
>
> Regards,
> Thomas Hallgren
>
>
> Guillaume CHATELET wrote:
>> Hello,
>>
>> I'm trying to build a war archive from a ant action but I miss some jars.
>> Here is my CSpec action :
>>> <public name="deploy" actor="ant">
>>> <actorProperties>
>>> <property key="buildFile" value="make/build.xml"/>
>>> </actorProperties>
>>> <prerequisites alias="input">
>>> <attribute name="java.binaries"/>
>>> <attribute name="eclipse.build.requirements"/>
>>> </prerequisites>
>>> </public>
>>
>> and my ant target
>>> <target name="deploy">
>>> <delete dir="deploy" />
>>> <mkdir dir="deploy" />
>>> <mkdir dir="deploy/lib" />
>>> <mkdir dir="deploy/classes" />
>>> <!-- copying .class files -->
>>> <buckminster.copy todir="deploy/classes"
>>> includeemptydirs="false">
>>> <buckminster.filesetgroup value="${fs:input}" />
>>> </buckminster.copy>
>>> <!-- cleaning some unused folders -->
>>> <delete dir="deploy/classes/libIn"/>
>>> <delete dir="deploy/classes/META-INF"/>
>>> <!-- copying the libs -->
>>> <buckminster.copy todir="deploy/lib" flatten="true"
>>> includeemptydirs="false">
>>> <buckminster.valuepath value="${fs:input}" />
>>> <fileset dir="libIn" includes="**/*.jar"/>
>>> </buckminster.copy>
>>> <!-- building the war -->
>>> <war destfile="deploy/mywar.war"
>>> webxml="WebContent/WEB-INF/web.xml">
>>> <classes dir="deploy/classes" />
>>> <lib dir="deploy/lib"/>
>>> </war>
>>> </target>
>>
>> However, I miss a few jars in my lib folder : those that are on the
>> component's build path. How can I get those entries ?
>> Note that the jar on the build path are exported but it doesn't change
>> anything.
>>
>> Best regards,
>> Guillaume
Re: Building war from ant [message #381630 is a reply to message #381627] Fri, 12 December 2008 09:06 Go to previous message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Guillaume CHATELET wrote:
> ...
> What do you think about this solution ? Is it the right one ? Actually I
> did use plugins because I thought this way I could just use Eclipse to
> manage my dependencies and libraries and that Buckminster would have
> magically gathered them through some good chosen artifacts, but actually
> I haven't succeeded.
>
Using PDE to manage jar dependencies this way is, as you have noted,
complicated :-). PDE (and our integration to it) works under the
assumption that it creates a jar that bundles everything needed to make
that plug-in self sufficient with respect to what it exports. A plug-in
cannot have dependencies to jars that are not in themselves plug-ins
managed by the same OSGi runtime so there's no Buckminster generated
attribute that includes such jar files.

Since what you are creating are not plug-ins per se, you should perhaps
consider another approach and maintain a simplified buckminster.cspec
yourself where you define your own attributes and artifacts.

In the long run, we should add a component type that generates a cspec
based on the .project and .classpath (and optionally a build.properties)
files alone. I think that could be very useful for scenarios like this.
An extension to that in turn, would be to support various WAR and EAR
set-ups.

Regards,
Thomas Hallgren
Previous Topic:Pushing last Maven plugin
Next Topic:Adding extra dependency jars to update site
Goto Forum:
  


Current Time: Fri Apr 26 03:00:12 GMT 2024

Powered by FUDForum. Page generated in 0.03044 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top