Ship an eclipse dynamic web project as a pure maven project (possible?) - java

I have a maven project in eclipse (was originally a dynamic web project, which was converted to a maven project that has the web-app arch type).
Whenever I upload the project to Github, I, of course, upload the source java and web files, pom.xml, but I also need to upload the .project, .settings, and .classpath files which are Eclipse IDE specific (right?), so that later I can import it directly using eclipse from Github. If the latter files are not uploaded, I cannot import the project later on in eclipse. After importing, I use maven with the respective pom.xml file to download the dependencies and build the war file.
Is there a way to export my project in a form independent from eclipse, i.e., something like a pure maven project? So that, later, it can be imported using e.g., say Intellij or Netbeans only using maven? Or just tell Eclipse to import a maven project from Git, rather than an Eclipse project as it is now. Is there such a thing? If so, how to create it and commit it to Github from Eclipse? Which files/directories do I (not) need?

Related

using eclipse and netbeans on git

I am trying to work with a partner using a git repo. He uses netbeans but I use eclipse. I am having problems when I import the project into eclipse, the project has no classpath folder in eclipse so it cannot run and it is not highlighting errors in the code.
My question is is there anyway to work on the same git project with two different IDEs? And if so, how do I get eclipse to recognize the netbeans project folder to create its own .classpath.

Can I convert eclipse source folders into packages?

I've forked a Github project, used Eclipse to clone it locally, and imported that as a general project into Eclipse.
The accompanying .project file is an Eclipse .project file with the proper "nature" and "buildCommand" xml tags.
So it seems like a valid Eclipse project. However, I'm unable to specify a run configuration or configure the build path.
When I select the Build Path popup menu item, it says "no actions available" in grayed out text. When I select "Run/Run As" from the main menu,
it shows (none applicable). I'm wondering if the problem is that the project imported completely as source folders:
There are no packages to speak of. I created another project from scratch, and created the proper source folders and packages as needed
to match the package statements in the source code. After manually importing the source from the git repo, I can build and run that project.
If the lack of packages is indeed the problem, is there a quick way in Eclipse to convert source folders to packages?
What you did is you have probably cloned the repo in Eclipse and then Imported this project through a New Project Wizard, because in GitHub there is no existing .project (and no .classpath) files.
The "New Project Wizard" will create a set of defaults for a java project (I suspect that you selected just that), but is anaware of Maven structure, so all source folders will not be recognized and you will end up having to define them on your own. Worse, you will be unaware of any special parts of the Maven build that might be configured within pom.xml.
Because this project uses Maven for building, it would be better to use M2Eclipse while importing it. Install it using Help->Install new software.
Then there are a couple of steps required to make it use all Eclipse features.
Keep your cloned copy of the repository or clone again if you want to start from scratch. Then use File->Import feature to import a maven project into the workspace. Select Exisiting Maven Projects and point to the directory containing pom.xml file in the cloned repo. This will use Maven integration in Eclipse to generate .project and .classpath files based on pom.xml contents, so you will be able to more closely mimic Maven build in Eclipse. All source folders should be properly discovered this way. Eclipse might want to install some additional integrations for Maven features that this particular project uses. Let it, if that is the case.
Now, you will have the project operational and compiling in Eclipse, but it will not be aware that it is managed by Git... This is because M2Eclipse and Git Team provider are not integrated (at least they weren't when I last checked). In order to be able to commit to the repository in Eclipse, remove the project from workspace, but without deleting contents. Then, import from Repository view using Import Projects/Import exsisting Eclipse projects. Since necessary .project file is already generated, Eclipse will autodiscover the project and will use the right configuration prepared earlier by M2Eclipse.
In the end you will have a properly configured Maven project with Git as a team provider for it.
If this is a project meant to be built by Maven that contains a pom.xml file, install M2E before importing the project from your local cloned repository. It will handle this.
Right click at root of project select properties, in the sources tab add the folder "src/main/java" as source folder
Other way is to configure facet as java

Grails equivalent for Gradle Eclipse plugin?

I just cloned a Grails project to my local machine (using Mercurial). I am using GGTS for Grails projects, and would like to import the Grails project as an existing project. With a Gradle-built project, I would just apply the Gradle Eclipse plugin and then run gradle eclipse inside the project root.
This generates Eclipse project files and classpath magic for me, so I can import it into my Eclipse workspace.
I'm using GGTS for my Grails projects. But when I open up GGTS and go to Import >> Existing project, and select my Grails project (root dir), it doesn't see the necessary Eclipse project files and can't open it up.
So I ask: is there an equivalent "Grails Eclipse/GGTS" plugin that will allow me to take a Grails project that has no Eclipse files (.project, etc.) and generate them?
The command you are looking for is the Grails command integrate-with. You can read more about it in the Grails documentation.
The integrate-with command will integrate Grails with different IDEs
and build systems based on the arguments provided. For example the
--eclipse command will produce .project and .classpath files for use with Eclipse or Spring Tool Suite (STS).

what is the difference between maven-archetype-webapp and eclipse dynamic web project

why do I need to apply: mvn eclipse:eclipse command?
are they equivalent to application container/server?
Is there a file for which customizing is necessary besides web.xml?
when you create a web project using maven, like maven-archetype-webapp. It creates the folder structure as recommend by Maven for a webapp like shown here .
Now when you try to import these folders in Eclipse, it still would look like folders but eclipse cannot understand the nature of these folders. Eclipse relates folders and contents within them to an Eclipse dynamic web project only through its .project , .settings files
So in order for your maven project to be understood by Eclipse, you run the goal mvn eclipse:eclipse. After executing this goal, maven generates the .project, .settings files necessary for eclipse to understand the project as Web project.
This is however optional. You can still import the project as Maven projects within eclipse and continue to use them but you cant rely on Eclipse's features like clean/ build / build automatically.
Though I use eclipse, I dont rely on Eclipse's build feature. I have installed Maven eclipse plugin and that allows me to run maven goals and commands within Eclipse which is as good as running Eclipse's build feature. Hope this helps.

How to build a project from GitHub?

I'm new to using GitHub and I need to build the latest project from https://github.com/TantalumMobile/Tantalum but I don't know what to do with the zip I downloaded from the site.
What I got after extracting from this zip was a Tantalum-Master folder and inside the same layout as the project in GitHub but if I try to import this folder into Eclipse then I get the example projects imported and not the project with the classes I'm interested.
Do I have to reference somehow project like in Visual Studio? How do I build the jar? Do I have to paste the source folder into my project? Does Eclipse needs a plugin to use this kind of projects? Do I need a specific IDE to build this kind of project?

Categories