SVN checkout doesn't create packages - java - java

I'm trying to check out a svn repo. So far so good, the checkout worked but there are no Packages. Is there a way to get the right packages in eclipse?
All the given data I do have is this:
svn co https://jensembl.svn.sourceforge.net/svnroot/jensembl jensembl
Furthermore, I'll add the link to the program, which i want to get working.
link to JEnsembl
/edit added a link to the explorer view of the current project
link

You need to generate eclipse project files using Maven.
See http://maven.apache.org/guides/mini/guide-ide-eclipse.html
Basically:
$ mvn install
$ mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
$ mvn eclipse:eclipse

You can import as a maven project and I feel that is the better way also
I have gone thru the repo you mentioned.
In Eclipse
File--> Import --> Check out Maven Projects from SCM
select svn and use this url
http://jensembl.svn.sourceforge.net/viewvc/jensembl/trunk/
or any subdirectory which contains the pom.xml
and see you can proceed further

On your harddisk a package is a normal folder. If you have the project in eclipse it has to know which of the folders are source folders. Eclipse will show all folders in a source folder as packages and recognize the classed as part of the project. Open the properties of the project. At first you have to go to the category Project Facets and enable Java. After that you can go to the category Java Build Path and add all source folders in the Source tab.
Furthermore you checked out the whole SVN repository which seems to contain a few projects/modules. You want to check them out (or at least import them to Eclipse) seperatly from the trunk folder. I'm also seeing that your project is a maven project so you might want to read up on maven and how to check out projects in eclipse. Here is a short how-to. Again you only want the trunk folder. If you want to know what that is you can read it up here.

Related

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

How to force Eclipse to see java project as java project?

I have downloaded a 3rd party project, which consists of multiple files, including Java ones.
General structure is as follows:
<topfolder>
pom.xml
<subfolder1>
pom.xml
src
main
java
<normalclasspath>
resources
site
apt
index.apt
test
java
<normalclasspath>
Eclipse imports this project normally, but is unable to index its Java content. For example, I can't browse from a variable to its definition, and so on.
Also I can't set my own Build Path since it says No action available.
Of course, I can refactor folder structure myself to suite eclipse needs, but are there any automation means for this?
UPDATE
Yes, this is a Maven project and Eclipse already knows that it has Maven nature. The only option now is to disable it
But this is not a question. The question is how to add JAVA NATURE, so that Eclipse knows consistence of classpath and be able to navigate to class definitions and so on.
UPDATE 2
#75inchpianist's answer about facets helped partially. It was not available to select Java facet immediately, but required turning on facets at all first. Then Java facet was already there.
Now I see, that Eclipse interprets Java, but Maven interpretation is not full. Namely, no Maven dependencies interpreted (no Maven Dependencies node in Package Explorer).
The attempt to add it fails:
Right click on the project and select "Properties"
Within "Project Facets" make sure that Java is selected!
As this is a maven project (because of the pom.xml) you need to install a maven plugin for eclipse.
Next you have to right click on the project and choose "Configure->Convert to Maven Project".
Now you should have your normal java structure.
Assuming that Eclipse recognizes the project as Java project yu can do the following:
If you don't want to install a maven plugin into Eclipse you can make Eclipse recognize the source correctly by adding every src/main/java folder as Source-Folder to your Build-Path.
This is better than modifying the folder structure as you can update the sources without problem later.
Add following to your .project file and refresh the project.
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

My source folders are deleted after executing mvn eclipse:eclipse

I execute the command: mvn eclipse:eclipse to add the required librairies included in my pom file. The problem is that any source folder are deleted after executing that command.
There is any way to add the libraries without deleting the source folders?
I'm not sure what you are doing exactly but the eclipse plugin handles only eclipse configuration and does not touch any source folders. If the source folders are removed from your eclipse project, then the project/pom file is not set up correctly.
Since Juno, eclipse contains the m2e maven integration plugin. I suggest you create your first projects using that. It will take care of handling the build process and project setup for you.
Use the New->Project...->Maven Project menu and create the project using the wizard. When it is complete, copy all your existing sources into the new one and manipulate the pom file with the pom editor (eclipse will open the pom file with this editor by default.)
Important note: If you start using m2e, then don't use the command line eclipse:eclipse target any more as all the house keeping is done by m2e from that time on. If something is really messes up in your eclipse project, then you may delete the project from the workspace (don't tick the delete from disk option), run eclipse:clean (to make sure everything is cleaned up) and import your project with the m2e importer (File->Import...->Existing Maven Projects...)
As allprog wrote: your source folders are probably not deleted. (but probably removed from your .classpath file)
Maven use a standard configuration for all project. Usually there are 2 source folder (for *.java):
/src/main/java for your production code
/src/test/java for your test code
It's a good practice to follow this recommandations, but you can choose another location for your production/test code by adding this in your pom.xml:
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
...
</build>
Using multiple source folder for your production code and/or for your test code is not recommended.

How to import a GIT non-Eclipse Java project into Eclipse?

I have some problems importing a Java project into my workspace. I am following this tutorial - however I can not use the final Import existing projects step because the GIT repository I use does not include the Eclipse specific .project and .classpath files.
Use the New Projects wizard
Therefore the project is not recognizes as project and hence can not be imported. Therefore I tried my luck using the option Use the New Projects wizard and select "Java Project" in the next dialog. The problem is that this creates a new Java project without any content!
The project is also not connected to the GIT repository.
Edit: This is a known bug of eGIT: Bug 324145 - Project import doesn't work for abitary project types - if you want this problem fixed vote for it...
Import as general Project
If I use Import as general Project Eclipse always wants to use the external repository directory as project directory which is not what I want and additionally the created Project is not Java-enabled.
Therefore I am asking why it is so complicated to import a Java project into Eclipse using eGIT?
It is possible by first cloning the repository and then creating a General project based on that. Then you can convert it to Java project. Here is how:
First go to File>Import...>Projects from GIT.
In the Select a Git Repository view you first press Clone. And follow instructions. This will create a local "checkout" of the repository to your computer. You can set the folder to be your workspace so it looks like any other of your eclipse projects.
After you have cloned the repository you get back to Import-view. Now you can select the repository you just cloned from the list.
Click Next and select Import as General Project. Now you have a git repository to eclipse.
Convert it to Java project: Add nature and buildCommand elements from other Java project to your .project file:
Relevant sections from .project:
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Then from Project>Properties>Java Build Path>Source add your source folders (and possible libraries).
Edit: Added the conversion to Java project.
With Git (especially EGit) your 2 best options are:
1) Create a java project in eclipse, and then create a linked folder to where the source lives in your git repository (mentioned by #mattb). I don't think EGit will connect to your git repo easily in this mode, but your eclipse specific project files will be in a different location than your source tree.
2) Create your java project and let it point to the external git repo (which you mentioned). It will create a .project and .classpath file where your source lives. Then using Team>Share Project will allow you to connect EGit to the already existing git repo.
Option 2 (which I use) allows the tools to work with java projects in a git repo reliably.
May not be applicable to your project but if you are using Maven in the project, you can import it as Maven Project from Eclipse if you have m2e installed, this way all the needed files like .project, .classpath will be generated. I think that is a good approach because if your pom.xml is well-written, it can contain all the needed information about the project such as build target directory, classpath, java version etc., and it will probably work with most of the populer IDEs.
I suggest to get used to use Maven on every java project, even for a simple hello world application because I see it as some sort of "standardization" for Java projects.
Create a new project in eclipse and just point the source directory at the existing sources, rather than the default path.
here I saw all methods to import a non eclipse project into eclipse(open source git projects into eclipse) ... no need to copy .project or .classpath file to copy ... here is the step by step process-
Step 1. import the project from git. Paste the URL and import the project as a general project.
Step2. If you want to import it as a maven project you should have m2e plugin installed in your eclipse(eclipse marketplace).
Step3. Now we should convert this general project into eclipse project.So right click on project ->properties->ProjectFacets. click on ConverttoFacetedform
Step4. Now if your project is a web project.See the left side window.. there is an option DynamicwebModule ... check it (leave it if it's not a webproject).... On the rightside window .. go to runtimes tab. Now check the server and JDK version both.. apply Ok.
Step5. If it's a maven project .. then right click on project congigure->convert to maven project->Finish
Steps:
Import project as a normal git project
Right click on the project and select Configure -> Convert to Faceted From
Now Select Faceted whichever you want to choose for simple java project just select Java from the Check box List
you can add more configurations based on your requirement under runtime tab on left and under "Further configuration available.." link below the pane. you can skip this step if no additional configuration required and you just need a simple java project.
click on apply and then apply and close.
It will convert your simple git project to simple java project of Eclipse.
-- Happy coding :)

How do you include source file/code when sharing a Project with SVN Eclipse?

I downloaded and installed the latest SVN plugin for Eclipse. I have a Project that I want to Share. I right-clicked on my Project's name, selected Team --> Share Project. This worked like a charm and all my files were checked into the repository. However, I noticed that my Java source code was not included in the repository. In my Eclipse project I have the Java Build Path linked to a separate folder. I like to keep my source code in a separate directory. How do I get SVN to recognize and add this folder to the repository?
Thank you for all your help and advice.
my understanding is, that the folder you would like to add is not a sub-folder of the root folder of your project. In that case, you may find an answer in svn externals:
http://svnbook.red-bean.com/en/1.5/svn.advanced.externals.html

Categories