Thursday, March 26, 2009

Developing for Archimedes

Hello,
With the new team working on Archimedes, I had to help them set up an environment to work with Archimedes. I am pretty proud of the outcome.
In order to code for Archimedes, just follow these steps:
  1. Download and install a Java Virtual Machine S.E. SDK version 1.5 or later compatible with the Sun virtual machine (I suggest sun's one called 'Java SE Development Kit (JDK)' under http://java.sun.com/javase/downloads/index.jsp).
  2. Install Subversion (http://subversion.tigris.org - or "sudo apt-get install subversion" on debian based linux distributions or "sudo port install subversion" on Mac OS X with MacPorts).
  3. Download an Eclipse version above 3.4 (I suggest the one found at http://download.eclipse.org/eclipse/downloads/drops/R-3.4.2-200902111700/ - Eclipse SDK for your platform should be enough). Make sure it has all of the Eclipse RCP plugins. If you pick another version, choose the package Eclipse SDK or the specific build for Eclipse Plug-in Development.
  4. Install it on your system. It usually just involves unpacking the zip or tar.gz file you downloaded.
  5. Open it. Usually, just enter the folder that was created on the previous step, there should be an executable called 'eclipse'. Run that executable.
  6. Install subclipse. Go to "Help"->"Software Updates...". Select the tab "Available Software", click on "Add Site...". Fill in the "Location" field with "http://subclipse.tigris.org/update_1.4.x" (if you installed version 1.6 of Subversion, you can use "http://subclipse.tigris.org/update_1.6.x"). Click on OK. It should list the site on the table with the name "http://subclipse.tigris.org/update_1.4.x". Click the checkbox next to it. Click on the button "Install..." on the upper right corner. Accept the license and let it install. Once it's done, it will ask you to restart Eclipse. Please do.
  7. Download the file "http://svn.archimedes.org.br/public/mainarchimedes/rcparchimedes/br.org.archimedes.config/trunk/ArchimedesProjectsSet.psf". Save it somewhere you can find.
  8. Go back to Eclipse and go to "File"->"Import...". Expand "Team" and choose "Team Project Set". Click "Next". Click "Finish". It will download all the projects needed to work on Archimedes. This will take some time and a lot of bandwith. If you get an "Svn error", please erase all projects and try again.
That's it. Once you've done that, you should have about 100 projects for Archimedes. If you are getting some compile errors ("there are red signs on the projects"), try changing your Java default compile version. To do so, go to "Window"->"Preferences..." (or "Eclipse"->"Preferences..." on Mac), type 'compiler' , select the "Compiler" item on your left pane, change the "Compiler compliance level" to "1.5". It should rebuild the project and remove the compiler errors.

Running Archimedes from within Eclipse should be pretty simple but I've found problems more than once. Here is what you should do:
  1. Find the project "br.org.archimedes.core", expand it. Find the file "archimedes.product", right-click it, "Run As..."->"Eclipse Application". On Mac, that's enough. It all works. On Linux, I've found that this doesn't select all plugins needed. It then pops an error dialog asking if you want to view the log. Answer "No".
  2. Go to "Run"->"Run configurations...". Select the tab "Plug-ins". Click the button "Add Required Plug-ins". Click "Apply" and then "Run". This should do the trick and run Archimedes with all plug-ins.
Ok! This should be enough to work on Archimedes and try your modifications. Last and final step to have a complete Archimedes environment: setting up the build system. This also got greatly improved. The following steps should be enough:
  1. Download an Eclipse version along with its Delta Pack. I suggest you use the same version on development and on building to avoid unpleasant surprises. Therefore, go to http://download.eclipse.org/eclipse/downloads/drops/R-3.4.2-200902111700/ and download "Eclipse SDK" for your platform and "Delta Pack". Extract both files on the same place (it should merge the contents). This means, if you enter the "eclipse/plugins" directory of that new eclipse path, you should find plugins for all platforms (such as "org.eclipse.swt.carbon.macosx_3.4.0.v3448f.jar", "org.eclipse.swt.gtk.linux.ppc_3.4.0.v3448f.jar", "org.eclipse.swt.gtk.linux.x86_3.4.0.v3448f.jar",
    "org.eclipse.swt.win32.win32.x86_3.4.0.v3448f.jar" and others).
  2. Go to your "br.org.archimedes.build" project. Open the "build_local.properties" file. Change all fields. "buildHome" should be the absolute path to your "br.org.archimedes.build" project. "buildDirectory" should be the absolute path to a temporary folder where the build will generate the files. Make sure this is not a folder where you store important files because the build system will erase it. "eclipseDir" should be the absolute path to the Eclipse installation created on step 1. "os" should be the name of your operating system ("linux", "macosx" or "win32"). "ws" should be the name of the widget system of your system ("gtk", "carbon" or "win32"). "arch" should be the architecture of your processor ("x86", "x86_64" or "ppc").
  3. Go to your "br.org.archimedes.build" project and open the folder "maps". Copy the file "all-hugo.map" to "all.map". Open the new "all.map". Replace all occurrences of "/Users/night/Document/Archimedes/" with the path to your workspace (for example "/home/night/" if my workspace if "/home/night/workspace").
  4. On Eclipse, right click the "build.xml" file on "br.org.archimedes.build" project and choose "Run As..."->"Ant Build". On other systems, open a terminal (or cmd.exe), go to the directory where you "br.org.archimedes.build" project is and type 'ant'. If "ant" is not installed, please install it (http://ant.apache.org/manual/install.html or "sudo apt-get install ant" for debian based linux distributions). This should trigger the build process. It takes around 5 minutes to build it all.
On the folder you specified for "buildDirectory", you should find a folder "results" that contains several files. Among them, "Archimedes--...zip" files for macosx, linux (x86 and x86_64) and windows. Those are your executables.

Happy hacking!

6 comments:

ukaliko said...

Cara muito massa o projeto. Parabéns pela iniciativa.
Tava procurando um software em CAD open source,
escrito em Java e achei o Archimedes.
Apesar de, no blog ter informação só pra ingles ler...rsrs.
Achei muito interresante a ideia, e se tiver algum site em Portugues sobre o Archimedes, posta o link ai.
Assim que tiver um tempo vou baixar o projeto e dar uma olhada, fazer uns testes.
Trabalhei com o AutoCad 8 Anos, hora programando em AutoLisp, hora desenhando, hoje sou programador Java,
Mas baixei o Archimedes e rodei, e confesso que quase me senti em casa, igual quando trabalhava
com AutoCad. Achei o Archimedes muito bom, perto de outros CAD Open Source
e bem proximo do AutoCad, este projeto tem futuro, esta no caminho certo.

Um forte abraço!

Hugo Corbucci said...

Obrigado.
Se tiver qualquer problema, mande-me um email ou poste algum comentário. A maior parte das atividades acontece no nosso site do sourceforge: http://sf.net/projects/arquimedes/

ukaliko said...

Olá Hugo!! Blza!!.
Baixei o arquivo Archimedes-0.64.0.Shortcuts-sources.zip,
mas depois de importar os projetos do Archimedes no eclipse,
vejo que os arquivos abaixo estão faltando;


import br.org.archimedes.exceptions.InvalidArgumentException;
import br.org.archimedes.exceptions.NullArgumentException;
import br.org.archimedes.intersector.circlecircle.CircleCircleIntersector;
import br.org.archimedes.model.Element;
import br.org.archimedes.model.Point;
import br.org.archimedes.Tester;
import br.org.archimedes.exceptions.InvalidArgumentException;
import br.org.archimedes.exceptions.NullArgumentException;
import br.org.archimedes.model.Point;

onde eu os encontro, ou tem jeito de vc postar ai, pra download??

Valeu! um abraço.

Hugo Corbucci said...

Estranho!
A maioria desses arquivos deveria estar no projeto br.org.archimedes.core.
Vou dar uma olhada sobre como as coisas são empacotadas para descobrir porque essas coisas estão faltando.
De toda forma, é provavelmente melhor se você baixar o arquivo do "Team Project Set" como está explicado no post. Ele vai baixar os projetos do SVN: http://svn.archimedes.org.br/public

Você pode pegar esses arquivo nesse repositório de Subversion.

ukaliko said...

blza...vou tentar baixar do subversion!.

peedu said...

Done at a clean win7 install:

1) Installed JAVA SE SDK 1.6 from sun page, link referred from guide. jdk-6u18-windows-i586
2) Installed Subversion: CollabNetSubversion-client-1.6.6-4.win32
3) Set up a bat to initialize bat files:
3.1) JAVA_HOME to JDK root
3.2) JDK bin directory to path
3.3) ANT_HOME to ANT root in eclipse plugins directory
3.4) ANT_HOME\bin to PATH
4) Installed 3.4.2 Eclipse SDK: eclipse-SDK-3.4.2-win32.zip;
4.1) Installed to /Hack/eclipse; Workspace: /Hack/workspace
5) Installed 3.4.2 RCP SDK through "software updates and addons": 3.4.200.R342_v20090122_989JESTEbig*
6) Performed the Subversion update procedure described in the guide, for subversion ver 1.6.x
7) Performed the team version download through subversion in eclipse
8) Did the "Add required plugins" operation through the run configuration and as such the archimedes.core app runs.
9) Downloaded and extracted to eclipse directory the delta pack: eclipse-3.4.2-delta-pack
10) Updated the build_local.properties file:
10.1) buildHome=/Hack/workspace/br.org.archimedes.build
10.2) buildDirectory=/Hack/temp
10.3) eclipseDir=/Hack/eclipse/
10.4) os=win32; ws=win32; arch=x86
11) Renamed hugo.map > all.map;
11.1) Replaced: /Users/night/Documents/Archimedes/workspace with /Hack/workspace in every occurence in the file
12) Tried to build: Error caught on error:
12.1) Expanding: C:\Users\night\Downloads\eclipse-platform-3.4.2-macosx-carbon.tar.gz into C:\Hack\temp\testhost
12.2) Apparently br.org.archimedes.build/build-files/automatedTests/run-stests.properties references to the /Users/Night... directory where the eclipse-platform-3.4.2-macosx-carbon.tar.gz file is supposed to be. It turns out it's osx eclipse runtime.
12.3) Will download eclipse-platform-3.4.2-win32.zip and add it to /Hack and update the reference
13) Tried to do another ANT Build of the main br.org.archimedes.build project
13.1) Great Success!:)