[GiM logo] gim.org.pl is down || odświeżony jogger (v.0.4) GiMa

Nice title, huh?
Descent plugin is being cooler and cooler, but you've probably seen it on videos.
One of the things that was driving me mad and kept me away from descent was compilation process.

Java guys probably know apache ant build system (and if they don't they definitely should). I'm going to describe here, how to force eclipse to use descent plugin's ant tasks to build D projects. I'm using this at least for a few months now and I prefer it much more over rebuild method described on Descent page, I was wondering why this method is not described there.

First there are some basic informations, how to install descent with eclipse 3.4, how to set-up a project, the rest is about ant usage.

Eclipse/Descent basic stuff

I'm using Eclipse ganymede since it's better than its predecessors. First quick installation for all the lazy bastards out there:

  1. Go and grab eclipse, I've downloaded IDE for Java Developers since it has ant plugins ready to use.
    (If you have eclipse installed already, you probably could just install apache ant stuff in software updates).
  2. Unpack and start eclipse, choose workspace, go to Help -> Software updates, Available software
    choose Add site and enter descent's site: http://downloads.dsource.org/projects/descent/update-site and OK, it should appear in the middle table, select it and Install,
  3. After few clicks and minutes Descent should be installed and Eclipse will ask you for the start, do so
  4. When it'll start again close the welcome screen, and first of all, turn on D-perspective (Window->Open perspective->Other->D), if it's not there it means you haven't installed descent plugin properly
  5. Next we'll add tango to user libraries to make project configuration simpler. Go to Window->Preferences, choose D->Build path->User libraries, choose New and enter meaningful name (tango? :>), choose Add directory and select directory with your tango lib (I got it under /opt/dmd/include/d),
  6. Go to General->Editors->Text editor->Spelling, and disable spelling engine, otherwise you'll get most of the code red-underlined :]

Now time for some fun stuff.
eclipse descent

  • Choose File->New->Project, select D project, enter name (I've used DSample) and you can click Finish,
  • Right click on your project, choose New->module, enter module name (I've used sample.d) (for simplicity everything will be in default package,
  • Now in editor window type 'main' and press Ctrl+Space (you'll love this shortcut ;)), editor should show suggestions, after hiting Enter you'll have basic main function,
  • If you try typing 'Std' [Ctrl+Space], you'll see there are no fancy proposals, right-mouse-click on your project, choose Build Path->Add Libraries, choose User Libraries, select tango (added in step 5) and click finish,
  • Now after typing 'Std' [Ctrl+Space] you should see some proposals

eclipse descent
Now let's play with ant..

Descent + ant, honey

One night I was playing with descent jar files and I've noticed interesting jar inside descent.core.
Open up your favourite terminal and extract needed jar.

  1. mkdir -p ~/.ant/lib
  2. cd ~/.ant/lib
  3. unzip ECLISPE_DIR/plugins/descent.core_0.5.3.20081231.jar ant_tasks/descent-ant.jar

ECLIPSE_DIR above is of course your eclipse installation dir (~/eclipse in my case :])
Now go back to eclipse, Window->Preferences, Ant->Runtime (Classpath), click Add External JARs and add your ~/.ant/lib/descent-ant.jar archive.
Next go to Tasks menu we'll add two tasks:
I've entered name "descent.D", choose descent-ant.jar from drop-down list, and click on: "/descent/ant/tasks" and choose "D.class"
Now do the same using "descent.DBldNum" and choose "DModuleBuildNumber.class" file.

We're going to create ant build file, but before that let's create build.properites file that will held some basic data in easily editable format.
Press Ctrl+N, choose General->File, and enter build.properties as it's name.
Here is content of my properties file:

  1. compiler.dir = /opt
  2. compiler.type = dmd-linux
  3. src.dir = .
  4. dest.dir = bin

compiler.dir is a path to compiler (without dmd/bin/dmd, descent appends it)
Press Ctrl+N and in filter box type xml, and chose XML, click next, and enter build.xml as a filename, Using bottom tabs choose Source instead of Design
I've created following build.xml (I'm not pasting it here, since this would be quite senseless, but you can take a look at it at codepad.org.
Build file is specific for linux, if I remember correctly my build.xml under windows was simpler than that one.
As you see most of the file is definition of compile macro which takes one parameter (bldtrg). (EDIT: you can find list of all possible parameters for descent.D task here)
Let's forget about that macro for a moment and take a look down at possible targets:

  1. <target name="build-number">
  2.   <descent.DBldNum file="${src.dir}/sample_bn.d" fqn="sample_bn" />
  3. </target>
  4. <target name="compile" depends="build-number" description="Compiles sample">
  5.   <compile bldtrg="sample"/>
  6. </target>

This looks quite clean don't you think?
Now you could right-mouse-click on the build.xml file, choose Run-as ->Ant build file but this is uber-lame.
Instead go to Window->Show View->Other and select Ant. I like to keep this window in lower-wight corner. Double click on any listed target will execute it (along with dependencies).
I have binded Ctrl+Shift+Q A to Show View (View: Ant), this way I can fast switch to ant window :).
eclipse descent

What's cool about it is that you can have multiple build targets (one can build few executables) and have all of them visible and easily accessible.
I'm not going to encourage anybody to use ant, but it's really cool tool, take a while to peek into ant's documentation, especially ant tasks.

catz: [eng.lish] [kom.puterowe] [programowanie w D] [Techblog]
tagz: [d] [d programming language] [descent] [eclipse]
dnia środa, 14 styczeń 2009, 044409 by Michał 'GiM' Spadliński

Komentarze:

Proszę wpisy pisane po angielsku komentować również w tym języku.

Don't be such a lamer! Why English?

dnia czwartek, 15 styczeń 2009, 181237 by lami

@lami: clever as always ;>

Cause It's not very documented method of building d projects under eclipse and I think there are more people abroad who're using Descent than here.

dnia czwartek, 15 styczeń 2009, 234115 by GiM

I have a problem with Descent + Eclipse3.4 + SuseEntprise10.
When I press CTRL+Space, I will see an error message:

------------------------------------------
The 'descent.ui.JavaNoTypeCompletionProposalComputer' proposal computer from the 'descent.ui' plug-in did not complete normally. The extension has thrown a runtime exception.

To avoid this message, disable the 'descent.ui' plug-in or disable the 'Other D Proposals' category on the content assist preference page.
------------------------------------------

Can someone helP?

dnia piątek, 23 styczeń 2009, 101337 by stanleyxu2005

when does this happen, can you post fragment of a code?
I haven't seen "Other D proposals" option.
Maybe you have somehow installed few versions of a plugin?

(You should probably post detailed informations to descent forum page: http://www.dsource.org/forums/viewforum.php?f=107)

dnia poniedziałek, 26 styczeń 2009, 003120 by GiM

Interesting. Im not familiar with D but i want to learn this language. Im not familiar with ANT too but ant buildscript is allmoust self-explanatory. Everything is working just fine! I can compile and run application, and ctrl+space works ^^. Thanks! Pozdrawiam.

dnia poniedziałek, 01 czerwiec 2009, 184235 by solgar

@solgar: hope you'll stick to D, it's worth it. Ant itself has very good documentation (like most of the software from Apache Foundation).

dnia poniedziałek, 01 czerwiec 2009, 223430 by GiM

..tożsamość..:
..meritum..:
..lokum..:
Wpisz kod:code