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

Java example source code file (osgi-build.xml)

This example Java source code file (osgi-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, hence, maven, this, when

The osgi-build.xml Java example source code

<project name="osgi-test" default="testAll">

	<!--
		This build file is usually run indirectly via Maven.
		
		When running this build file through Ant directly, you must
		define the currentVersion property on the command line, e.g.:
		
		ant  -DcurrentVersion=1.5.4-SNAPSHOT	
	-->
	
	<echo message="compile classpath: ${currentVersion}" />
	<echo message="test classpath:    ${test_classpath}" />
	<echo message="basedir:           ${basedir}" />

  <property name="iBundleJar" value="target/iBundle.jar"/>
  <property name="bundlesDir" value="bundle"/>


	<!-- this is really very ugly, but it's the only way to circumvent
  	     http://jira.codehaus.org/browse/MANTRUN-95
	-->
	<taskdef name="junit" classpath="${test_classpath}" 
           classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />

	<path id="minimal">
		<pathelement location="target/test-classes/" />
	</path >

	<target name="init">
		<mkdir dir="target/unit-reports" />
	</target>

  <target name="createIBundle">
    <mkdir dir="${bundlesDir}"/>
    <jar destFile="${iBundleJar}" 
         manifest="src/IBUNDLE-META-INF/MANIFEST.MF"
         basedir="target/test-classes/"
         includes="integrator/**.class"/>
                   
  </target>

	<target name="testAll" depends="init, createIBundle, nop, simple, jdk14">
	</target>

 
  <macrodef name="prepareOSGiHarness">
    <attribute name="binding"/>
    <sequential>
      <delete>
        <fileset dir="${bundlesDir}" includes="*.jar"/>
      </delete>
      <copy file="${iBundleJar}" todir="${bundlesDir}"/>
      <copy file="../slf4j-api/target/slf4j-api-${currentVersion}.jar" todir="${bundlesDir}"/>
      <copy file="../slf4j-@{binding}/target/slf4j-@{binding}-${currentVersion}.jar" todir="${bundlesDir}"/>
      <echo>value of t = @{t}
    </sequential>
  </macrodef>


   <!-- for some reason if mvn is invoked from the parent directory, junit gets
        invoked from the parent dir, which messes up theses tests. Hence, the
        fork="yes" dir="${basedir}" -->

  <target name="nop">
    <prepareOSGiHarness binding="nop"/>
    <junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
			<classpath path="${test_classpath}"/>
      <formatter type="plain" />
      <test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
    </junit>
	</target>

	<target name="simple">
    <prepareOSGiHarness binding="simple"/>
    <junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
			<classpath path="${test_classpath}"/>
      <formatter type="plain" />
      <test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
    </junit>
	</target>

	<target name="jdk14">
    <prepareOSGiHarness binding="jdk14"/>
    <junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
			<classpath path="${test_classpath}"/>
      <formatter type="plain" />
      <test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
    </junit>
	</target>
  
</project>

Other Java examples (source code examples)

Here is a short list of links related to this Java osgi-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.