Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Mike Wilson www.whisperingwind.co.uk

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Basic ant script with vim & jikes

Apache ant build XML. This will use jikes in place of javac. Any compiler error output is formatted so that vim can parse it.

ant is a modern alternative to make. The build script is an XML file. It works particularly well with java. Download it for free from the Apache ant site. Most people find ant a lot nicer to live with than make.

<?xml version="1.0"?>

<project name="Hello" default="compile" basedir=".">
  <property name="name" value="Hello"/>
  <property name="version" value="1.0"/>

  <!-- Project directories.
  -->

  <property name="build" value="build"/>
  <property name="dist" value="dist"/>
  <property name="src" value="src"/>

  <!-- Compiler directives.
  -->

  <property name="optimize" value="off"/>
  <property name="deprecation" value="on"/>
  <property name="debug" value="on"/>

  <property name="build.compiler" value="jikes"/>
  <property name="build.compiler.emacs" value="true"/>

  <target name="init">
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>

  <!-- Compile all the .java files from the source directory into
       the build directory.
  -->

  <target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${build}" includes="**/*.java"
      debug="${debug}" deprecation="${deprecation}" optimize="${optimize}">
    </javac>
  </target>

  <target name="clean" depends="init">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>

  <target name="test" depends="compile">
    <java classname="HelloWorld" fork="yes">
      <classpath>
        <pathelement location="${build}"/>
      </classpath>
    </java>
  </target>
</project>

vim configuration - graphics mode

This is my .gvim rc, the configuration file for gvim, vim's graphics mode. vim is "vi improved", a vi clone and so much more.

set guifont=Monospace\ 11

" Overrides settings in vim's configuration. I prefer minimal colour.

hi Normal			guifg=Black		guibg=White
hi NonText			guifg=Black		guibg=White
hi Comment	gui=none	guifg=DarkGray
hi Constant	gui=none	guifg=Magenta
hi Identifier	gui=none	guifg=DarkGreen
hi Statement	gui=none	guifg=Blue
hi PreProc	gui=none	guifg=Blue
hi Type		gui=none	guifg=Blue
hi Special	gui=none	guifg=DarkGreen
hi Ignore	gui=none	guifg=DarkGreen
hi Error	gui=none	guifg=DarkGreen
hi Todo		gui=none	guifg=DarkGreen
hi Cursor	gui=none	guifg=White		guibg=Black

autocmd GUIEnter * winpos 66 28
autocmd GUIEnter * winsize 80 45

" What is this menu for? No documentation, something to do with 'C'
" or C++ perhaps? Dunno, but I don't want it.

aunmenu Bicycle\ Repair\ Man

" If I have Python, create a dummy project menu and exececute the
" vimproject script.

if has ("python")
    if filereadable ("/home/mrw/bin/vimproject.py")
	amenu Project.Dummy dummy
	pyfile /home/mrw/bin/vimproject.py
    endif
endif

vim configuration

This is my .vimrc file -- configuration options for vim, the "vi improved" text editor for grown ups.

:autocmd!

set nohlsearch

" Press F2 to word-wrap a block of text. It's almost like using Word
" Star all over again.

map #2 !}fmt -65

" Personally, I wouldn't use a C++ keyword as a Java identifier, but
" if someone else does, I don't want an ugly display, so turn off
" flagging of this as an error:

let java_allow_cpp_keywords=1

set autoindent
set cmdheight=2

" Strewth, what a mess. Copied from the vim docs, if memory serves.

set comments=s:/*,mb:**,ex:*/,://,b:#,b:##,:%,:XCOMM,n:>,fb:-

set formatoptions=orc
set history=20
set incsearch
set ignorecase
set keywordprg=
set mouse=a
set mousehide
set mousemodel=popup_setpos
set nowrapscan
set path=.,/usr/include,/usr/local/include
set smartcase
set nosmartindent
set smarttab
set showmode
set textwidth=70
set viminfo='50,\"10000,n~/.viminfo
set wildchar=9
set wildignore+=*.class,*.pyc
set wildmenu

syntax on

:autocmd FileType *		set shiftwidth=4
:autocmd FileType xml,html	set shiftwidth=2
:autocmd FileType java,c,cc,cpp	set nocindent

set makeprg=ant

" Bleurgh! This makes sense of ant/jikes error messages so the ":make"
" command works. But, I ask you, how the f**k can anyone make sense of
" that mess?

set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,\%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#

" For the style of comments I like in 'C', C++ and Java.

autocmd BufNewFile,BufRead *.java set comments=s:/*,mb:**,ex:*/
autocmd BufNewFile,BufRead *.c set comments=s:/*,mb:**,ex:*/
autocmd BufNewFile,BufRead *.cc set comments=s:/*,mb:**,ex:*/

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS