synchronising / maintaining ant and eclipse classpaths - eclipse

I'd be interested to find out about any automated processes that people have for ensuring that the project classpaths for the ant and eclipse configurations are in synch. In my case, I want the classpath defined in the ant build file to be the master configuration, since its used for our production builds. As part of the build i'd like to add an ant target that will verify that the eclipse classpath is up to date, or at least indicate differences between the two classpaths.
I'm aware of ant4eclipse but its focus is in the opposite direction, ensuring that the eclipse classpath is master and that the ant build reuses the eclipse path. I like the idea behind AntAndEclipse but am wondering are their ant other tools in this space that i'm not aware of.

You solution at a previous company was to have ant invoke Eclipse to do the compiles as described here:
http://www.eclipse.org/articles/Article-PDE-Automation/automation.html

I'm not aware of any ant tools which can do this but I've switched from ant to Maven a few years ago and never looked back. You can use the "Maven integration for Eclipse" to make Eclipse use the Maven classpath.
As of today, I'm not 100% happy with the Eclipse plugin, though. It's a bit slow and due to the different philosophy of Eclipse and Maven, some operations behave strange. For example, Eclipse doesn't differentiate between a "production" and "test" classpath, so you can get compile errors in Maven when everything looks great in Eclipse.
My solution was to use the plugin to keep the classpath in sync and compile from the commandline.

there is an ant task to do xml transformations, we used that task to create the classpath in our build file. It was a little trick to get the XSL right but once it worked it was great

Did you evaluate Apache IVY? Currently I am building a Continuous Integration environment at our place and we use IVY to handle our dependencies. There is a eclipse plugin that takes the dependency configuration of eclipse and uses it as eclipse classpath.
Currently this solution looks quite promising.

My team wrote an Eclipse plug-in to add a new type of library to the Java Build Path->Add Library option in the project settings. This custom library type allowed both Eclipse and ANT to reference the same canonical list of dependencies.
Nowadays, I'd probably look at IVY for doing the same thing if I was locked into using ANT, rather than writing my own.

You need Ant2Eclipse.

Related

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

aaspectj - installation, ide and in between

I'm fairly new to aspectj. and actually need to use it because a feature in spring needs it in order to work.
One thing i don't get. i see that the installation of the aspectj is via eclipse.
so apparently post installation - all my src code and jars are still the same.
so what exactly am i installing? I mean, my project is comprised of jars + .class files so what difference does it make if i install a plugin in my IDE?
p.s I tried to install it but all the installation of aspectj are through maven and I Don't use maven.
there are kind of supporting tools for eclipse that ease aspectJ development (e.g. it shows you weaved pointcuts etc).
AspectJ itself has several options of how to "enrich" your code. You can use compile-time weaving, which modifies your class-files. or you use load-time weaving, in which case aspectj modifies the bytecode during startup of your application.
either way, after weaving, your code depends on the aspectJ-runtime library, so you need this in your classpath too.
If you use maven, you add aspectj-stuff to it, if you dont, you add it to eclipse itself (which is the plugin for, i guess). just install ADJT and you are up and running.

Scala, Maven, Sbt and Eclipse

I am wondering what is the most efficient way to use Sbt and Eclipse together? There seems to be a Sbt Eclipse plugin but what is the generally recommended workflow post generating the eclipse config? It seems kind of wrong to then add dependencies via the Eclipse Maven plugin in Eclipse? Is that what people usually do though?
Kind of new to the ecosystem so maybe I'm missing something here.
I add maven dependencies in via the sbt config files. Then regenerate the eclipse project after each modification, keeping the sbt config as the definitive project specification. I suspect it's the only sane way to run the setup.
I use the IvyDE plugin for eclipse with sbt deliver-local.
The advantage here is it can give you separate classpath containers for different configurations easily and you don't need to blat your eclipse project settings regularly.
It'd be really nice if scala-ide supported tighter integration with sbt.

In Eclipse for Java -JDT (DynWeb), Is Eclipse using default ant build.xml ? behind the scenes?

I believe when Eclipse installs, ant comes with it.
I should review the default build.xml
( I assume it uses one, whether or not it is obviously included in the project files )
I need to find out where it would store and use this from.
I have some projects / code artifacts that come with a build spec, and may need to use the one specified. Thanks in advance for your help, and suggestions.
Eclipse doesn't use ant to build your projects, if that's what you are asking. Eclipse builders (such as Java builder) are implemented natively as Eclipse plugins. Eclipse does support integration with Ant... Calling ant targets as part of the build... Calling ant targets as separate tools... Ant is meant to be used to augment IDE-provided facilities when you need something specialized.

JavaRebel with a Multi-module Enterprise Project in Maven

Does anybody have experience working with JavaRebel, specifically for a large web application built using Maven? There is a JavaRebel plugin for Maven that seems under-documented, does anybody have comments on how it works, can you really update one class in a Multi-module Enterprise Project and have it "automagically" change on your Server?
Are there any issues with different IDEs and this setup? For example NetBeans will not let you compile one class at a time in a Maven project (from what I can tell).
Disclaimer: I work for ZeroTurnaround.
JRebel (formerly JavaRebel) installation involves the application configuration file "rebel.xml" and modifying the container startup command line.
The Maven plugin is used to generate the "rebel.xml" file, that is used by the JRebel agent running in the container to find the files in the workspace. This allows to use IDE building to compile .java files and skip the Maven build process, as the changes to files will be picked up from the workspace. However as it relies on the IDE to compile the classes, it does depend on the IDE ability to compile efficiently. I know for sure that Eclipse will compile classes one at a time and am fairly sure you can configure NetBeans and IntelliJ IDEA to do the same.
In addition to the Maven/rebel.xml configuration you also need to configure the container startup command line. You may also need to install and IDE plugin or do some additional configuration to have the best expirience with JRebel. Following through the steps of Installation manual ensures that.
Hope this helps.
Disclaimer: I've not actually used this plugin myself.
This tutorial implies that JavaRebel works well with Eclipse 3.4. If you are also using m2eclipse it should work ok with Maven projects as well (as long as you ensure that Maven and Eclipse are compiling to the same target folder so the Eclipse incremental compiler can be used to modify the class file).
According to this post, you should configure the javarebel-maven-plugin to generate the rebel.xml (used to mount external folders to the application classpath). There's also a general installation guide you may find useful.