Change Eclipse Project Settings programmatically - java

I have a rather big project with about 30 seperate subprojects hosted on subversion. If I want to set up the project on a new client, i have to check out 30 projects (each time manually selecting the trunk), then change the eclipse facette for each project and then convert every project into a plugin project. Finally I have to build the project using maven.
Is there an easier way to do this? Perhaps some kind of API provided by eclipse which allows me to change project settings without fiddling with the .settings and .classpath files?

It sounds to me that you are missing some of the project metadata files from your source control system. There should be no reason for performing these steps every time you pull down these projects.
Check to make sure that all files starting with '.' in project root are in source control along with the entire contents of the .settings directory.

Related

How do I build and run an existing project in Eclipse?

I would like to start the program from this repository: https://github.com/SaifurRahmanMohsin/Personal-Diary but when I dowload it and open the project in Eclipse I am not able to build/compile it. So i also can't run it.
Do I have to change run configurations or build a working set or something like that? I usually don't work with Eclipse so I am a bit overwhelmed.
screenshot eclipse1
screenshot eclipse2
Check out. Delete the files .project, .classpath, and folder .settings before you import because those hold data unrelated to your system.
File, Import, Project from existing sources
Pick the inner Personal Diary folder, not the repo folder
You will need to download two libraries to add to the classpath
JSON-Simple and Apache HTTP Client

where does the Intellij IDE store the artifacts settings of one project

I am using Git in Intellij. Every time I change git branch, my artifacts settings is gone, so I have to reset the settings.
I want to get the file which stores the artifacts settings, So I can put the file in when I switch the branch to avoid resetting the artifacts.
I wonder if there is a file storing the artifacts settings.
Another question btw, I want to package a war in Intellij, but the automatic way always lose some files, so I set the artifacts manually. I wonder if there is one way to package the war better.
Thanks for your any suggestion or help.
The settings are stored in .idea/artifacts directory (inside the project root directory). You may consider sharing it via the version control.
You can put war file by:
Go Project Structure -> Artifacts -> choose Output Directory.

Eclipse: how to properly integrate a Maven/Ant project into a larger one?

I have a Java project that depends on a 3-rd party component. This component is available both as a jar and as a Maven/Ant project. One option for me is to simply add the jar as a library. However, I prefer to add the source code into my project since I may need to slightly modify their source code to better suit my needs.
What's the right way to do it in Eclipse?
My main project has a simple structure: src/ and lib/. The external component also has a standard structure: src/, test/, build/, target/, pom.xml, build.xml. So do I need to copy piece by piece (like contents of one src/ into the other src/), in which case what goes where? Or do I somehow copy it all at once? Or smth else?
The best way would be if you use maven on your projet for dependency management. This way, if you have the other projects open in eclipse, your project will resolve them as local projects, but if you don't, maven will try to fetch the jars from the configured nexus repository.
This way, you avoid having to manually configure your Eclipse projects. Maven will be able to configure your project anywhere you want to build it, not having to manually configure dependency resolution.
Import both the projects into eclipse. Add the reference of 3pp jar project to your project as a reference by clicking on Add on build path option. While delivering it as output there will be a dependency to the 3pp jar project. So either deliver it as separate jar and add it to classpath while executing your project else you have to copy the entire source files into your project and deliver it test complete jar.
Making a jar will be handled by eclipse itself.

Eclipse java libraries

I'm kind of new to Eclipse and I'm hating it so far
The question is I'm working on a small project with some classmates, we are using Eclipse and Git but every time someone does an immport all the libraries are lost because they are referencing the computers path like C:/someone/something.jar and then someone else push something to github and the libraries path C:/someone2/somthing.jar
Every time, I and my partners have to search for the libraries on our pc so the errors stop appearing.
Is there an easier way so we don't have to lose time searching for the libraries on our pc?
You need Java build tool like Maven, Gradle to manage your dependencies.
In that way, it will resolve the libraries for you. And in the source code, you should not check in .classpath,.project meta files. Those files should be added into .gitignore to avoid commit.
To import projects into IDE (Eclipse in your case), Maven and Gradle can help you to generate those IDE meta files. Or some Eclipse plugins could be used to import maven or gradle project.
You should create a folder for libraries and put all jar files in there, add these files to classpath using Java Build Path Option from project properties. Also add this folder to git

Update Eclipse project type through a script

I have inherited an old java project, where different team members are using different development tools; some use emacs, some netbeans, I use eclipse. Hence when this project is checked into the version control, it's just a bunch of java files and ant build files.
Every time there is a new branch or so, I checkout the project in my eclipse through subclipse plugin and generate some dependent jars, put them in classpath, then set up the source folder etc etc. This is becoming very tedious as I help out others with same configuration if they're using eclipse. Is there a way I could have some script which I can run on the project to convert and restructure it to an eclipse project?
You could have the Ant build create the .project and .classpath files for you. I've done this myself with the XMLTask suite, since those files are just XML documents. Add them to the svn:ignore property so your twitchy teammates don't get upset.
There appears to be an old ant task that does this for you, but I haven't used it myself.

Categories

Resources