You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Mike Müller <mi...@mysign.ch> on 2009/04/20 09:45:51 UTC

What are the best practices developing bundles for Sling in Eclipse?

Hi

I tried different ways to develop OSGi bundles for Sling in Eclipse,
but neither was very productive.
I tried the Eclipse PDE-stuff, but run into several problems: Eclipse does not
recognise the Sling bundles even if they are in the same workspace.
I had to install the bundle jars into the OSGi target platform (which
is per default the Eclipse installation itself). After that I could find
the Sling packages in the Imported Packages dialog (manifest.mf editor, tab
Dependencies). But got a build cycle error which seems to be an Eclipse
bug... and in this scenario I would have to install the Sling bundles (or
even my own bundles) after each update of the bundle again in the target
platform (if some of the interfaces have changed).

So what are the best pracices to develop an OSGi bundle for Sling in Eclipse?
How are you guys developing/testing bigger projects for Sling?
(including packaging the jar with the correct manifest).

best regards
mike

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Mike,

On Mon, Apr 20, 2009 at 9:31 PM, Mike Müller <mi...@mysign.ch> wrote:
> ...I tried your setup and it doesn't feel (as it seems on a first view) that
> unproductive....

Sure, it kind of works ;-)

> ...You haven't to turn off the Java Builder needfully. Let it turned
> on, you get all the compiling warnings and errors as usual....

I *think* I started turning that off because I was losing track of
what was compiling what in my target folder. But I might try turning
on again, you're right.

-Bertrand

AW: What are the best practices developing bundles for Sling in Eclipse?

Posted by Mike Müller <mi...@mysign.ch>.
Hi Bertrand

> I learned programming back when waiting for a compilation meant going
> out for a coffee (or lunch if you still had floppy disks ;-), and
> still appreciate some effort before compiling, to try and be a bit
> careful...YMMV of course.

I come from this ancient long past time as well :-))
And yes, I certainly agree, it's worth to have a deep look at the
code before compiling - even if compiling is much more faster today.

> If I find an easy way to have hyperlinks from compilation errors, I
> will probably activate it, but right now I prefer not having to worry
> too much about my IDE. You could say that I use Eclipse as an editor /
> code browser / pre-compilation analyzer / coding assistance tool /
> debugger, that's a lot already, it just not include the build cycle.

I tried your setup and it doesn't feel (as it seems on a first view) that
unproductive. You haven't to turn off the Java Builder needfully. Let it turned
on, you get all the compiling warnings and errors as usual.

best regards
mike

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Mike,

On Mon, Apr 20, 2009 at 1:38 PM, Mike Müller <mi...@mysign.ch> wrote:
> ...If I get you right, that means, that you do not compile in Eclipse.
> So you do not get errros and warnings in Eclipse. Does that mean
> you use Eclipse only as editor, or do I get things wrong?...

Correct, I compile with maven at the command-line, so I do not get
hyperlinks from compiling errors to the corresponding java code.

But you still get all the pre-compilation warnings in Eclipse,
combined with coding assistance (method parameters etc), so I don't
get that many compiling errors. And requiring a round-trip of a few
seconds to compile and get the results means that I'm a bit more
careful when writing code, which (for me) tends to lead to better
code.

I learned programming back when waiting for a compilation meant going
out for a coffee (or lunch if you still had floppy disks ;-), and
still appreciate some effort before compiling, to try and be a bit
careful...YMMV of course.

If I find an easy way to have hyperlinks from compilation errors, I
will probably activate it, but right now I prefer not having to worry
too much about my IDE. You could say that I use Eclipse as an editor /
code browser / pre-compilation analyzer / coding assistance tool /
debugger, that's a lot already, it just not include the build cycle.

> ...I do hesitate to use maven as central build tool, but would like
> to see errors and warnings in Eclipse, and Eclipse should also
> know the definitions for easy jumping in the code....

Definitions are no problem, but you sometimes need to refresh the
Eclipse view of them, if you changed things in another bundle. Errors
and warning, as I said, don't work in Eclipse with my current setup.

On the other hand, having fully reproducible builds, saved in
subversion (as poms) and 100% independent of the programmer's IDE
settings, is a requirement for me, much more important than a more
integrated build cycle.

> ...Have you Bertrand - or someone else - tried another setup where
> at least compiling to classes is done in Eclipse?...

I'm sure someone has tried...it'll be interesting to find out if they
have succeeded ;-)

-Bertrand

Re: AW: What are the best practices developing bundles for Sling in Eclipse?

Posted by Michael Dürig <mi...@day.com>.
Mike,

I use basically the same setup like Bertrand. However, I don't disable 
the Java builder. This way I can directly jump to errors and warnings by 
point and click. The only problem I noticed with this setup recently is 
that the OSGi foundation bundle sometimes gets into the way. I fixed 
this by putting it to the very end of the Eclipse build class path.

Michael


Mike Müller wrote:
> Hi Bertrand
> 
> If I get you right, that means, that you do not compile in Eclipse.
> So you do not get errros and warnings in Eclipse. Does that mean
> you use Eclipse only as editor, or do I get things wrong?
> (I must admit, that I do not have deep knowledge of maven...)
> I do hesitate to use maven as central build tool, but would like
> to see errors and warnings in Eclipse, and Eclipse should also
> know the definitions for easy jumping in the code.
> Have you Bertrand - or someone else - tried another setup where
> at least compiling to classes is done in Eclipse?
> 
> best regards
> mike
> 
> 
>>> ...So what are the best pracices to develop an OSGi bundle
>> for Sling in Eclipse?
>>> How are you guys developing/testing bigger projects for Sling?
>>> (including packaging the jar with the correct manifest)....
>> The way I do it might not be a best practice but that works for me:
>>
>> -Start by copying and adapting an existing Sling pom that
>> looks like what I need
>> -Generate the Eclipse project files using mvn eclipse:eclipse
>> -Disable the Java builder in the Eclipse projects
>> -Build and test from the command-line, using the Eclipse
>> remote debugger
>> -If adding dependencies to my poms, run mvn eclipse:eclipse again and
>> refresh the project in Eclipse
>> -Use the subclipse svn client for most things, back to the command
>> line for the really important stuff
>>
>> I know some people want things more integrated with their IDE, but as
>> I said the above works fine for me, and I'm almost never fighting with
>> the IDE.


AW: What are the best practices developing bundles for Sling in Eclipse?

Posted by Mike Müller <mi...@mysign.ch>.
Hi Bertrand

If I get you right, that means, that you do not compile in Eclipse.
So you do not get errros and warnings in Eclipse. Does that mean
you use Eclipse only as editor, or do I get things wrong?
(I must admit, that I do not have deep knowledge of maven...)
I do hesitate to use maven as central build tool, but would like
to see errors and warnings in Eclipse, and Eclipse should also
know the definitions for easy jumping in the code.
Have you Bertrand - or someone else - tried another setup where
at least compiling to classes is done in Eclipse?

best regards
mike


> > ...So what are the best pracices to develop an OSGi bundle
> for Sling in Eclipse?
> > How are you guys developing/testing bigger projects for Sling?
> > (including packaging the jar with the correct manifest)....
>
> The way I do it might not be a best practice but that works for me:
>
> -Start by copying and adapting an existing Sling pom that
> looks like what I need
> -Generate the Eclipse project files using mvn eclipse:eclipse
> -Disable the Java builder in the Eclipse projects
> -Build and test from the command-line, using the Eclipse
> remote debugger
> -If adding dependencies to my poms, run mvn eclipse:eclipse again and
> refresh the project in Eclipse
> -Use the subclipse svn client for most things, back to the command
> line for the really important stuff
>
> I know some people want things more integrated with their IDE, but as
> I said the above works fine for me, and I'm almost never fighting with
> the IDE.

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Mike,

On Mon, Apr 20, 2009 at 9:45 AM, Mike Müller <mi...@mysign.ch> wrote:
> ...So what are the best pracices to develop an OSGi bundle for Sling in Eclipse?
> How are you guys developing/testing bigger projects for Sling?
> (including packaging the jar with the correct manifest)....

The way I do it might not be a best practice but that works for me:

-Start by copying and adapting an existing Sling pom that looks like what I need
-Generate the Eclipse project files using mvn eclipse:eclipse
-Disable the Java builder in the Eclipse projects
-Build and test from the command-line, using the Eclipse remote debugger
-If adding dependencies to my poms, run mvn eclipse:eclipse again and
refresh the project in Eclipse
-Use the subclipse svn client for most things, back to the command
line for the really important stuff

I know some people want things more integrated with their IDE, but as
I said the above works fine for me, and I'm almost never fighting with
the IDE.

-Bertrand

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Dominik,

2009/4/20 Dominik Süß <do...@gmail.com>:
> ...The espblogsample may be a
> good start for your pom ( but doesn't use the maven-sling-plugin yet)...

It does use it in fact, because the espblog's parent pom is the one
found in parent/pom.xml, so for example

 mvn -P autoInstallBundle clean install
-Dsling.url=http://localhost:8888/system/console

works.

But that's not automatic, we felt it more convenient to trigger the
install with a profile, to avoid installing new bundles in Sling
without being aware of it.

-Bertrand

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Dominik Süß <do...@gmail.com>.
Hi Mike,

I currently try several ways of a simple projectsetup myself and for me the
way Bertrand sets up his projects works pretty good for me.
I additionally use maven-sling-plugin [1] to enrich the install-phase by
direct deployment into a running sling instance. The espblogsample may be a
good start for your pom ( but doesn't use the maven-sling-plugin yet)

To have all running in eclipse you can run sling as external tool (using mvn
jetty:run) in eclipse (Run -> External Tools) with your params for remote
debugging and if you don't want to use a plugin as m2 plugin you can define
the goals you need in eclipse as external tools configurations the same way.


Btw. ${project_loc} is the required variable for the Working Directory in
the external tools configuration for the mvn install goal.

Best regards,
Dominik

[1] http://incubator.apache.org/sling/site/sling.html

On Mon, Apr 20, 2009 at 10:08 AM, Bertrand Delacretaz <
bdelacretaz@apache.org> wrote:

> On Mon, Apr 20, 2009 at 9:45 AM, Mike Müller <mi...@mysign.ch> wrote:
> > ...How are you guys developing/testing bigger projects for Sling?
> > (including packaging the jar with the correct manifest)....
>
> forgot about that one  - I just use mvn install, and the
> mvn-bundle-plugin does the rest.
>
> -Bertrand
>

Re: What are the best practices developing bundles for Sling in Eclipse?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Apr 20, 2009 at 9:45 AM, Mike Müller <mi...@mysign.ch> wrote:
> ...How are you guys developing/testing bigger projects for Sling?
> (including packaging the jar with the correct manifest)....

forgot about that one  - I just use mvn install, and the
mvn-bundle-plugin does the rest.

-Bertrand