I would like to generate Eclipse Java Project with my Java program. When I click a button: it will generate an eclipse project with the parameters I specified (source path, library, ...)
My questions are:
is there a way to do that ? and how ? (api).
it is possible to generate Net-beans project too ?
Best regards,
Florent
Maven enables this and many more things around creating, bulding, testing and developing Java projects.
Create a Java project from command line. Then, using Maven create NetBeans, Eclipse or IntelliJ IDEA specific project files. Or even easier, just import already created Maven project directly from these IDEs.
Create Java Project in Eclipse first. Then look into directory created. You should find there two files: .project and .classpath. These are the files you should create in your app to get what you want.
Also for eclipse available M2Eclipse plugin to provide some Maven feature from Eclipse IDE.
http://m2eclipse.sonatype.org/
While Maven is the way to go in the long term, the best way to start a project in Eclipse is:
Hit Ctrl+N and choose Java project
Fill in the project name fields
Copy your files from wherever they are to the newly created project (ensuring to preserve package hierarchy)
Refresh project from File menu
Create a Run / Debug profile to run your app.
It should be fairly simple to get up and running this way.
The reason people recommend Maven is because Eclipse is an IDE. It's great for development but its no good for resolving external dependencies or for command line / automated builds. Maven is an IDE neutral way of building and becomes essential the more dependencies a project pulls in.
Unfortunately Eclipse integration with Maven is pretty clumsy and can be summarized with these very broad steps:
Install Eclipse Helios
Install m2eclipse from the Help | Eclipse Marketplace
Mess around with eclipse.ini to make Eclipse start from a JDK.
Configure m2eclipse to use any existing Maven local repository
Hit Ctrl+N and create a new Maven project and skip archetype selection
Copy all the source files from the old project into the new ensuring to use Maven's conventions for file locations. (e.g. source goes in src/main/java)
Create a Run / Debug maven target to clean / install the app
I say broad steps because there are a lot of gotchas. For example if the source is Java 5+ you might have to tweak the pom to set the compiler level. Best to get Eclipse working and then worry about Maven.
Netbeans has vastly better out of the box support for Maven although IMO Eclipse is still the better IDE for other reasons.
Related
I have a couple of projects in eclipse which I now manually export as plugins from eclipse with the following steps:
1) Right click on example_project_plugin_1 in the Project Explorer View
2) Select Export
3) Select Plugin Development > Deployable plug-ins and fragments
Then in the folder eclipse>plugins folder, I can see the archive/jar file of these plugins.
However I want to automate this system.
These plugins are required by another project (say project_to_test) which I'm trying to run and test and I am using Maven to automatically build test cases written using RCPTT running on a jenkins server.
So basically what I want is, without having to manually export as plugins from eclipse, it should be automatically exported as plugins when I call project_to_test from the jenkins server.
I found Tycho but it seems very complicated. (Maybe there's an easier way or tutorial somewhere of how to use Tycho for my particular use?) I tried Ant too but it's also manual work. Is there any easier way to do this? I am quite new to this so I need some direction.
Thanks in advance!
Tycho is probably the best way to do it, as you are already using Maven you should be well on your way. Tycho is simply an extension of Maven (plug-ins, but I am afraid to say plug-ins too many times with different meanings :-).
There is an excellent Tycho tutorial out there: http://codeandme.blogspot.co.at/p/tycho-articles.html so that is the place to start.
However, if you really really don't want to do that, then you probably want to use PDE Build. That is the traditional build system of Eclipse, but it has its weaknesses. You should know that Eclipse does not even use PDE Build to build itself anymore, it uses Tycho.
To use PDE Build from a command line you need to use Ant. The manual work that you refer to is (mostly) automated through a PDE feature that creates that Ant files for you. Right-click on a project, select Plug-in Tools -> Create Ant Build File
Once again, I feel compelled to encourage you to take the plunge into Tycho now, rather than invest more time in the PDE Build way. You are clearly ahead of the curve in other areas (you are doing GUI testing!) so now is the time for automating your builds too.
I need to write some Unit-Tests for google guava 15 (for an online course).
There is a semi-automatic tool involved that reads the source code and executes it with the help of eclipse. So I need readable source code (not only the binary classes) that can be run from within an unittest.
So here is what I did:
cloned github repo via egit
Import from git -> local repository -> general project (I tryed new java project and the new project wizard but that created empty folders, only with general project the source was at least visible within eclipse)
went back in git history to guava version 15
But it seems that he doesn't build the java project now (of course because its a general project). I found some answers to this topic: editing the .project from eclipse to change the general to a java project but that did not work, maybe I did it wrong).
But is there an easy way to do this? Maybe by using a build tool or something? Seems to be very complicated to edit the .project for a complex project like guava, only telling him that this is a java project does not work!?
Guava is designed to be built using the Maven build tool.
If you want to do this within Eclipse, the M2E plugin implements Maven integration. It knows how to import a Maven source tree as an Eclipse Java project, including setting up the ".project" file and other stuff that Eclipse needs.
Here's how to install it: Maven in Eclipse: step by step installation
This is somewhat detailed answer on how to get a Maven project in Eclipse working and manage it by EGit. It describes almost the same situation.
I write C# commerically and I am using Scala IDE ( Eclipse) at home. I want to be able to structure my project so I have a play component (.NET equivalent Assembly / VS Project) and another component which is the Core (Model, Services etc)
How do I do this in the Java / Scala world with Jars etc. How do I structure this in eclipse to get these results?
Cheers.
It depends if you use maven. If you do, you would create a project for the play component which has a dependency on the core component, which is another maven project.
If you don't wanna learn maven because you want only a fast solution, create two separate java projects and in the project properties of the play component go to the "build path">projects tab and add the other project (core) there, this will also create a workspace dependency
If it is a play project, you can just generate the eclipse project by using 'eclipse' command in the play console, and just import the project.
From the Scala IDE point of view, there are 2 possibilities:
the sbt build contains 2 projects, the core one and the play one. Using eclipse from the sbt prompt will generate the correct Eclipse configuration file, and the 2 projects will be linked when imported in the workspace.
there are 2 sbt builds, each containing one project. The eclipse sbt command will generate independent project configurations. After importing the projects in the workspace, the Java build path (in the project properties) will have to be tweaked to make one project depend on the other. (quick tip: make sure to select the dependencies you need in the Order and Export tab).
If you set it up with 2 sbt builds, you will likely need to publish the core locally, and add it as a dependency in the play build.
I will let others chime in about configuring multi-projects in one sbt build.
i was on a 2-day training introducing as to Java EE. We used there Java EE, Spring Framework, Maven, Springsource Tool Suite (Eclipse), Tomcat.
I took the Eclipse workspace we created there and run it on my work PC. I had, if i remember correctly, only to configure Tomcat properly, and it worked on my PC.
Now i want to save the created Eclipse workspace containing 5 "sub"-projects in subversion so that my work colleagues can checkout this to them and run it on their computers.
How to do this correctly? I found somewhere a svn:ignore rule:
.classpath
.project
.settings
target
Using tortoiseSVN i added to the folder with the workspace this ignore rule, but the found out that the underlying folders target were'nt deleted so i deleted them manually and "added to ignore list". But after that the project in spring source tool suite does not see the mevan dependencies (i think so) because the imports are broken. STS underlines org. in the imports and says it can not resolve this.
How do i correctly version control such a project?
In my project we are using Maven and Eclipse (Helios, currently) and the Maven plugins for Eclipse:
Maven Integration for Eclipse
Maven Integration for WTP
We only have the pom.xml file and the src/ directory tree in our version control system. We make sure not to add the eclipse files there. Then when a new developer starts in the project they do Import -> Maven -> Existing Maven Projects. The Maven plugins for Eclipse then set up perfect build paths, settings and so on.
This way it is also very easy to re-import your projects into Eclipse as needed.
So, my tip is to leave the Eclipse files out of SVN and make sure you can setup the project correctly automatically simply by importing a Maven project.
If I understand your problem the right way, you need to configure Eclipse in order to be able to launch tomcat from it. The key, here, is not maven anymore, but Eclipse, I think. As you've made modifications in your workspace that can't be put in your maven configuration file (the pom.xml), you become "Eclipse dependant".
The key here is that, as you're Eclipse dependant, you need the Eclipse configuration files to work. Consequently, I'm afraid you need to add back .classpath, .project, .settings to your versioning tool... It's not generic, because you force people who work on your project to use Eclipse. But if everybody in your team do so, it shouldn't be a problem.
As I don't use Eclipse anymore, I don't know if versioning theses files can lead to problems. However, I hope this answer will help you to configure your project back...
EDIT : to be more accurate... and maybe give a better answer.
When using a version control system, the main goal is often (always ?) to give all the keys to use the sources, and develop from them. Consequently, you need to put in your VCS your sources, and all the configurations needed to use them efficiently.
In your specific case, the key is that you've become Eclipse dependant through its Springsource Tool Suite plugin. Consequently, it becomes essential to add the configuration files for this tool, because they can't work without them, and if they can't work, you can't work.
I can tell you my way of subversioning maven eclipse projects. First, when you create the project structure you have to commit the .setting, .classpath, .project files into the subversion repository. If you can't do this the other colleagues will can not use the project structure after checkout. After you commit the project structure, the best way is not to commit these files except only when you change something important eclipse or build path settings, because the others will have conflicts due to the system dependent informations. Never commit the maven target directory. Sorry for my english. Hope it helps.
I have been working solo on a project for some time, and now, new developers are likely to join the project for various reasons.
I, of course, use a version control software but I am afraid importing my project into Eclipse and making it run might prove a little difficult for new comers, and I want to make it as clean as possible.
When I first took over the project, it took me almost two days to have the project built and run it, I documented every step and fixed the most obvious errors, but not all, and I want the project to run as it is when imported.
The project is a mix of java projects for the backend, a j2ee project for the server and a flex project for the client.
The IDE is going to be Eclipse
The version control software is Perforce
Here are some of the specific problems I have right now, should I fix them, and how ?
Eclipse environment variables are used for libs, all the libs are in a folder in the j2ee project but are used by all the java projects (they have to be set in each IDE the project is imported into)
Runtime JRE is specified in .classpath for each project, so each projects property must be edited when trying to build the project in another environment
Apache server is specified in j2ee project property
To avoid exporting the jars of all the java projects into the j2ee project each time I modify the code, there are linked folders in the j2ee projects, linked to each java project bin folders
For (4) I will probably have to use maven, but is it possible to fix problem (1) (2) and (3) without using maven ?
The alternative is to have a one page set up instruction document
Also do you have any other general or specific advices as to how organize this whole mess.
Thank you
Dependency management is a must - use Maven. If you can't use maven, because you are already using ant, go with Ivy.
Make the project buildable with one click - be int ant build all or mvn package. Maven provides integration with the IDE (via the plugin).
Don't reply on IDE metadata. like .project and .classpath. You can still commit them to ease Eclipse users though, but don't restrict the IDE.
Provide build-on-save. Either using Eclipse WTP, or using the FilSync plugin (it sounds like a hack, but is pretty cool)
Use build profiles (maven provides them automatically) - to create different builds for different environments
It's not always possible to configure everything in your maven (or ant/ivy) scripts. For any additional actions, like installing app server - document then in a single file in the root of your project, describing step by step what should be installed, with what config options, etc. Thus the developers have only one place to look at and follow. The document can (and better) be plain .txt
A sidenote: use Continous Integration - download Hudson or TeamCity and configure it to build a project
From my very recent experience - we had a project we've been working on for 6 months. A colleague of mine had to re-import the project on a new machine. It took him 20 minutes. The project is configured with Maven.