# Creating Port that is Built with Apache Ant



## AntumDeluge (Dec 18, 2014)

I've been going through the Porter's Handbook trying to figure out how to create a port that requires devel/apache-ant. I've created the Makefile, pkg-descr, pkg-plist, and distinfo files.

Makefile:

```
# $FreeBSD$

PORTNAME=  stendhal
PORTVERSION=  1.16
CATEGORIES=  games
DISTNAME=  stendhal-${PORTVERSION}-src
MASTER_SITES=   http://downloads.sourceforge.net/project/arianne/stendhal/${PORTVERSION}/
WRKSRC=  ${WRKDIR}/${PORTNAME}-${PORTVERSION}

MAINTAINER=  antumdeluge@gmail.com
COMMENT=  An open source 2D Action/Adventure Online Role Playing Game.

USE_JAVA=  yes

BUILD_DEPENDS=  ant:${PORTSDIR}/devel/apache-ant

.include <bsd.port.mk>
```

pkg-descr:

```
Stendhal is an open source 2D MMORPG with an excellent community. Players can gain experience through battling, quest for special items, explore an expanding world or even be a part of the development. There are lots of ways to be involved in the project. Stendhal is developed using the Arianne game development system.

Stendhal is written in Java and requires the Java runtime environment.

WWW: http://stendhalgame.org/
```

pkg-plist:

```
bin/stendhal
share/applications/stendhal.desktop
share/stendhal/doc/Licenses
share/stendhal/doc/Licenses/BSD.txt
share/stendhal/doc/Licenses/CC-BY-3.0.txt
share/stendhal/doc/Licenses/CC0-1.0.txt
share/stendhal/doc/Licenses/MIT.txt
share/stendhal/doc/AUTHORS.txt
share/stendhal/doc/BUGS.txt
share/stendhal/doc/CHANGES.txt
share/stendhal/doc/LICENSE-audio.txt
share/stendhal/doc/LICENSE-images.txt
share/stendhal/doc/LICENSE.txt
share/stendhal/lib/EasyMockLicense.html
share/stendhal/lib/LICENSES.txt
share/stendhal/lib/NOTICE.txt
share/stendhal/lib/jorbis.jar
share/stendhal/lib/license-apache-2.0.txt
share/stendhal/lib/license-bsd.txt
share/stendhal/lib/license-cpl.html
share/stendhal/lib/license-gpl.txt
share/stendhal/lib/license-h2.html
share/stendhal/lib/license-lgpl.txt
share/stendhal/lib/log4j.jar
share/stendhal/lib/marauroa.jar
share/stendhal/lib/stendhal-data.jar
share/stendhal/lib/stendhal-music-data.jar
share/stendhal/lib/stendhal-sound-data.jar
share/stendhal/lib/stendhal.jar
share/stendhal/log/stendhal.txt
share/stendhal/.hotspotrc
share/stendhal/README.txt
share/stendhal/icon.ico
share/stendhal/stendhal-starter.jar
```

distinfo:

```
SHA256 (stendhal-1.16-src.tar.gz) = 1d2702f4074a356926e2c4fe07f4d620192663e469f5c42e366815e4efac1f8a
SIZE (stendhal-1.16-src.tar.gz) = 67320865
```

I have no idea how to set up the build instructions for using ant. From the WRKSRC directory I want it to execute `ant client_build`, which is defined in the file build.xml.

I'm also not sure how to set up the install instructions. This seems to not be addressed in the Quick Porting section of the handbook, but I'm trying to go through the rest of the handbook in more detail.


----------



## SirDice (Dec 18, 2014)

I couldn't find it the documentation but reading /usr/ports/Mk/bsd.java.mk shows you need to set USE_ANT. You may want to take a look at other ports that use it, like java/jakarta-commons-primitives for example.


```
# Ant support: default do-build target
.               if defined(USE_ANT)
DESTDIRNAME?=           -Dfreebsd.ports.destdir
ANT?=                           ${LOCALBASE}/bin/ant
MAKE_ENV+=                      JAVA_HOME=${JAVA_HOME}
BUILD_DEPENDS+=         ${ANT}:${PORTSDIR}/devel/apache-ant
ALL_TARGET?=
.                       if !target(do-build)
do-build:
                                        @(cd ${BUILD_WRKSRC}; \
                                                ${SETENV} ${MAKE_ENV} ${ANT} ${MAKE_ARGS} ${ALL_TARGET})
.                       endif
.               endif
```


----------



## AntumDeluge (Dec 18, 2014)

I just found the section of the handbook that talks about ant: https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/using-java.html


----------



## wblock@ (Dec 18, 2014)

A brute-force trick is to search the entire ports tree for existing ports that use the features desired:
`find /usr/ports -name Makefile -print0 | xargs -0 grep -H ANT | less -S`

Yes, that is not particularly fast the first time.  Followup searches go much faster due to caching.

Be careful, out of the thousands of ports, some are likely to do things in an old or non-standard way.  Of course, the question can always be asked on the freebsd-ports mailing list.


----------



## AntumDeluge (Dec 19, 2014)

Thank you wblock@. I found the port net-im/jitsi that uses ant and seems to be helpful.


----------

