I use eclipse to work on an application which was originally created independently of eclipse. As such, the application's directory structure is decidedly not eclipse-friendly.
I want to programmatically generate a project for the application. The .project and .classpath files are easy enough to figure out, and I've learned that projects are stored in the workspace under <workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects
Unfortunately, some of the files under here (particularly .location) seem to be encoded in some kind of binary format. On a hunch I tried to deserialize it using ObjectInputStream - no dice. So it doesn't appear to be a serialized java object.
My question is: is there a way to generate these files automatically?
For the curious, the error I get trying to deserialize the .location file is the following:
java.io.StreamCorruptedException: java.io.StreamCorruptedException: invalid stream header: 40B18B81
Update: My goal here is to be able to replace the New Java Project wizard with a command-line script or program. The reason is the application in question is actually a very large J2EE/weblogic application, which I like to break down into a largish (nearly 20) collection of subprojects. Complicating matters, we use clearcase for SCM and create a new branch for every release. This means I need to recreate these projects for every development view (branch) I create. This happens often enough to automate.
You should be able to accomplish this by writing a small Eclipse plugin. You could even extend it out to being a "headless" RCP app, and pass in the command line arguments you need.
The barebones code to create a project is:
IProgressMonitor progressMonitor = new NullProgressMonitor();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("DesiredProjectName");
project.create(progressMonitor);
project.open(progressMonitor);
Just take a look at the eclipse code for the Import Project wizard to give you a better idea of where to go with it.
Use AntEclipse
It can create eclipse projects from ant.
To create java project you can use JavaCore from org.eclipse.jdt.core.JavaCore. As a sourceProject you can use generic project item, which has been suggested by #James Van Huis
IJavaProject javaSourceProject = JavaCore.create(sourceProject);
Related
I recently tried to add the google tink library to eclipse and it always has a "com.google.protobuf.GeneratedMessageV3$ cannot be resolved" error, I normally never have any problems with adding libraries to my project, and from what I can tell it has something to do with the all key template files since the error only occours when I try to generate a new KeysetHandle with any key template, and the error only starts when i enter in the key template file# https://github.com/Gameidite/testProject
The Protobuf library can generate Java classes for you. You need to find where these .class files have been output to (eg there should be a GeneratedMessageV3$.class somewhere) and make sure that they are included on your classpath. There's presumably somewhere in Eclipse where you can configure where it looks for class files - you'll need to add the generated files there.
If the generated class files don't exist yet you need to figure out what to do to generate them. It might be easier to use Maven or Gradle as suggested in the Tink documentation rather than directly adding things to Eclipse.
I think it's probably because Eclipse cannot find the protobuf Java runtime. Have you tried adding Tink to your project with Maven or Gradle?
I have a HelloWorld Java app called FitnessTracker that I want to clone as another name, FDE3, leaving the original website in tact. I performed the following steps an attempt to do this. Please tell me where I went wrong and/or what else I need to do.
Change Context Root
Confirm Change Context Root
Still the original "FitnessTracker" name persists and I'm not sure how to get rid of it.
If I was able to successfully clone the FitnessTracker webapp as FDE3, I should be able to access the new site as
http://localhost:8080/FDE3
But I get an invalid resource error. Instead, the site is still accessible as
http://localhost:8080/FitnessTracker
..because of reminants of the old name.
What do I need to change within Spring Tool Suite to get the web app to use only the new name? To minimize chance of corruptying the project, I'd rather do it via the STS GUI over manual modification of any system file.
I see that the following file contains the text "FitnessTracker" but I would rather not modify it manully for fear of breaking. What GUI option controls this?
Search "fitnesstracker" (2 hits in 1 file)
C:\Dev\Workspace\FDE3\.settings\org.eclipse.wst.common.component (2 hits)
Line 2: <wb-module deploy-name="FitnessTracker">
Line 7: <property name="java-output-path" value="/FitnessTracker/target/classes"/>
Sorry for being a noob.
Update:
I'm not sure what I did, maybe just clean, refresh, open/close a million time, dunno, but now when I run the web server from with the Spring IDE the site is coming up using the FDE3 path, however, I am wondering why I see a reference to Fitness in Parens in the project node.
Earlier, it just displayed "FitnessTracker" in parens, now I see a full path to a Test folder...
Update 2:
When I copied the FitnessTracker project as FDE3, I didn't expect that the new FDE3 project would have any ties to FitnessTracker project and I didn't think that the new FD3 project would be in SVN until I added it to SVN, but based on the icons I see below, it looks like it is, (I'm new to SVN, too)
It looks like my issues are related to SVN.
Why is there a tie to the original FT project and why? How should I have clone the FitnessTracker project?
Yes, your issue is indeed related to SVN. Copying an SVN working copy will copy .svn folders inside that and will be pointing to the same URL in the SVN repository. What you have to do is an SVN Export of your FitnessTracker project to FitnessTracke-Ex first in either Tortoise or Subclipse SVN client and then import that project into your STS Eclipse environment. Finally you can copy and rename the FitnessTracke-Ex project FDE2 or FDE3
See this
post on how to Export a working copy
See this post on how to Import an existing project into Eclipse
Hello guys I am new to programming.
I used NetBeans first but didn't like the UI.
I switched to IntelliJ.... but while creating forms in Netbeans some code was auto generated like the button info etc etc.
I would like to have the same in IntelliJ but can't find this feature anywhere. Can you guys please help me?
Most likely the generated code made by NetBeans vs IntelliJ will be different, and there isn't much you can do about it. By default IntelliJ will not create actual code for auto-generated UIs, but instead will create binary files that will directly create a class file for a UI class at compile time. You can modify this setting, however it does not guarantee that it will be the same as what NetBeans generated, or that it will be parsable for use in IntelliJ's swing designer, so just be aware.
To answer your actual question though you can change from binary files to generated Java source files via the following:
File -> Settings -> Editor -> GUI Designer.
Modify the item named "Generate GUI into" and set it to Java source files.
Take a look at this section of the IntelliJ manual: https://www.jetbrains.com/idea/help/gui-designer.html
I hope my question will be clear enough as I am not used to Eclipse environment.
My goal is to create a project in Eclipse with an already existing EMX file. I gather that file from a Git repository.
And I would like to create a command line (or a script, or anything I can run automatically from remote) that imports that EMX file into Eclipse, so I can use another script (already created) to work with this EMX.
My problem is that I don't know how to create this script or command line.
I've tried solutions found here at StackOverflow, without success. Maybe I'm just bad :p
As I am beginner in Eclipse stuff, if someone has a link to a clear tutorial or working example, it would be very nice.
Note: I just have the EMX file (no .project or whatever). So I guess I need to create a project with this file, and not just import an existing project.
Thank you very much for your help :)
Laurent
I finally managed to do what I wanted by creating a plugin which imports projects from a given path into my current workspace.
Main part of the code is from: http://code.google.com/p/headlesseclipse/source/browse/branches/JUnit/com.ind.eclipse.headlesseclipse/src/com/ind/eclipse/headlessworkspace/HeadlessProjectImport.java?r=88
I did not find any way to do this outside the plugin. Grovvy solution was giving plenty of errors and without CDT, the first simple solution I looked for was not available.
I want to identify the type (java/c/...) of the currently selected project from an Eclipse plug-in; If possible some other information also (used libraries and what not), basically all the information surrounding the project.
I have been searching on google and here for a couple of hours now, to no avail. Can i even access the information i want without selecting some bogus Extension Point (none of the ones listed seem to fit what i want to do)? I mean, i don't want to actually add anything to Eclipse right now, i just want to print out that stuff into the console. (start small and stuff)
Sorry for the long rant, but i don't know how to better express my problem right now.
A lot of this information is stored in the .project file in the project folder. The correct way to access the information is via the IProject object for the project.
The IProject.getDescription method returns you a IProjectDescription containing information about the project.
To determine the type of project you need to look at the natures that are defined in the project description. The IProjectDescription.getNatureIds() method returns an array of the nature ids. A Java project will have the org.eclipse.jdt.core.javanature and a plug-in will have org.eclipse.pde.PluginNature (and a Java plug-in will have both these natures).
To find the IProject. If you have a selection in something like Package or Project Explorer try:
IResource resource = (IResource)Platform.getAdapterManager().getAdapter(obj, IResource.class);
or
IFile file = (IFile)Platform.getAdapterManager().getAdapter(obj, IFile.class);
the getProject() method of these interfaces gives you the IProject. You may also just be able to do:
IProject project = (IProject)Platform.getAdapterManager().getAdapter(obj, IProject.class);
Platform in the above is org.eclipse.core.runtime.Platform (there are other Platform classes in Eclipse so be sure to get the correct one).
If you just have a project name then use:
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);