alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (build.xml)

This example Java source code file (build.xml) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

ant, api, build_date, delete, general, iiop, java, jmx, jrmp, license, oracle, public, this

The build.xml Java example source code

<?xml version="1.0"?>

<!--
 Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Oracle designates this
 particular file as subject to the "Classpath" exception as provided
 by Oracle in the LICENSE file that accompanied this code.

 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 or visit www.oracle.com if you need additional information or have any
 questions.
-->



<!-- README - HOW TO USE THIS BUILD FILE
     . You need Ant 1.5 or higher available in your path
     . You need a build of Java SE 6 available in your path, or JAVA_HOME set to such a build
     . cd to the directory containing this build.xml file
     . Launch the build by typing: ant
     . Please also read the important comment on basedir definition below.
 -->

<project name="JMX API Version 1.4 - Java SE 6 implementation"
	 default="jar"
	 basedir="../../../../.."
	 >

    <!-- IMPORTANT: BASEDIR DEFINITION
         This file is assumed to be in:
         <src_bundle_dir>/j2se/src/share/classes/javax/management
         Thus the basedir for this project is defined above as:
         basedir="../../../../.."
         in order to be the parent dir of src subdir.
	 Result of the build will be placed in ${basedir}/build_jmx
	 as defined by ${dir.build} property below.
     -->

    <description>
        Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.

        Description: JMX API Version 1.4 - Source Code from Java SE 6
    </description>


    <!-- build properties -->

    <property name="dir.src"
	      location="${basedir}/src/share/classes" />

    <property name="dir.build"
	      location="${basedir}/build_jmx" />

    <property name="dir.build.lib"
	      location="${dir.build}/lib" />

    <property name="dir.build.classes"
	      location="${dir.build}/classes" />

    <property name="dir.build.cache"
	      location="${dir.build}/cache" />

    <property name="flag.debug"
	      value="on" />

    <property name="flag.debug.level"
	      value="lines,source" />

    <property name="flag.optimize"
	      value="on" />

    <property name="flag.javac.source"
	      value="1.6" />

    <property name="flag.deprecation"
	      value="off" />

    <!-- ANT: when compiling, ignore the classpath in effect when Ant is run
	      and therefore use only the classpath specified in the javac tasks -->
    <property name="build.sysclasspath"
	      value="ignore" />



    <!-- Concatenated classpaths: one classpath for each build purpose -->

    <path id="classpath.tobuild.jmx">
	<!-- EMPTY, NO DEPENDENCY! -->
    </path>



    <!-- Convert path objects to string properties for display -->

    <property name="property.classpath.tobuild.jmx"	refid="classpath.tobuild.jmx" />




    <!-- ********************* -->
    <!-- *** BUILD TARGETS *** -->
    <!-- ********************* -->


    <!-- ~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Initialize the build -->

    <target name="init" >

        <!-- Set the values for build date and time -->
        <tstamp>
	    <format property="BUILD_DATE"        pattern="yyyy.MM.dd_HH:mm:ss_z" />
        </tstamp>

        <!-- Create the build directory -->
        <mkdir dir="${dir.build}" />

        <!-- Log the values of all properties to file -->
        <echoproperties destfile="${dir.build}/properties.log" />

        <!-- Display the values of most important properties -->
	<echo />
	<echo>See the contents of ${dir.build}/properties.log for all defined properties.
	<echo />
        <echo message="MAIN JVM DEFAULT SYSTEM PROPERTIES: " />
        <echo message="   java.runtime.version        = ${java.runtime.version}" />
        <echo message="   java.home                   = ${java.home}" />
        <echo message="   os.arch                     = ${os.arch}" />
        <echo message="   os.name                     = ${os.name}" />
        <echo message="   os.version                  = ${os.version}" />
        <echo message="   user.name                   = ${user.name}" />
	<echo />
        <echo message="ANT BUILT-IN PROPERTIES: " />
        <echo message="   basedir                     = ${basedir}" />
        <echo message="   ant.file                    = ${ant.file}" />
        <echo message="   ant.version                 = ${ant.version}" />
        <echo message="   ant.project.name            = ${ant.project.name}" />
        <echo message="   ant.java.version            = ${ant.java.version}" />
	<echo />
        <echo message="MAIN ANT BUILD-SET PROPERTIES: " />
        <echo message="   dir.src                     = ${dir.src}" />
        <echo message="   dir.build                   = ${dir.build}" />
        <echo message="   classpath.tobuild.jmx       = ${property.classpath.tobuild.jmx}" />
        <echo message="   flag.debug                  = ${flag.debug}" />
        <echo message="   flag.debug.level            = ${flag.debug.level}" />
        <echo message="   flag.optimize               = ${flag.optimize}" />
        <echo message="   flag.javac.source           = ${flag.javac.source}" />
        <echo message="   flag.deprecation            = ${flag.deprecation}" />
        <echo message="   BUILD_DATE                  = ${BUILD_DATE}" />

    </target>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Call classes subtargets and rmic stubs generation -->

    <target name="classes" depends="init,classes-javac,classes-rmic"
	    description="Call classes subtargets and rmic stubs generation"
    />


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Build JMX java files                  -->

    <target name="classes-javac" depends="init"
	    description="Build JMX java files" >

        <mkdir dir="${dir.build.classes}" />

	<javac 	srcdir="${dir.src}"
		destdir="${dir.build.classes}"
		source="${flag.javac.source}"
		debug="${flag.debug}"
		debuglevel="${flag.debug.level}"
		optimize="${flag.optimize}"
		includeAntRuntime="no"
		includeJavaRuntime="no"
	        >
	    <include name="javax/management/**"/>
	    <include name="com/sun/jmx/**"/>
	</javac>

    </target>


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Generate RMI JRMP and IIOP stub class files for remote objects -->

    <target name="classes-rmic" depends="init,classes-javac"
            description="Generate RMI JRMP and IIOP stub class files for remote objects" >


	<!-- JRMP Stubs -->

        <rmic 	base="${dir.build.classes}"
		classname="javax.management.remote.rmi.RMIConnectionImpl"
		includeAntRuntime="no"
		includeJavaRuntime="no"
		stubversion="1.2"
		>
	</rmic>

	<rmic	base="${dir.build.classes}"
		classname="javax.management.remote.rmi.RMIServerImpl"
		includeAntRuntime="no"
		includeJavaRuntime="no"
		stubversion="1.2"
		>
        </rmic>


	<!-- IIOP Stubs -->

	<rmic 	base="${dir.build.classes}"
		classname="javax.management.remote.rmi.RMIConnectionImpl"
		includeAntRuntime="no"
		includeJavaRuntime="no"
		iiop="yes"
		>
	</rmic>

	<rmic	base="${dir.build.classes}"
		classname="javax.management.remote.rmi.RMIServerImpl"
		includeAntRuntime="no"
		includeJavaRuntime="no"
		iiop="yes"
		>
        </rmic>

    </target>


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Jar all JMX  classes                 -->

    <target name="jar" depends="init,classes"
            description="Jar all JMX classes" >

       <mkdir dir="${dir.build.lib}" />

       <jar jarfile="${dir.build.lib}/jmx.jar"
	    update="true"
	    >

	    <fileset dir="${dir.build.classes}"
		includes="**/*.class"
	    />

	    <manifest >
		    <attribute name="Build-JDK"              value="${java.runtime.version}" />
		    <attribute name="Build-Platform"         value="${os.arch} ${os.name} ${os.version}" />
		    <attribute name="Build-User"             value="${user.name}" />
		<section name="common">
		    <attribute name="Sealed"                 value="true" />
		    <attribute name="Specification-Title"    value="JMX(TM) API" />
		    <attribute name="Specification-Version"  value="1.4" />
		    <attribute name="Specification-Vendor"   value="Oracle Corporation" />
		    <attribute name="Implementation-Title"   value="JMX(TM) API, Java SE 6 implementation" />
		    <attribute name="Implementation-Version" value="${BUILD_DATE} rebuild of Java SE JMX sources" />
		    <attribute name="Implementation-Vendor"  value="Source bundle from Oracle Corporation - Customer rebuilt" />
		</section>
	    </manifest>
       </jar>

    </target>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Delete only all class files in build/classes directory hierarchy -->

    <target name="clean-classes"
            description="Delete only all *.class files in build_jmx/classes dir" >
        <delete>
           <fileset dir="${dir.build.classes}" includes="**/*.class" />
        </delete>
    </target>


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Delete build directory and all its contents -->

    <target name="clean-all"
            description="Delete build directory and all its contents" >
        <delete dir="${dir.build}" />
    </target>


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Clean all and build everything -->

    <target name="all" depends="clean-all,jar"
	    description="Clean all and build everything" />


</project>

Other Java examples (source code examples)

Here is a short list of links related to this Java build.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.