Redeploy plugin into eclipse installation - eclipse

I have a eclipse plugin that contains JUnit Tests developed using SWTBot.
I'm trying to run the test against a eclipse installation using tycho-surefire-plugin on a hadless mode. Here is my maven conviguration:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIThread>false</useUIThread>
<testRuntime>p2Installed</testRuntime>
<work>${work.dir}</work>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<argLine>${ui.test.args}</argLine>
<appArgLine>${ui.test.vmargs}</appArgLine>
<application>com.myapplication</application>
</configuration>
</plugin>
I'm running test using:
mvn verify
Everything is ok except that fact that if I'm doing some code change on my plugin the newer version of the code is not deployed into eclipse installation.
Before running mvn verify I'm running a mvn install command.
If I'm adding a new test class I get
Caused by: org.apache.maven.surefire.util.NestedRuntimeException: Unable to create test class 'com.tests.MyNewClassTest'; nested exception is java.lang.ClassNotFoundException:
I there any configuration that I'm missing. How can I redeploy test plugin?

Incremental builds, i.e. builds without clean require that the build plug-ins correctly cope with the build results in the target folder from the previous execution. This is apparently not the case for the tycho-surefire-plugin.

Related

Configure in Maven that Eclipse follows maven-surefire-plugin configuration

We got following situation: We have unit and integration tests. Unit test classes end with Test and integration tests end with ITest. To execute only unit tests at Maven build we use following configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*ITest.java</exclude>
</excludes>
</configuration>
</plugin>
That's working in Maven build, but when I'm executing tests in Eclipse IDE via context menu > Run as > JUnit test it ignores these excludes and tests with ITest at the end fail.
Is there a way to configure (in POM) that Eclipse follows maven-surefire-plugin configuration?
Run as > JUnit test does not know about your pom.xml.
But if you place your unit tests and integration tests in different directories (the Maven convention suggests src/test/java and src/it/java), then you can use Eclipse’s ability to run all tests in a package or source folder; simply click on the integration-test source folder and select Run as > JUnit test from its context menu.

eclipse nullpointer exception for modulare maven project update

I'm using Eclipse 4.4.1 with m2e plugin and the latest gae dependencies. When I import the gae module sample project eclipse tells me that the project configuration is not up to date. If I run the suggested maven -> update project, I get a NPE.
There are a lot of bug reports according NPE on project updates out there. So far I've tried it with mvn eclipse:eclipse or maven project imports, in fresh or existing workspaces but I was never able to get the projects running in eclipse.
Are there any solutions to this?
EDIT:
That is the stacktrace:
java.lang.NullPointerException at
com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
at
com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
at
com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
at
com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)
at
org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:120)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:477)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:1)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:470)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProjects(ProjectConfigurationManager.java:250)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:163)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$1.call(ProjectConfigurationManager.java:1)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:166)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:142)
at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:96)
at
org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1348)
at
org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:133)
at
org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob$1.doCreateMavenProjects(ImportMavenProjectsJob.java:73)
at
org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:62)
at
org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob.runInWorkspace(ImportMavenProjectsJob.java:82)
at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
You can comment out the appengine-maven-plugin to solve the problem, but by doing that you lose the command-line capabilities of the plugin. You can have the best of both worlds (Eclipse and Maven command-line) by using Maven profiles:
<profiles>
<profile>
<id>gae</id>
<build>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
</build>
</profile>
</profiles>
To activate it, for instance, to deploy the project from the command-line, you can do:
mvn appengine:update -P gae
When defining the appengine-maven-plugin only inside a profile, Eclipse won't use it, and the bug goes away. When using the command-line, just remember to activate it using the -P flag.
I had the same problem suddenly appear in one of my projects. Disabling the JPA validator seems to have resolved the issue for now.
Select Windows > Preferences > Validation
Disable the JPA Validator for both Manual validation and Build validation
It might be related to the "The persistence.xml file does not have recognized content" error described in here: www-01.ibm.com/support/docview.wss?uid=swg21616684 .
I had the same issue after updating from Eclipse Kepler (4.3) to Luna (4.4). Commenting out the app-engine-maven plugin from my pom.xml fixed it for me.
<!--
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
-->
I'm able to run and deploy my app without any issues so far.
seem to be a duplicate of An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
got to preferences / Server / Runtime Environemnt
--> select "Google App Engine" and associate a valid SDk to this runtime.

Errors when executing tests in Tycho but not in Eclipse

I have a set of test cases that use the Eclipse WorkbenchPage and a couple of other classes to perform a set of functions.
When I execute the test bundle in Eclipse, all the test results are green. But when I "clean install" the same package in the command prompt, the build fails and shows test failures in my test classes.
What could be the problem here? I tried debugging my code from Maven but it didn't help at all.
Tycho and Eclipse differ in how they determine the test runtime:
In Eclipse, by default the entire target platform and all projects from the workspace are included in the test runtime.
In Tycho, only the test bundle/fragment and its transitive dependencies are part of the test runtime. If your test has implicit dependencies, e.g. on a bundle which provides some UI via an extension point, you need to explicitly configure these in Tycho.
With the following build configuration, you can for example include the feature org.eclipse.rcp and all its transitive dependencies into the test runtime:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-feature</type>
<id>org.eclipse.rcp</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>

Eclipse error with osgi + maven + maven-pax-plugin

I am trying to create an OSGi bundle and integrate it into eclipse. I am using the maven-pax-plugin to create the bundles. These are the steps I follow
I create an osgi project using pax
mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId=osgi-project -Dversion=1.0-SNAPSHOT
and then create a bundle
mvn pax:create-bundle -Dpackage=org.sonatype.mcookbook -Dname=osgi-bundle -Dversion=1.0-SNAPSHOT
and then try to import the maven project into eclipse (file/import/existing maven project) the bundle project created in the second step always gives me this error
maven-pax-plugin:1.5:compile (1 error)
Execution default-compile, in org.sonatype.mcookbook/pom.xml
maven-pax-plugin:1.5:testCompile (1 error)
Execution default-testCompile, in org.sonatype.mcookbook/pom.xml
When I select one of the errors the description says
No marketplace entries found to handle Execution default-compile, in org.sonatype.mcookbook/pom.xml in Eclipse. Please see Help for more information.
If i ignore the error and import the project anyway this is what eclipse complains about
Plugin execution not covered by lifecycle configuration: org.ops4j:maven-pax-plugin:1.5:compile (execution: default-compile, phase: compile)
Has anyone seen this? any ideas how to fix it?
I am following this tutorial but adding integration with eclipse. Note however that if I build it with maven and don't use eclipse at all it all works fine, the problem is in eclipse/m2e
I am using Eclipse Indigo SR2 and m2e 1.0.200
I get rid of this problem by following the comment in the generated POM and move the <extensions>true</extensions> down to the maven-bundle-plugin below giving:
...
<plugins>
<plugin>
<groupId>org.ops4j</groupId>
<artifactId>maven-pax-plugin</artifactId>
<version>1.4</version>
<!--
| enable improved OSGi compilation support for the bundle life-cycle.
| to switch back to the standard bundle life-cycle, move this setting
| down to the maven-bundle-plugin section
-->
<!-- WAS HERE -->
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<!--
| the following instructions build a simple set of public/private
| classes into an OSGi bundle
-->
<extensions>true</extensions> <!-- MOVED HERE :-) -->
<configuration>
...
Then update the project (Right click on project name in Project Explorer: Maven -> Update Project...), wait for the build to complete and the error is gone.
Hope that helps!
The new m2eclipse versions require that every plugin that affects the build is supported using a m2eclipse plugin. So the maven-pax-plugin is not yet supported. As this basically happens with most maven plugins out there I still use the old m2eclipse version.
Unfortunately the old version 0.12 download seems to have been removed recently. So probably you will have to wait till maven-pax-plugin is supported.

GWT Maven and web.xml

I'm using the GWT Maven plugin from Codehaus with m2eclipse. Where is my web.xml file supposed to end up? Isn't the Maven build supposed to copy it to the /war directory? I can't see it there. Or does Jetty pick it up automatically from src/main/webapp/WEB-INF/?
Here's a relevant section from my pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warSourceDirectory>war</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
I believe web.xml (and everything else under src/main/webapp/) gets copied into target/<projectname>-<version>/ during the normal maven lifecycle (For example, when you run mvn install).
If you're running any of the gwt-maven plugin goals, then check out this link.
When running gwt:run, if you want to run the full web app just as if you have built and deployed a war, I found the best way is to add the following to the configuration for the gwt-maven plugin:
<hostedWebapp>
${project.build.directory}/${project.build.finalName}
</hostedWebapp>
This tells gwt-maven plugin to look for the web.xml (and all the other parts of the war file) under target/<projectname>-<version>/. So make sure to either run mvn install first (or mvn war:exploded), then run mvn gwt:run and you should be set.