i am working on developing a eclipse plugin which takes code from repository and builds the code in hudson.
for that i need to get the repository url of pom.xml
are there any eclipse api's to get repository url of current project.
for example i have got the workspace of current project using this api.
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IPath location = root.getLocation();
I think you should try to "stand on the shoulders of giants". Eclipse has now integrated m2e from Sonatype (formally m2eclipse), and I found the following in an XML file
M2E provides both a framework for building Maven-centric Eclipse
tools and set of tools and user interface elements directly
consumable by Eclipse Users.
As a framework, M2E provides facilities to import and configure
Maven projects in Eclipse workspace as well as APIs that allow
m2e extensions to access Maven project metadata and participate in
Maven project configuration and workspace build.
So you should look into m2e and check if the API allows what you want to do. I would start with plugin org.eclipse.m2e.core and study how to get access to the maven project ...
I think eclipse may not know the repository url in pom.xml,the eclipse maven plugin can tell you about them,but why not manually analyze the pom.xml as resource file?
Related
I have searched around and couldn't find a direct answer in how to import an existing AEM project on my local into Eclipse. I am relativity new to AEM and would like to use the features Eclipse has. I have the AEM plug in downloaded and am able to create a new project, just not import.
I am not using maven, just packages and OSGI.
Advice?
You can create a new AEM archetype project (provided by the AEM eclipse plugin). That project will be a maven project.
Since you are not using maven in your current project, you can manually move all of your java files into their respective location on the newly created AEM project. As for the java dependencies, you can lookup tutorials on how to use maven and add your java dependencies to it. or you can just add your dependencies directly on the project, but I recommend using maven.
You have only package and OSGI bundle, so you can only modify the content (package) and cannot modify the bundle.
We cannot import a project from the osgi bundle to make the source code editable.
For import AEM project to Eclipse, follow the procedure:
Import AEM project as maven projects. Please check with image.
Then select your project and build.
From where you are getting those packages and bundles?
When ever you build the project from the source(cmd : mvn clean install), packages/bundles will be generated under respective target folder based on pom.
So, you can only import project source on eclipse and not the generated target files.
I have an application made up of a number of maven projects. I work on it in Eclipse. Some of the projects use Maven plugins to generate stub classes for web services etc.
When i import the projects into a new workspace I have to issue a maven generate sources command followed by attach source folders to build path on each project. The application i work on has more than 5-6 projects which require these steps.
Is there a plugin I can install in Eclipse to pick up the generated sources, or even one that generates the sources and updates the build path to save the manual steps?
I'm pretty sure the m2e plugin takes care of this automatically. m2e is included in the primary Java and Java EE packages of recent Eclipse versions, so you probably already have it. If you right-click on your project, and there is a Maven submenu, then the project is already managed by m2e. Otherwise, right-click and choose Configure > Convert to Maven project.
Well, it depends on exact maven plugin you are using.
generate sources
Before I considered that m2e connector would be needed for any non common plugin, like generator. But I came recently on some plugins (1), that do it without special m2e connector.
attach source folders to build path
For this part check build-helper-maven-plugin and answer to M2E and having maven generated source folders as eclipse source folders
I migrated a GAE project to a Maven project with the official way (https://developers.google.com/appengine/docs/java/tools/maven) but I don't want to use Maven to deploy/use devserver.
When I'm using the GAE Eclipse plugin I get an error:
Could not locate /path/to/project/target/WEB-INF/appengine-web.xml
Is it possible to use the GAE eclipse plugin or must I use Maven for deploying/local server?
I found the current process to do this a bit tricky, but it is possible. And it works pretty well after fiddling with it... I've been happy to have Maven manage the dependencies and I've found myself using it to test/deploy too. The key to getting it to work can be found in the GWT docs: In particular, you need to use a "dynamic web project" in Eclipse, rather than the normal (to me) GAE project.
Create the Eclipse Dynamic Web Project as in the link above, including changing the source folders to the proper maven-like location, and changing the web module location to the maven location.
Copy your source files in the right places.
Add the pom.xml file to the directory. At this point, you should be able to go to the command-line and run mvn appengine:devserver
Back in Eclipse, go to the project properties and turn on Google -> App Engine: Use GAE, and use HRD.
To be able to use m2eclipse to manage Maven dependencies and take Maven actions in Eclipse, you need to convert the project to a Maven project, as per this StackOverflow question
You might need to shutdown Eclipse, rebuild via Maven, restart/refresh Eclipse. At this point, you should be able to build/debug/deploy via Eclipse or via Maven!
I have an OSGi bundle which is in Eclipse IDE represented as Eclipse Plug-in Project. The only way I found to satisfy the dependencies of this plug-in/bundle is to
1) import all dependencies (.jar files) through File > Import... > Plug-ins and Fragments wizard
2) and then declare the imported dependencies in MANIFEST.MF
Yes, this solution works, but on the other hand after I commit the changes to our repository all my team mates also have to manually import dependencies to Eclipse to fix the compilation errors.
QUESTION:
Is there a solution which does not require such irritating steps? I just want to pull the changes from repository and continue my work without need to fix the dependecies in MANIFEST.MF again and again...
P.S.: To retrieve dependencies we use Apache Ivy.
You need to set up a target platform in Eclipse. I find the easiest way is to put all the dependencies in a folder, and save the target platform as a .target file which I check into source control. Then the only steps my colleagues need to do is retrieve the dependencies and configure Eclipse to use the shared target definition. If we add new dependencies to the definition Eclipse will automatically pick up the changes with a restart or target platform refresh.
The Eclipse documentation should get you started: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.pde.doc.user/concepts/target.htm
If you develop server based applications then it is much better to let maven or Ivy manage the dependencies and use the maven bundle plugin to generate the Manifest. So you can avoid the Eclipse OSGi mode and the target platform. See http://www.liquid-reality.de/x/DIBZ for a tutorial how to develop OSGi bundles using maven and deploy on Apache Karaf. For Ivy you may have to use a slightly different build but the basics should be the same.
I need help using Egit (Eclipse git integration capabilities). My goal is to have Hibernate sources in my local Eclipse. Eventually I aim for running their tests, doing some changes in the sources, issuing a git pull request (patch), etc.
Can someone explain how to clone Hibernate sources and have them as Java Project(s) in Eclipse?
All I can achieve myself is to have the sources cloned (as needed) to some specified path (the suggested path is outside of the workspace directory). Then I am puzzled trying to convert the structure into Java projects in Eclipse. I try different ways to import the project(s) using File | Import (e.g. Existing projects into workspace) or linking sources into a new created Java project. The problem seems to be the Hibernate sources are not a single maven project (not quite sure about this one either, I am new to maven) and probably not an Eclipse project at all, so Eclipse doesn't recognize the source structure at all.
It looks like it has both maven and ant builds, so you can generate Eclipse projects with both of these.
For maven you have 2 options:
Run mvn eclipse:eclipse to generate
eclipse project artifacts and then
import existing projects.
Install m2Eclipse and import Existing Maven
Project. This is the preferred
approach when working with Maven and
Eclipse.
For ant, New project->Java Project from Existing Ant Buildfile