And StepByStep tutorial explaining how to setup a netbeans 4.0 project with lenya.
First of all excuse me for my English....
Last month I have been working in lenya with netbeans 4.0 and I managed to create a project to work with lenya in this IDE. Here I put the steps I follow to configure the IDE:
- Download the latest stable source distribution (1.2.3 when I wrote this page)
- Follow the steps provided by lenya to compile. You obtain a build folder. [BR]
- Netbeans doesn't allow you to create a project without a web.xml file in WEB-INF folder. Lenya doens't provides you a web.xml
- file in src/webapp/WBE-INF folder. You can use the build/lenya/webapp/WEB_INF/build.xml file to cheat lenya.
- Create a web project with existing sources using new project wizard.
- Choose folder {LENYA_HOME}/src/java in src files and {LENYA_HOME} in project folder.
- When you accept, netbeans tells us that this project have an existing build.xml. Netbeans creates a new nbbuild.xml file...
- Choose {LENYA_HOME}/src/webapp folder in web pages location.
- Choose {LENYA_HOME}/lib folder in libslocation.
- Creating the project sometimes netbeans hangs up. We can cancel an fortunately the project is created
/****** Changes in NBBUILD.XML *******************************/
Note: Be careful with ant project name (affects variable ant.project.name). To avoid problems (like not being able to deploy the project), use context path name (for instance lenya) like ant project name.
- Now we copy all ant import from build.xml file to nbbuild.xml.
- Now we add our custom targets. For instance:
<!-- OUR TARGETS --> <import file="src/targets/our_targets_file.xml" />
- Now we "patch" some lenya targets to adapt it to our requirements:
- - webapp.xml: Comment the steps in charge of loading Tomcat or Jetty
<!-- netbeans takes care of this... <condition property="servlet.engine.wls"> <equals arg1="${web.app.server}" arg2="WLS"/> </condition> <antcall target="install-wls"/> <antcall target="successfully-built-message-wls"/>
<condition property="servlet.engine.tomcat"> <equals arg1="${web.app.server}" arg2="Tomcat"/> </condition> <antcall target="install-tomcat"/> <antcall target="successfully-built-message-tomcat"/>
<condition property="servlet.engine.jetty"> <equals arg1="${web.app.server}" arg2="Jetty"/> </condition> <antcall target="successfully-built-message-jetty"/> -->
<!-- netbeans takes care of this... <target name="compile" depends="prepare-src"
description="Compile the sources">
<mkdir dir="${build.dest}"/> <javac srcdir="${build.src}"
- destdir="${build.dest}" debug="${debug}" optimize="${optimize}" deprecation="${deprecation}" target="${target.vm}" nowarn="${nowarn}"
source="1.4">
<classpath refid="classpath"/> </javac> </target> -->
- - webapp.xml: Comment the steps in charge of loading Tomcat or Jetty
- Now we add source libraries needed to compile in properties project. We can obtain them from Coocon folder or lenya itself:
- - avalon-framework-api-xxxx.jar - avalon-framework-impl-xxxx.jar - cocoon-xxx.jar - log4j.jar - excalibur-source-resolver.jar - excalibur-io.jar - excalibur-xmlutils.jar - jakarta-reg-exp.jar - xalan-xxx.jar - commons-lang.jar - commons-httpclient.jar - lucene.jar - jtydy-xxx.jar - xml-commons-resolver.jar - rhino-xxx.jar - quartz-xxx.jar : You can find it at coocon/lib/optional. - All *.jar from tools/lib folder.
- Now we overwrite the following netbeans ant targets in nbbuild.xml file:
<target name="-pre-compile" depends="prepare-src"/>
<target name="-pre-init" depends="init-lenya"/>
<target name="-post-init" depends="sincronizar_build_con_src"/>
<target name="-post-clean" depends="clean-lenya"/>
- Add the following ant targets to nbbuild.xml our our custom targets file (you choose!) You can find Kupu at kupu.build file in src/targets folder)
<target name="kupu" description="Build Kupu">
<echo>
- *******************************************
- Build Kupu. *
- ******************************************* ${build.webapp}/lenya/resources/kupu
</echo>
<exec
- dir="${build.webapp}/lenya/resources/kupu" executable="xsltproc" failonerror="false" failifexecutionfails="false" outputproperty="xsltproc.output"
/>
<fail unless="xsltproc.output">:
- *******************************************
- Please install "xsltproc" to build Kupu. *
- *
- xsltproc can be downloaded from *
- (you also need zlib and iconv) *
- *******************************************
</fail>
<exec dir="${build.webapp}/lenya/resources/kupu"
- executable="make" failonerror="true" failifexecutionfails="false"
/>
</target>
<target name="clean_tomcat_work_folder">
<delete dir="/home/sergi.tur/.netbeans/4.0/jakarta-tomcat-5.0.28_base/work/Catalina/localhost/lenya"/>
</target>
- Customize filke {LENYA_HOME}/build.properties to our specific paths requirements (cocoon.src.dir,etc).
- Modife the following ant properties in file {LENYA_HOME}/nbproject/project.properties:
- -build.dir=build/ a build.dir=build/lenya -build.web.dir=${build.dir}/web a build.web.dir=${build.dir}/webapp
Here you can find the same steps in my native language (spanish):
- Bajarse los fuentes de la última versión estable (1.2.3 al escribir este doc)
- Compilar las fuentes según los pasos indicados en lenya. Se obtiene una carpeta build.
- Netbeans no permite crear un proyecto web sin fichero web.xml en la carpeta WEB-INF.
- Como las fuentes no tiene este fichero copiaremos el fichero web.xml de la carpeta build a src/webapp/WEB-INF.
- Crear un nuevo projecto de netbeans tipo: Web project with existing sources.
- Escoger los ficheros fuente (carpeta {LENYA_HOME}src/java) y la carpeta del proyecto ({LENYA_HOME}).
- Nombrar el proyecto.
- Al aceptar no indicará que ya existe un fichero build para este proyecto y que creara uno con el nombre nbbuild.xml.
- Aceptamos.
- Elegimos como localización de los ficheros web (web pages location) la carpeta {LENYA_HOME}/src/webapp.
- Elegimos como localización de las librerias la carpeta {LENYA_HOME}/lib.
- A veces da un error y se queda colgado al crear el proyecto.Sin embargo si cerramos la ventana de dialogo podremos abri el proyecto recien creado desde el punto de menu nuevo proyecto.
/****** RETOCAR EL FICHERO NBBUILD.XML *******************************/
Nota: Ojo con el nombre del projecto ant que afecta a la variable ant.project.name. Este debe ser igual al nombre del contexto que que estemos utilizando en las propiedades del projecto.
- En el fichero nbbuild.xml copiamos todos los imports del fichero build.xml original (se important todos los ficheros de projecto de la carpeta src/targets)
- Añadimos un linea como esta:
<!-- NUESTROS TARGETS --> <import file="src/targets/tu_fichero_de_targets.xml" />
- Hay que hacer unos pequeños cambios en los ficheros target del lenya para adaptarlo a netbeans:
- - webapp.xml: Comentar la parte encargada de ejecutar Tomcat o Jetty
<!-- ESTO SE LO DEJAMOS AL NETBEANS <condition property="servlet.engine.wls"> <equals arg1="${web.app.server}" arg2="WLS"/> </condition> <antcall target="install-wls"/> <antcall target="successfully-built-message-wls"/>
<condition property="servlet.engine.tomcat"> <equals arg1="${web.app.server}" arg2="Tomcat"/> </condition> <antcall target="install-tomcat"/> <antcall target="successfully-built-message-tomcat"/>
<condition property="servlet.engine.jetty"> <equals arg1="${web.app.server}" arg2="Jetty"/> </condition> <antcall target="successfully-built-message-jetty"/> --> Cambiar el target clean por clean-lenya.
<!-- SUSTITUIDO POR EL DE NETBEANS <target name="compile" depends="prepare-src"
description="Compile the sources">
<mkdir dir="${build.dest}"/> <javac srcdir="${build.src}"
- destdir="${build.dest}" debug="${debug}" optimize="${optimize}" deprecation="${deprecation}" target="${target.vm}" nowarn="${nowarn}"
source="1.4">
<classpath refid="classpath"/> </javac> </target> -->
- - webapp.xml: Comentar la parte encargada de ejecutar Tomcat o Jetty
- Para compilar necesitaremos añadir algunas librerias extras que no estan en la carpeta lib (son de cocoon):
- - avalon-framework-api-xxxx.jar - avalon-framework-impl-xxxx.jar - cocoon-xxx.jar - log4j.jar - excalibur-source-resolver.jar - excalibur-io.jar - excalibur-xmlutils.jar - jakarta-reg-exp.jar - xalan-xxx.jar - commons-lang.jar - commons-httpclient.jar - lucene.jar - jtydy-xxx.jar - xml-commons-resolver.jar - rhino-xxx.jar - quartz-xxx.jar : Esta en en coocon/lib/optional. - Todos los .jar de la carpeta tools/lib.
- Hay que sobrescribir los targets de netbeans siguientes:
<target name="-pre-compile" depends="prepare-src"/>
<target name="-pre-init" depends="init-lenya"/>
<target name="-post-init" depends="sincronizar_build_con_src"/>
<target name="-post-clean" depends="clean-lenya"/>
- Añadir los siguientes targets (el de kupu se copia del fichero kupu.build de src/targets)
<target name="kupu" description="Build Kupu">
<echo>
- *******************************************
- Build Kupu. *
- ******************************************* ${build.webapp}/lenya/resources/kupu
</echo>
<exec
- dir="${build.webapp}/lenya/resources/kupu" executable="xsltproc" failonerror="false" failifexecutionfails="false" outputproperty="xsltproc.output"
/>
<fail unless="xsltproc.output">:
- *******************************************
- Please install "xsltproc" to build Kupu. *
- *
- xsltproc can be downloaded from *
- (you also need zlib and iconv) *
- *******************************************
</fail>
<exec dir="${build.webapp}/lenya/resources/kupu"
- executable="make" failonerror="true" failifexecutionfails="false"
/>
</target>
<target name="clean_tomcat_work_folder">
<delete dir="/home/sergi.tur/.netbeans/4.0/jakarta-tomcat-5.0.28_base/work/Catalina/localhost/lenya"/>
</target>
- Repasar el fichero {LENYA_HOME}/build.properties para ver si los paths son correctos (cocoo.src.dir,etc).
- Modificar en el fichero {LENYA_HOME}/nbproject/project.properties:
- -build.dir=build/ a build.dir=build/lenya -build.web.dir=${build.dir}/web a build.web.dir=${build.dir}/webapp