I'm building a GWT application with Maven for dependency resolution and I've got a strange problem with Eclipse when trying to run JUnit tests. I have a standard maven-like structure of sources and tests:
/src/main/java
/src/test/java
If I set the the Java Build Bath > Default output folder of all source folders to:
/MyProject/target/classes
then there are no problems. However, the GWT plugin needs the sources to reside in:
/MyProject/src/main/webapp/WEB-INF/classes
in order to be able to deploy from this directory in development mode, otherwise it complains. However, if I set the output directory of all source folders to this directory, the tests are failing with ClassNotFoundException.
This can be worked-around if I manually add the directory /MyProject/src/main/webapp/WEB-INF/classes to the JUnit launcher's classpath, so, obviously, the compiled .class files are missing and hence the exception I get. But why doesn't eclipse add the directory to the classpath automatically if I define it to be the default output directory?
I suspect the m2eclipse plugin to be overriding the Default output folder setting, can it be? Because if I set the output folder for /src/main/java to /target/classes and src/test/java to /target/test-classes, everything works. But if any output directory is set outside of these two, it doesn't work.
I would appreciate any ideas, thank you!
m2eclipse has a storied history of ignoring the project classpath settings when running unit tests. It used to be (0.12 version of m2eclipse and earlier, I think), that if you just gave up fighting and set your project default classpaths to but target/classes (for source code), and target/test-classes (for unit test code), everything would be happy. With 0.13 m2eclipse, this no longer works, as the maven builder appears to put things in target/your-artificat-version-SNAPSHOT/web-inf/classes. Basically, the folder for the artifact that maven builds. This really sucks, since that path includes a version number.
m2eclipse has about exhausted my patience ;-).
A tip: To find out what is going on with your unit test class paths, you can always DEBUG as unit test, then right click on the thread in the debug perspective and pull up "properties". This will show you the complete classpath used for the unit tests, and you can see what the sneaky annoying plugins are doing to your classpath.
Related
I have an Eclipse project that uses Maven. The regular source files (ie, in src/main) build fine in both Eclipse and Maven. However, the test files (ie, in src/test) will only build in Maven. I cannot find any way to get them to build in Eclipse.
That is, the tests in Eclipse are run as the last version which Maven compiled. Before I used Maven, tests would be compiled automatically when they were run in Eclipse. "Build automatically" in the project menu is still enabled.
This only affects the tests (which are JUnit 4 tests). As mentioned, the regular source files are being built automatically correctly.
Here's the POM file, with irrelevant data pruned: https://gist.github.com/anonymous/10001049
Add the src/test directory to your build path. Windows / Preferences / Java / Build Path, or something like that.
Updating the project might also work, since m2e can get out of sync with your pom file quite often.
I want to run the puregwt-showcase project from geomajas in debug mode. I have checked the debug configuration and my maven dependencies are included. (should there by any particular order here?).In my maven dependencies i have this jar boss-marshalling-river-1.3.6.GA.jar included. So naturally if it is in my maven deps and my maven deps are on the debug confing claspath it should be detected right?...this is the stacktrace returned http://pastebin.com/xdkwLGkX . I have also asked on majas dev mailing list but nobody answered plus this seems more like a gwt and spring issue so i'm trying my luck here
Hoping to get so answers, or at least some leads,
Otis
EDIT: Another issue i have is that after i run gwt devmode another error pops up in my source: Template file CaptionImpl.ui.xml is missing (expected at org/geomajas/puregwt/example/client/widget/ShowcaseDialogBox) . This only appears if i run the gwt in devmode. If i try a maven install and run there are no problems.
You server-side classes and dependencies have to be in your war folder's WEB-INF to be picked up.
As you're using Maven, you first have to mvn package your app to move all dependencies to target, and then run DevMode with the proper war directory; see https://developers.google.com/eclipse/docs/faq#gwt_with_maven
We have a multiple modules in our Java project and each module publishes SNAPSHOT jar files to Nexus repository. All the sub-modules are directly dependent on the SNAPSHOT jar files.
During development, we want to depend on the Eclipse project rather than SNAPSHOT jars. So we introduced a flag which switches between the dependencies as shown below.
if(System.properties.'setupProject'){
compile project(':Core')
compile project(':Module1')
compile project(':Module2')
}else{
compile 'com.test:core:0.1-SNAPSHOT'
compile 'com.test:module1:0.1-SNAPSHOT'
compile 'com.test:module2:0.1-SNAPSHOT'
}
Executing the following command generates the .classpath file as expected.
gradle eclipse -DsetupProject=true
Is there a better way to do this? Can we use Gradle configurations to achieve the same?
I could not find good examples for the same.
At the moment this is the way to go. You might tweak this even more and instead of using a System property to mark a project as available you can check if the project folder is available (project is checked out)
cheers,
René
I have a list of Eclipse projects that I would like to compile based on the existing project configuration.
As far as I can tell, if an ant script could read the .classpath files, it would pretty much be able to infer the project dependencies and perform a "javac" compilation in the right order. This would save time in describing the same dependencies again in the ant script or a Makefile.
The dependencies I am interested in are JAR Dependencies, JRE dependencies, and inter-project dependencies. These are -- as far as I can tell -- part of the .classpath XML file.
Any ideas on how Eclipse project dependencies could used in an ant script?
Right click on your Project -> Export
"General/Ant Buildfiles".
Choose the projects and there you go.
Otherwise...
I have some experience with ant4eclipse and it is a hassle to get it stable.
Go check Buckminster or Maven Tycho for a good solution.
I'm currently using Ivy along with Ant, Eclipse and Maven.
I just love the way Ivy works.
Currently, we have a workspace with many projects using Liferay (with Tomcat) for the front-end and Glassfish for the back-end.
We were looking for a way to manage our dependencies a lot better than how we were doing it.
So I took Ivy, replaced all of the classpaths and deployment dependencies in eclipse and was able to build my application using 1 ivy file per project using either Eclipse or Ant.
Ivy integrates like a charm in ant and builds are done either from the workspace or by command line.
I strongly suggest you look at this avenue. Additionnaly, by adding Artifactory, we have a local repository in which the ivy files look for dependencies. This helps us maintain and rule which jars are to be used by developpers. Once everything is setup, we will build our application nightly using Jenkins and these builds will be using our Artifactory repository to resolve dependencies since our build servers do not have access to the internet.
Hope this helped
If you are running the Ant script only from eclipse using the "External Tools Configurations", you can add the variable ${project_classpath} to the Classpath.
Depending on if you are in a plugin project and dependencies you might need to add the
${eclipse_home}.
In case you get an error launching Variable references empty selection: ${project_classpath}, make sure the ant xml file or at least the project is selected. This is important.
I believe the ant4eclipse project provides support for executing Ant builds based on Eclipse metadata files.
However, in my opinion that is doing things back to front. You shouldn't have your build (Ant) depending on your IDE (Eclipse) environment. But it is useful if you can derive your Eclipse environment from your Ant build.
This is an approach used successfully in a team I worked in. We had a helper Ant target which applied XLST to project build.xml files to transform these into Eclipse .classpath files. Thus the Ant build.xml files were the single configuration point for our projects.
I'm using M2E for maven integration with eclipse. My unit tests reference property files in the resources/ directory. Well, everything fine in the command line test (mvn test). However, in Eclipse, the resources couldn't be found.
Check the Java Build Path, there, all resources entries are marked with Excluded: **. (I deem it should only exclude .java/.class files) Then, after removed the exclude pattern, the problem fixed.
I'm not sure whether I should remove all Excluded ** by hand, or maybe I doesn't use M2E correctly.
P.S. The projects are imported by Existing Maven Projects.
It does this on purpose, to allow the maven-resource-plugin to do the resource copying. You might have filters enabled after all. I have pestered the m2e list about this, you are welcome to file a bugzilla and join in the pestering. it is really annoying.