Info | ||
---|---|---|
| ||
This page documents the usage with Gradle, the pre-Gradle documentation is here: Eclipse Tips (pre Gradle version) |
Warning | ||
---|---|---|
| ||
Before any interaction with OFBiz in Eclipse be sure to run "gradlew eclipse". This generate the information Eclipse needs about the OFBiz project. |
Children pages
Children Display all true sort creation
Table of contents
Table of Contents |
---|
Useful tips for Eclipse
Top 10 Tips For New Eclipse Users
An interesting link to hide the jar files from the left section of the files in the Eclipse IDE
Periodically clean caches and history to avoid Eclipse ‘rot’
If you still use an old version, don't forget to turn on Eclipse's memory monitor, use Window -> Preferences -> General -> Show Heap Status.
Most important shortcuts
- CTRL+SHIFT+R for finding resources!
- CTRL+H for finding text in files
...
- The rest you will find on Internet
...
Setting up Eclipse to work with OFBiz is easy.
There are two ways to import OFBiz into Eclipse:
- You can either allow Eclipse to download OFBiz directly from SVN,
- or you can import an already downloaded copy of OFBiz (from SVN or otherwise) from the filesystem.
Importing OFBiz from the filesystem into Eclipse
If you have already downloaded OFBiz and do not wish to have Eclipse handle SVN pulls for you, Eclipse can import OFBiz from the filesystem as well. OFBiz includes a
First you need to generate the ".project" file to allow Eclipse to automatically configure the project for you. For that simply run "gradlew eclipse" on the command line.
Then This means that if you have already downloaded the code (from SVN or otherwise), all you have to do to import the project is:
- Right-click in the Navigator window and click on Import.
- Select "Existing Project into Workspace" and click Next.
- Click Browse and select the directory that contains the ".project" file, then click Finish. When this is complete, a new project named "ofbiz" will now appear in your Navigator. This will not copy the project to Eclipse's workspace directory: it will remain wherever it was before the import. If you want the OFBiz files in your workspace directory, you must move them there before you do the import.
...
- Note that by doing so you will not have the the plugins inside your ofbiz project. If you want that, follow the info in the "Setting up Eclipse to work with OFBiz is easy" section above.
Building OFBiz with Ant from within Eclipse
You will next need to build OFBiz with Ant. To do this, go to the Navigator panel and do the following:
- Click the "+" next to the ofbiz project.
- Right click on the "build.xml" in the root of the ofbiz project and select "Run Ant..."
- The defaults are fine for the initial build. Click Finish. If you get the following error message:
javac[ BUILD FAILED: file:<Project Dir>/build.xml:32: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK. See the instructions for modifying the Eclipse JVM below.
...
Using SVN from within Eclipse
If you want to do the SVN pull from within Eclipse, use the following steps:
- First you need to install Subclipse
- see Installation Instructions for Eclipse 3.x Then connect to the repository:
- Bring up the "SVN Repository" panel in Eclipse (Window/Open Perspective/SVN Repository Exploring)
- Right-Click within panel/New/Repository Location
...
Pick the URL of the one you are interested in at http://svn.apache.org/repos/asf/ofbiz/
eg: http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk
...
- /
- Click on Finish. Now, do the initial checkout
...
- .
- Click the "+" next to the new repository
...
- then Right-Click on trunk and select "Checkout...".
- Select "Check out as project in the workspace" and click on "Finish".
- This will create a new project
...
- that you can name as you want and download the OFBiz files directly from SVN. To sync your project with SVN in the future, right-click on the project and click Teams/Synchronize with Repository.
...
Additional Eclipse and OFBiz resources
Changing Eclipse's JVM
javac[ BUILD FAILED: file:<Project Dir>/build.xml:32: Unable to find a javac compiler;
If you have received the above error, you most likely have more than one JVM (e.g. a JRE and a JDK) installed. Eclipse uses the first Java VM it finds on your computer's PATH variable. In this case, it is most likely a JRE, not a JDK. Ant uses the same Java environment as Eclipse, no matter what you may specify in the compiler attribute. Because it is a JRE, you will not be able to compile.
To correct this, you must tell Eclipse to use the SDK. To do this, modify the shortcut you use to launch Eclipse and change the target to the following:
<ECLIPSE_DIR>\eclipse.exe -vm <SDK_DIR>\bin\javaw.exe
Original source: http://www.ryanlowe.ca/blog/archives/000386.php
Tuning Eclipse
For more on tuning Eclipse JVM heap size, you can refer to this IBM article
- Note that by doing so you will not have the the plugins inside your ofbiz project. If you want that, follow the info in the "Setting up Eclipse to work with OFBiz is easy" section above. Then of course import the project from the plugins directory inside the OFBiz project.
...
Using GIT from within Eclipse
You will need "Git Team Provider" package (integral part of many Eclipse IDE builds) for this to work. If not installed please check "EGit - Git integration for Eclipse".
- From the Eclipse main menu, choose: Window -> Perspective -> Open Perspective -> Other -> Git.
- In the "Git Repositories" window click the "Clone a Git repository" link or the "Clone a Git Repository and add the clone to this view" button from the view's toolbar to start git clone wizard.
- On the first page of the wizard, enter the location of the trunk remote repository, among
https://github.com/apache/ofbiz/ (freezed just before the framework and plugins split, 12 Feb 2017). You can use this one for releases branches.
https://github.com/apache/ofbiz-framework
https://github.com/apache/ofbiz-plugins
and click the "Next" button.
- On the first page of the wizard, enter the location of the trunk remote repository, among
- On the next "Branche Selection" page, choose which branches shall be cloned from the remote repository (by default all selected).
Example: Click the "Deselect all" button, choose "release16.11" branch and click the "Next" button. - On the "Local Destination" page, choose the directory where you want to store the repository on the local file system and click the "Finish" button.
If you want the OFBiz files in your Eclipse workspace directory, choose: Browse -> [/location/of/the/eclipse/workspace/directory].
Upon successful completion of the clone operation, the newly cloned repository appears automatically in the list of the Git Repositories perspective. - Open the terminal view from within Eclipse: Window -> Show View -> Other -> Terminal -> Terminal.
- In the "Terminal" window, click the "Open a Terminal" button from the view's toolbar (confirm with "Ok" in the "Launch Terminal" window) to start the terminal.
- In the terminal, open the directory where you stored the repository (i.e. /location/of/the/eclipse/workspace/directory/ofbiz) and run
./gradlew eclipse
(Linux) orgradlew eclipse
(Windows). - In the Git Repositories window, expand the ofbiz repository tree, choose: Working Tree -> right click -> Import Projects -> Finish.
After the import is finished your project is ready to be built, developed and debugged.
For more information about how to manage the repository please see EGit/User Guide - Managing Repositories.
Eclipse and Gradle
There are several Eclipse plugins for Gradle. In our experience they don't all provide the same level of features and quality. A good Eclipse plugin for Gradle is "Pivotal EGradle IDE" you can find it with MarketPlace and it offers almost all what you need.
Info | ||
---|---|---|
| ||
OFBiz has been split between framework and plugins. It's though still possible for Eclipse to handle the plugins inside the framework by embedding the ofbiz-plugins project inside the ofbiz (ofbiz-framework) project. That's interesting notably if you use Subclipse.
There is only one drawback. I you run "gradlew eclipse" (notably needed after a cleanAll), you need to redo the 3rd step. |
...
Hide folders from searches and hide some files when opening a file.
Most of the time you don't want to look into some folders because there is nothing interesting there and they sometimes annoy you because of search errors
It's also annoying to see *.class files when you look for a similar Java source.
Then you tool of choice is https://nodj.github.io/AutoDeriv/
For your convenience here is the content of the .derived file I set at the root of my workspace folder, YMMV...
# sets these folders as derived
.settings
bin
build
gradle
lib
runtime/indexes
runtime/catalina
runtime/data
runtime/logs/birt
runtime/output
runtime/tempfiles
runtime/tmp
runtime/uploads
...
Using local XSD's when no internet connection is available, or you are using another version than the one online
Eclipse uses XSD files to check XML files for correctness and also when using autocompletion. Normally, eclipse uses the XSD location specified at the top of the XML file which is usually a remote address. If you do not have an internet connection, the XSD will not be found and these features will not be available (unless they have been previously cached by eclipse).
The following documents describes how to setup local XSD resolution.
Eclipse OOTB
Eclipse + Oxygen see import section in XML Catalog Tutorial
At large, look for "eclipse xml catalog howto" in Google...
A new file ofbiz/ .catalog.xml has been introduced in OFBiz root starting from svn 1326499. This file contains a definition compliant with the Oasis Catalog specification of all schemas used by ofbiz. You can import it in you Eclipse workbench by following the explanation at the Eclipse Import XML catalog section (hint: use the Eclipse Import/XML feature). Note also that the platform:/resource notation is used to identify a resource located in the workspace. The next path segment after "resource" should be the name of a project, which can be followed by the folder and/or file we want to locate. So you might need to change the workspase name part of the path according to your real project name.
Setting "Save Actions" Preference
Here is a screen-copy of my setting of this feature which is unused by default
How to use Regular Expression for Search & Replace in Eclipse ?
When it comes to large changes, hand-coding is tedious and error prone. Using Eclipse regexp in S/R may then be the way. But be carefull, it takes a man to do an error and a machine to transform it in a cataclysm.
Here is an example of work done in OFBiz with S/R regexp
You don't need anything else than Eclipse 3.4+ version. The feature itself uses the standard java regular expressions and is actually fairly simple to understand. I would recommend to have a go at regular expressions before trying that feature. You may use these plugins Bastian Bergerhoff's Brosinski's to help your work. You may also use online tools like gskinner's or regextester to test the results. Another great read is also: http://java.sun.com/developer/technicalArticles/releases/1.4regex
Be aware that there are different types of regexp. So not all commands may work (luckily, eclipse displays the available commands on the input dialog)
Btw, a great one I use quite often is this:
Code Block |
---|
<TAG\b[^>]*>(.*?)</TAG> |
It'll grab the start and ending ending of a specified html tag. You can then use the select the inner element using $1