Buckminster: running JUnit Plugin tests headless - eclipse

I have a simple Hudons/Buckminster setup where Hudson checks out four Java plugin projects from SVN, materializes(?) the org.eclipse.platform from the Helios download-site, runs a small ant-job in one of the projects for JFlex etc. (Buckminster doesn't "see" the configure external ANT builder?, and then Buckminster builds the workspace.
The Java plugin projects also contain feature.xml files with the same ID as the plugin (we've been using an ant-based build-process so far).
I can successfully perform ...#site.p2 on the first two, but the third one fails for some reason (but this is not the question here).
Now, one of the projects has JUnit tests that I can run from Eclipse Indigo using a headless JUnit Plugin Launch configuration. Note: for some reason, (because we have the features not in separate feature projects?), dependency generation checking on the launch config is broken, and I have manually configured the minimal set of plugins required.
Now, I run this launch configuration in Buckminster:
junit -l com.pon.ent/junit.launch
and get:
ERROR: Plugin validation errors were detected:
{com.pon.ent_0.0.0.qualifier=[Lorg.eclipse.osgi.service.resolver.ResolverError;#c986d2, org.eclipse.ui.views_3.5.1.M20110202-0800=[Ljava.lang.Object;#b27cca,
org.eclipse.ltk.core.refactoring_3.5.100.v20100526-0800=[Ljava.lang.Object;#1ec391,
org.eclipse.ui.navigator.resources_3.4.201.M20100707-0800=[Ljava.lang.Object;#1b9a026,
org.eclipse.debug.ui_3.6.1.v20100901_r361=[Ljava.lang.Object;#1c126da,
org.eclipse.ui.ide_3.6.1.M20100825-0800=[Ljava.lang.Object;#1dde560,
org.eclipse.team.ui_3.5.101.R36x_v20100825-0800=[Ljava.lang.Object;#fe10f1,
org.eclipse.ui.ide_3.6.2.M20101201-0800=[Ljava.lang.Object;#a68c8,
org.eclipse.jdt.ui_3.6.1.r361_v20100825-0800=[Ljava.lang.Object;#16535fa,
org.eclipse.debug.ui_3.6.3.v20101201_r362=[Ljava.lang.Object;#1baec4c,
org.eclipse.ui.navigator.resources_3.4.202.M20101124-0800=[Ljava.lang.Object;#ef965e,
org.eclipse.jdt.debug.ui_3.5.0.v20100602-0830=[Ljava.lang.Object;#17916a0,
org.eclipse.jdt.debug.ui_3.5.2.v20100928a_r362=[Ljava.lang.Object;#bc7bc0,
org.eclipse.equinox.p2.repository_2.0.2.R36x_v20110111-1500=[Lorg.eclipse.osgi.service.resolver.ResolverError;#607cad,
org.eclipse.compare_3.5.100.I20100526-0800=[Ljava.lang.Object;#997c85,
org.eclipse.ui.views_3.5.0.I20100527-0800=[Ljava.lang.Object;#be0e6e,
org.eclipse.ui_3.6.1.M20100826-1330=[Ljava.lang.Object;#1a5688d,
org.eclipse.team.ui_3.5.102.R36x_v20110203-1036=[Ljava.lang.Object;#73102f,
org.eclipse.jdt.ui_3.6.2.r362_v20110203=[Ljava.lang.Object;#2baa00,
org.eclipse.equinox.p2.metadata.repository_1.1.0.v20100513=[Lorg.eclipse.osgi.service.resolver.ResolverError;#a5f472, org.eclipse.ltk.core.refactoring_3.5.101.r362_v20101117-0800=[Ljava.lang.Object;#153a539,
org.eclipse.swt_3.6.1.v3655c=[Ljava.lang.Object;#8445f7,
org.eclipse.ui_3.6.2.M20110203-1100=[Ljava.lang.Object;#d8573,
org.eclipse.ui.workbench_3.6.1.M20100826-1330=[Ljava.lang.Object;#1b4776a,
org.eclipse.compare_3.5.101.R36x_v20100929-0800=[Ljava.lang.Object;#10bdf62,
org.eclipse.swt_3.6.2.v3659c=[Ljava.lang.Object;#76b51c,
org.eclipse.ui.workbench_3.6.2.M20110210-1200=[Ljava.lang.Object;#16c6a89}
WARN: Process /usr/jdk/instances/jdk1.6.0/bin/java (Oct 19, 2011 9:02:53 PM) terminated with exit status 1.
Given that things like org.eclipse.ui.views show up as matched, e.g.
org.eclipse.ui.views:osgi.bundle/[3.5.1.M20110202-0800,3.5.1.M20110202-0800]:
Found match org.eclipse.ui.views:osgi.bundle$3.5.1.M20110202-0800
I'm a bit at a loss what is actually missing/going wrong. I am not using any products are target platforms, other from what I get from the cquery which gets org.eclipse.platform, and the dependency resolution from my plugins.
Any interpretation is appreciated!
Update:
I've switched things a bit and now use Indigo, include org.eclipse.rcp in Buckminster's target platform, and switched the JUnit launch from plugins to features, and things have condensed down do:
Waiting for jobs to end
junit '-l' 'eu.hatsproject.absplugin/junit.launch' '-o' 'eu.hatsproject.absplugin/junit.xml' '--maxTimeAwaitJunitReport' '20'
WARN: Process /usr/jdk/instances/jdk1.6.0/bin/java (Oct 21, 2011 6:04:32 PM) terminated with exit status 1.
Doing full workspace refresh

Lessons learned:
don't mix-and-match: run Buckminster 3.7 imports with Indigo, not Helios update-site (inconclusive, maybe I did something else wrong as well)
put --stderr --stdout into the Buckminster junit invocation!
The problem was that the launch configuration contained platform-specific -X-switches, since I exported it from MacOS and was running it on Solaris. I have no idea where those messages end up when you don't use the above switches.

Related

Is it possible to skip maven-javadoc-plugin execution in an Eclipse run configuration?

I have a few Maven projects in Eclipse 2019-6 that each include the maven-javadoc-plugin (v2.8) in their pom (which I don't want to modify), but in some cases I'd like to skip building the javadoc.jar when I run maven package or install through Eclipse (because for a couple of these projects, the javadoc.jar takes a fair amount of time to build).
Is there an argument I can pass through the Eclipse m2 run configuration that will allow me to skip the javadoc.jar when I run a package or install locally?
I've searched fair amount for tutorials or documentation of m2 run configurations in Eclipse and haven't found anything much more than "here's how to set up a Maven run configuration" with no extra options or advanced configurations.
I really appreciate any help!
You can try adding maven.javadoc.skip=true in the build parameters table of your launch configuration (equivalent to -Dmaven.javadoc.skip=true in a CLI build)

Using Maven for JUnit testing

I started learning JUnit testing within Eclipse. The plugin that is used to show the test results presents a nice clean view of the test and you can click on items that take you to the areas in code that are under test.
When I started working with Maven, I noticed that you can have Maven carry out your JUnit tests as well. However, because Maven is a command line process and the results get written to the console, the JUnit results get sent there as well. And it looks like crap. You have to parse your way through all the console text to find the results of the test. Everything is just plain old text.
This raises the question as to what purpose Maven has in testing with JUnit (or any other test frameworks for that matter)? I must be missing the point. Why would anyone want to read a large text dump when the Eclipse plugin provides an elegant way of viewing, executing and evaluating tests?
Generally speaking, you build on the command line because you've got everything working correctly in your IDE. The command line build is the final sanity check and possibly the way in which you are releasing your software (e.g. mvn release:perform etc.).
While there are a few plugins that make Maven test output slightly nicer, the expectation is that the tests will pass. If they don't, fire up Eclipse and run the tests again.
Maven is a build tool. Its goal and purpose is to produce repeatable and protable result. This is especially important when we talk about build/continuous integration servers.
So the normal workflow is/should be: Developers usually develop using their IDE (eclipse), they run their tests in the IDE, because it is developer centric and more comfortable.
The build server, lacking a graphical environment runs the build tool, i.e. maven.
Sometimes, the results between maven and the eclipse might differ, in that case might become necessary for developers to also run maven on their machine.
Another reason to use maven directly might be integration test which specifically us maven lifecycle integrations for say starting and stopping a server.
Some specific points: Maven quite comfortably shows you which tests failed in a summary:
00:46:21.988 Results :
00:46:21.988
00:46:21.988 Failed tests:
00:46:21.988 MyTest.testPersistErrorStateNewTransaction:48 Test for 'testPersistErrorStateNewTransaction()' not yet implemented!
00:46:21.988
00:46:21.988 Tests in error:
00:46:21.988 MyOtherTest.testMethod
00:46:21.989
00:46:21.989 Tests run: 1162, Failures: 1, Errors: 1, Skipped: 491
00:46:21.989
00:46:22.003 [ERROR] There are test failures.
00:46:22.004
Also, when run, from maven, you can still open the results of the surefire tests in your eclipse junit view by double-clicking on a test result (.xml) in the surefire-reports directory.
what purpose Maven has in testing with JUnit?
Unit testing is one of the part in Application Development(usually do while coding/developing components), Apache Maven is the project management tool, (as Duncan told) it helps us to releasing software.
includes - Dependency Management, Module Management, Plugin Management, and reporting configuration for tests.
Maven Objectives:
Making the build process easy
Providing a uniform build system
Providing quality project information
Providing guidelines for best practices development
Allowing transparent migration to new features
please look at below threads for more details about Maven:
Why do so few people use Maven?
Why maven ? What are the benefits?
Why would anyone want to read a large text dump when the Eclipse plugin provides an elegant way of viewing, executing and evaluating tests?
For software release purpose we need maintain statistics of the application(how many scenarios covered, test cases passed..etc). Maven supports different plugins to format the results, Maven Surefire Plugin, maven-site-plugin..etc plugins help us to generate reports different formats.
please refer below threads for more details:
JUnit3 and Junit4 XML Reports with Maven
Is there a decent HTML Junit report plugin for Maven?

best way to enable hot deployment on Jetty when using Gradle+Eclipse

I'm used to mvn, but I'm testing Gradle (v1.8) for a small web development project.
I've noticed that the Jetty Gradle plugin support autoscan and hot deployment, so I've enabled it. My goal is to recompile from Eclipse and get a Jetty reload the context every time I change a Controller, etc.
However, this is non working, mainly because Gradle compilation output goes to build/, however the Gradle Eclipse plugin creates a .classpath configuration that directs all the Eclipse output to /bin (even mixing test and main source folders).
Is there a way to?...
Run graddle jettyRun on a separate console.
Save a modified class on Eclipse (triggering a compilation)
See that Jetty picks up the change and reloads the context.
As per my research, I've identified three workarounds, but none of them solves the question above (I'm posting them in case you have related comments or more recommendations)
Tweak Gradle Eclipse config to direct test and main build output to the same directory that Gradle uses (using the pattern seen here). This is not recommended by some people, as it means using two different compilation systems that could interfere with each other.
Use the Gradle eclipse-wtp plugin to generate a WTP2 config, and use Eclipse's "Run AS -> Run on Server". This accomplishes the hot deployment / iterative goal and keeps both systems (IDE and Gradle) isolated. However, you need to setup the server on Eclipse.
(Not really a workaround): I've tested Spring's Eclipse build (STS) Gradle integration, however it seems that the integration is focused on the project setup, and while Gradle builds can be automatically triggered, Eclipse compilation is still redirected to bin/.
So you are interested in fine-tuning hot-deployment, right?
Please, consider using Gretty gradle plugin: https://github.com/akhikhl/gretty
It is an advanced gradle plugin for running web-apps on jetty. It does exactly what you want, regarding hot-deployment (and, possibly, even more).
Disclosure: I am author of Gretty plugin.
If you don't want to change to other plugins, here are two steps for the workaround:
add below configurations into your build.gradle:
jettyRun {
reload = "automatic"
scanIntervalSeconds = 1
}
each time after you changed java code, run the following task:
gradle compileJava
Because jetty is watching the *.class files, it will hot reload only after *.class files changed.
Refer to this link: https://discuss.gradle.org/t/hot-deploy-with-jetty-plugins-jettyrun/7416

gwt-maven-plugin with Eclipse Indigo

I would just like to setup a new GWT project in Eclipse and use Maven for dealing with all the jar jungle. I used gwt-maven-plugin with this instructions, but I can't get the project to work in Eclipse.
What I've actually done:
Created a maven project using the archetype gwt in command line.
Imported the projet in eclipse using import > existing maven project
While doing that I had errors saying:
gwt-maven-plugin:2.3.0-1:generateAsync - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:i18n - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:exploded - "No marketplace entries found to handle"
These errors don't go away even if I ignore them on the import.
How can I make these projects working? Is the problem that I skipped the "process-resources" setting? (There is no such setting in the latest version of m2e.)
Should I even use gwt-maven-plugin? Is there any other way of making a GWT project to use Maven? Or – is there any other way to fight with the jar jungle? What does GWT guys use?
I use Eclipse Indigo with m2e plugin 1.0.0 and Google suite plugin version 2.3.3.
Eventually I gave up Maven. As one other developer said "good ideas and bad code build communities faster" , I also remember my experience with Maven on all the projects: very promising on the beginning, but eventually you get to some problems and end up working more with configuring Maven than actually dealing with your own code.
I decided to manually copy needed .jar-s into /lib folder. I spent some time due to transitive dependencies, but LESS than dealing with Maven and now I have things under control. If sometime in the future working with libraries will become an overhead, I will consider using Ivy.
If someone wishes to stick with Maven, I lately found a very useful link by Google team:
http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven
They recommend using their sample projects and not gwt-maven-plugin archetypes (due to issues). I agree. They also provide needed pom lifecycle changes for Eclipse Indigo.
According to a recent post on the gwt-maven-plugin mailing list the Maven integration is not complete for Eclipse Indigo, since the M2Eclipse 1.0 release has brought about a large number of changes. The suggested workarounds from David Chandler, Google engineer, are:
You can run "mvn package" on the command line or right-click on the project > Maven > Run as > Maven build.
The plugin execution failures you're seeing can be resolved by adding lifecycle mapping metadata as in the sample POMs. They are only needed for Indigo. You should not get these errors in Helios or when running mvn package from the command line.
Disclaimer: The following guidelines are for Windows users. These steps are on the basis that, they have worked when tried by the replier and doesn't guarantee fulfledge working unless experimented by self and tried with proper prerequisites.
::Creating a simple gwt project using archetype::
Following are few commands that can be used to create a simple gwt project "Web Starter Application":
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 org.apache.maven.plugins:maven-archetype-plugin:generate
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 -Dmodule={module name} org.apache.maven.plugins:maven-archetype-plugin:generate
(The value of archetypeVersion can be 2.3.0 or any higher stable version.)
Few coordinates are required by maven to create the gwt project. They are as follows:
groupId
artifactId
version
module
The first command doesn't take any of the above coordinates hence, we need to supply them at the time it executes. Notice that the archetype goal is mentioned right at the beginning of the command. It is mandatory to give the archetype goal.
The meanings of these coordinates can be found here.
One of the best ways to start with understanding maven is this.
The second command doesn't consider the module name hence, you will be prompted to give it at the time the command executes.
The third command is equivalent to running it in batch mode where you just have to confirm the inputs for groupId, artifactId, version, module as mentioned in command itself.
Once any of these commands gives a BUILD SUCCESS result, then navigate to the just-now-created project folder from command line and execute the following command:
mvn gwt:run
It should start the project in Development Mode so that you can Launch the Default Browser to run the project or Copy the URL to clipboard and navigate to it through any browser.
Good luck with the execution.

How to solve problem with out of synchronization of J2EE module dependency in Eclipse?

I have two projects : my-lib and my-web.
my-lib is built using the Java compiler of Eclipse, and a short Ant task is run on some properties files, which are then modified (as explained here).
This is not a pretty solution, but it works.
Now, as my-web is dependent of my-lib, I define my-lib as a Java EE Module Dependency of my-web.
However, when I attach my-web to the Tomcat in Eclipse, and try to publish, I get the following exception:
'Publishing to Tomcat at localhost' has encountered a problem.
Resource is out of sync with the file system: '/my-lib/target/classes/my-app.properties'
This file is indeed one of the files modified by the Ant task.
How can I correct this problem, as I need to have the Ant task run on the my-lib.
If you have the Ant task run as an external builder or external task, you can configure it to refresh the project, workspace, or selected resources after execution. When specifying the task/builder click on the Refresh tab and pick the appropriate one for your needs.
There's more information in the eclipse help.