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.
Related
I am running NetBean 7.4 on Mac and I am sort of new to Maven dependancies.
I have been given a project that uses Maven to download a framework for networking simulation.
Turned out that the framework has a bug and the teacher gave us a public GitHub repository with all the source code for the framework, so that we can also modify it.
How do I connect the GitHub link (with sources) to NetBeans in order to being able to modify the framework classes? The "Attach Sources..." button that appears on the framework classes asks for a JAR or ZIP (if I download the ZIP from GitHub it doesn't work).
Moreover, it looks like the framework files in the Dependancies folder cannot be modified anyway (read-only files).
Thank you all.
to "connect" 2 different projects, the checked out source's version needs to be equal to the version in maven pom.xml.
So clone the github repository, figure out which branch/tag matches the version in your project and check it out. Then open the project(s). If you did that correctly (and assuming the github project is actually maven), your project's dependencies section will list them with project-like icon. Then the projects are linked.
I'm moving over from eclipse to Intellij, and I hit a snag on setting up my project
I have 4 projects on github that, in eclipse, all live in one workspace. They are API, Server, Client, and Basic Plugin, and they each have a Maven pom.
What I want to do is set up Intellij's project structure similar to Eclipse's workspace, where all 4 of those projects are side by side in the explorer, but it's not letting me import more than one maven project as a module (I import the first fine, but the rest silently fail), and importing directly from github creates a whole new project for each repository, which is not ideal.
I tried to import a in my eclipse workspace, but it all broke (Object and Math were not found), and all the java environment setting were wrong.
Any ideas? I'm fairly new with Intellij and I really like it, but I don't want to switch over from eclipse if I can't get my workflow right.
First of all, Intellij IDEA uses different naming than Eclipse, you can learn the details here: http://www.jetbrains.com/idea/documentation/migration_faq.html. In short, Eclipse's Workspace is called Project in IDEA, and Eclipse's Project is Module in IDEA. In your case, you want to have multiple Maven-based modules in one Project. You can do it by creating a Project with one Module and then adding the rest of Modules (File->Add Module->Import Module from external model->Maven etc.).
As for the multiple Git repositories, you can configure that using this help page: http://www.jetbrains.com/idea/webhelp/git-branches-in-multirooted-projects.html
In your case, have a look at the 'Asynchronous branch control' section). It's really straightforward, I have just done it myself for the first time by following these instructions.
Good luck.
UPDATE: The above link now gives 404, so here are the most up-to-date ones that may be of help:
https://www.jetbrains.com/help/idea/2017.1/git-branches-in-multirooted-projects.html
https://www.jetbrains.com/help/idea/using-git-integration.html
IntelliJ opens one project at time, but this project can have multiple modules ( say, maven reactor ). So modules are kind of [related] workspace projects in eclipse. You also can open several independent projects in different windows.
In case you have working maven reactor build, you can just open topmost pom as project and everything will be set up. ( treat maven reactor as your workspace )
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 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.
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.