importing a project from Perforce Eclipse Plugin as Java Project - eclipse

I am trying import a project from Perforce workspace in Eclipse. It is importing it (fetching the files into java package hierarchy) but the problem is it is not importing as "Java project". so i can't edit the "Build path" or there is no classpath or something.
Any idea?

You need to make sure to put Eclipse metadata files into your source control system. All files starting with . in the project root along with entire .settings directory need to get checked in along with your source. If you don't do that, Eclipse will loose all knowledge of the type of projects that it is and how it supposed to be configured.

If your Project in Perforce do not contain files of regular Eclipse java projects you can create another project with Java Nature. Keep Project empty.
File > New > Java Project
It will create for you following files.
.classpath
.project
.settings/org.eclipse.jdt.core.prefs
With this empty project by default your source folder is set to "src".
Now you have to copy first two files mentioned above to your Perforce workspace directory. Close and reopen project.
If you still have issues please check file .project. It should contain Nature section.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Dev-Project_03_04_2016</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Now Check your .classpath File. Since you copied it from blank project it contains something like:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
You need to remove this default default "src" folder and add your source folders, of course if you wont do development in eclipse you do not need all this. If you did everything correctly, andded also JUnit Nature you wil get something as follows:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911emergencydriver-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911accessmodel-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911accessplugin-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Related

After git clone src folders appear to be just folder instead of packages in Eclipse ubuntu

I am using Eclipse IDE with selenium, testng, Java on Ubuntu machine to automate test cases.
I committed a fresh new Project into Git and when on another machine by doing a git clone and importing the project. src folder which is source folder appears to be just a folder including the packages inside src folders.
How can i configure the project in such a way where after git clone and importing the project the src folders are intact and they appear to be src folders instead just folders.
Ecl;ispe IDE verison
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2021-06 (4.20.0)
Build id: 20210612-2011
.Project content
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SeleniumTests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
.classpath content
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
It is a multi maven project

Eclipse project missing required library that is not a dependency

I'm using Eclipse version 2019-03 (4.11.0) and I have a project with a big red exclamation mark to the left of the project name. I am not using any dependency management tool, I am managing my dependencies myself manually. The Problems view is telling me that my project is missing a required library, but that jar file is no longer in my list of dependencies for the project (I replaced it with an upgraded version recently, and the problem has existed since then). In case this was a GUI issue I checked the .classpath file for the project in a text editor and it's not listed there. I've also tried cleaning and re-building the project.
This problem is masking compile error and warning icons over the source files in my project. Is there something obvious I've missed? (before I attempt to recreate the project from scratch).
The error listed under the Problems view is:
Project 'MyProject' is missing required library: '/home/me/eclipse-workspaces/work/MyProject/xyz.jar'
The Location is Build Path and the Type is Build Path Problem.
Here's an edited version with the relevant stuff in my .classpath (the supposed missing jar is NOT listed in this file):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/home/me/eclipse-workspaces/work/MyProject/somelib.jar"/>
<classpathentry kind="lib" path="/home/me/eclipse-workspaces/work/MyProject/anotherlib.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Enki-Utils"/>
<classpathentry kind="output" path="bin"/>
</classpath>
The only other Eclipse related file in my project root directory is .project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyProject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
The solution for me was to close and re-open the project (without restarting Eclipse) which must have flushed out some stale cache. The accepted answer for this question got it for me (with some other possible solutions if that doesn't work).

Eclipse IDE internal project representaion

Currently I'm trying to write a tool for migration from Eclipse IDE to Intellij Idea specifically for my project.
For now, the main question is how and where Eclipse store project information (i.e. libraries, dependencies between app modules and so on) internally.
P.S.
The Intellij's migration tool does not work for my project.
Update:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry excluding="generated/" kind="src" path="src"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Everything that eclipse keeps on your project is stored in the .settings folder (containing a.o. .project and .classpath).
But unless you have some very specific setup you should be able to import your project into IntelliJ without any hassle. Even if it's not, I would expect that setting up the project manually in IntelliJ will be a lot faster than writing a tool for it.

Add Aspectj Runtime Library to project via .classpath file

I have a python script that downloads the latest svn build, then converts the project to an aspectj project and adds the necessary libraries , except for the Aspectj Runtime Library. I have my script trying to add the library in to the .classpath file like so: <classpathentry exported="true" kind="con" path="/Users/rovimacmini/.m2/repository/org/aspectj/aspectjrt/1.8.0/aspectjrt-1.8.0.jar"/> but I get an error that the aspectjrt.jar isn't in the classpath. Does anyone know how I can add it via the .classpath file so that my java build path has the AspectJ Runtime Library in it like so:
I suggest you manually create an AspectJ project in Eclipse and just look at how Eclipse does it.
.project needs an 'ajbuilder' and an 'ajnature':
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AspectJ_Project</name>
<comment></comment>
<projects></projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
.classpath needs a container ("con") classpath entry for the AspectJ runtime:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Update: I also tried replacing the container entry provided by AJDT by a direct reference to a manually installed library in my local file system like this:
<classpathentry kind="lib" path="C:/Program Files/Java/AspectJ/lib/aspectjrt.jar"/>
It works nicely. So in this case it is not con, but lib type. In my experience it also is not necessary to set the exported property, you can just skip that one.

How to convert eclipse java projects into groovy projects?

I have set of ten to twelve native java projects checked out from svn. Eventually I am considering to convert all the code into groovy. I am only concentrating on these two steps first:
1) Convert java projects to Groovy projects
2) Change the extensions of all the 10,000 odd files in all the projects to .groovy.
So I want to know if eclipse can provide me some help with these two steps (via UI) without me having to change all the .classpath entries or .project entries.
PS: I already have the groovy plugin installed
Are the java projects also Maven projects? That creates a bit more confusion, but is workable. You should be able start by editing the .classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/someDirectory"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
This is for a Maven and Groovy project. You can leave out the Maven line if it is not needed. Eclipse doesn't seem to like Maven+Groovy projects, so you will have to fix the .classpath again after you import it, but it won't change it again after that.
I'd recommend using a batch file for the renames (or a C# program, if you have VS installed, too).
I found this example: https://superuser.com/questions/205083/which-command-can-i-use-to-recursively-rename-or-move-a-file-in-windows
For loops are a bit odd in batch files, but they work nicely.
I think that would get you going. Start with the smallest project, of course!