Resolve Classpath within Eclipse as Maven-Plugin - eclipse

Enviroment
I am developing a Maven-Plugin for multimodule build which is using Eclipse Tycho. One of the plugins tasks is a bytecode enhancement and requires the maven projects classpath.
At the moment I am adding all session.getAllProjects() and project.getArtifacts() to the ClassRealm of my PluginDescriptor. This works just fine from the CLI on the parent and child pom.
Problem
If I am trying to build in eclipse (update on one of the projects) maven doesn't resolve the compilepath within the plugin - I only get the plugin classpth (at least in the usecase within eclipse). This leads to an error.
What I've already tried
Using requiresDependencyCollection = ResolutionScope.RUNTIME_PLUS_SYSTEM, requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM in my Mojo Annotation
Getting the classpath from some other variables available
Questions
How is the best way to get the whole maven build classpath in my plugin?
Does the classpath behaviour have anything to do with tycho?
Any post will be appreciated! Thank you very much!

Related

Why is jboss marshalling river jar reported as missing by gwt devmode even though it is included in the classpath

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

Maven integration with IDEs

I thought I understood Maven as I've worked on a few projects using it, but I seem to be having trouble creating my own project with it, so can someone correct me wherever I may be wrong?
Assuming I create a new Maven project (we'll say I did it through Eclipse or IntelliJ):
If I add a dependency to my POM file, assuming I add a public repository where that dependency can be found, shouldn't the IDE download the specified JAR and make it so that it is recognized when I use it in my code? Currently, my projects do not recognize any classes that should be found in JARs via my POM dependencies.
Assuming #1 does work, how can I determine via maven which transient dependencies I have? For example, I'm using classes from Pentaho Data Integration, and some of the plugins for it reference things like org.mozilla.javascript.*. Could maven automatically tell me that without me having to run the code, see it fail, and manually fix the dependency? There will be hundreds of those instances here, so manual fixing really isn't viable.
Here are my IntelliJ two cents:
1 - Adding a dependency in pom.xml of your project
Should indeed download the depended jar(s). You may need to approve "Import Changes" dialog if it pops in, or enable auto import.
2 - Seeing transitive dependencies
It can be achieved via Maven Dependencies Diagram - unfortunately only in IntelliJ Ultimate edition. You can use Maven Dependencies Plugin to see the dependencies tree in your favorite CLI.
Question 1: Adding a dependency
In Eclipse, depending on how you created the project, you should be able to add dependencies that are automatically recognized using the maven context menu.
Note that you should have created the project using the eclipse maven plugin so that it has maven nature.
To add dependencies/plugins from a remote repository, you can search in the resulting UI for a dependency if you know the artifactId or groupId. The plugin will pull up the deps whether the repo url is specified in the pom.xml or not.
After adding a dependency to the POM, the IDE will start downloading it and all transient dependencies as soon as you save the file.
If something goes wrong, you can try to "Update Project" from the context menu.
Question 2: Determining transitive dependencies
Transient dependencies are visible in the "Dependency Hierarchy" tab of the POM editor.
I usually default to the command line because it allows much more flexibility and functionality when tracking the dependency graph.
I am sorry but I have not worked with IntelliJ

transitive dependency using GWT Plugin Eclipse

I have Project A which is a GWT Project with RPC stuff. The Server part Depends on a Project B and that project (B) depends on some thirdparty ABC.jar's
When i Run the GWT project with Run/Debug the ClassPath doesn't contain the ABC'jars - only the compiled classes from Project A and B is in the WEB-INF/lib folder and the GwtServlet.jar.. thingy.
Any help would be very welcome ..
ps: We are not using Maven and wont be using it in any near future ...
put ABC.jar into the war/WEB-INF/lib folder
https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects
I you cannot use Maven in your project for dependency resolution and don't want to manage them by hand Apache Ivy (+Ant) may be another option.

Gradle eclipse classpath - Switching between SNAPSHOT and project dependency

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é

how do you configure GWT_B to add GWT_A as a dependency? (GWT_A & GWT_B are both GWT projects in eclipse)

I have a tough question.
I have 2 GWT projects GWT_A and GWT_B, each in a different root folder. All the porjects are compiled using Maven. GWT_B has its own servlet and uses the one of GWT_A.
Now my question is, how do you configure GWT_B to add GWT_A as a dependency?
PS: Adding a normal dependency fails because the GWT_B is not finding the packages in GWT_A.
Please help !!
As explained here. The trick is in turning on the resource filtering so that when you mvn install GWT_A, maven will package the source code which then gwt can pick up when compiling GWT_B.
There's more resources on the web describing how to setup a multi-module project, google for gwt maven multi module project.