<!--
 ! Licensed to the Apache Software Foundation (ASF) under one
 ! or more contributor license agreements.  See the NOTICE file
 ! distributed with this work for additional information
 ! regarding copyright ownership. The ASF licenses this file
 ! to you under the Apache License, Version 2.0 (the
 ! "License"); you may not use this file except in compliance
 ! with the License. You may obtain a copy of the License at
 ! 
 !      http://www.apache.org/licenses/LICENSE-2.0
 ! 
 ! Unless required by applicable law or agreed to in writing, software
 ! distributed under the License is distributed on an "AS IS" BASIS,
 ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ! See the License for the specific language governing permissions and
 ! limitations under the License.
 !-->

<project name="fiddler" basedir="." default="all">

  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## ENVIRONMENT SETTINGS						-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <property name="top" location="../../../../.."/>

  <property name="pkg-path" value="com/sun/jini/${ant.project.name}"/>

  <!-- ##								-->
  <!-- ## Set java-source for use with the javac task:			-->
  <!-- ##								-->

  <property name="java-source" value="${pkg-path}/**/*.java" />

  <import file="${top}/build_common.xml"/>


  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## TARGET: all							-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <target name="all"
          description=""
          depends="compile,
		   this.stubs">

  </target>


  <!-- ################################################################ -->
  <!-- ##                                                               -->
  <!-- ## TARGET: clean                                                 -->
  <!-- ##                                                               -->
  <!-- ################################################################ -->

  <target name="clean"
          description="Removes all files and dirs created by the build."
          depends="clean.jre.ext">

    <delete dir="${build.classes}/${pkg-path}" quiet="true"/>

  </target>


  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## TARGET: this.jars						-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <target name="this.jars"
	  depends="fiddler.jar,
		   fiddler-dl.jar">

  </target>
  

  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## TARGET: fiddler.jar						-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <target name="fiddler.jar"
	  depends="tools">
  
    <property name="fiddler.deps" location="${build.deps}/fiddler.deps" />
    
    <!-- ##								-->
    <!-- ## Run ClassDep.						-->
    <!-- ##								-->

    <java classname="com.sun.jini.tool.ClassDep"
          failonerror="true"
          output="${fiddler.deps}">
          
      <classpath refid="path.classdep"					/>
      <arg value="-cp"							/>
      <arg path="${build.classes}"					/>
      <arg value="-files"						/>
      <arg line="${jskprivate.include}"					/>

      <arg line="-in com.sun.jini.fiddler"				/>

      <arg value="com.sun.jini.fiddler.ActivatableFiddlerImpl"		/>
      <arg value="com.sun.jini.fiddler.FiddlerPermission"		/>
      <arg value="com.sun.jini.fiddler.FiddlerImpl_Stub"		/>
      <arg value="com.sun.jini.fiddler.NonActivatableFiddlerImpl"	/>
      <arg value="com.sun.jini.fiddler.TransientFiddlerImpl"		/>

    </java>

    <!-- ##								-->
    <!-- ## Generate the jar file.					-->
    <!-- ##								-->

    <delete file="${build.lib}/fiddler.jar" quiet="true" />

    <jar destfile="${build.lib}/fiddler.jar" 
         index="false"
         manifest="${src.jini.manifest}/fiddler.mf">
         
      <fileset dir="${build.classes}"  includesfile="${fiddler.deps}" />

    </jar>

    <!-- ##								-->
    <!-- ## Generate the Preferred List					-->
    <!-- ##								-->

    <preferredlistgen>

      <plg-elements>

      <arg line="-cp"							/>
      <arg path="${build.classes}"					/>

      <arg line="-jar"							/>
      <arg path="${build.lib}/fiddler.jar"				/>
      
      <arg line="-default true"   					/>

      </plg-elements>

    </preferredlistgen>

  </target>


  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## TARGET: fiddler-dl.jar					-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <target name="fiddler-dl.jar"
	  depends="tools">
  
    <property name="fiddler-dl.deps" location="${build.deps}/fiddler-dl.deps" />
    
    <!-- ##								-->
    <!-- ## Run ClassDep.						-->
    <!-- ##								-->

    <java classname="com.sun.jini.tool.ClassDep"
          failonerror="true"
          output="${fiddler-dl.deps}">
      
      <classpath refid="path.classdep"					/>
      <arg value="-cp"							/>
      <arg path="${build.classes}"					/>
      <arg value="-files"						/>
      <arg line="${jskprivate.include}"					/>

      <arg line="-in com.sun.jini.fiddler"				/>

      <arg value="com.sun.jini.fiddler.FiddlerAdminProxy"		/>
      <arg value="com.sun.jini.fiddler.FiddlerImpl$$FiddlerStatus"	/>
      <arg value="com.sun.jini.fiddler.FiddlerImpl_Stub"		/>
      <arg value="com.sun.jini.fiddler.FiddlerLease"			/>
      <arg value="com.sun.jini.fiddler.FiddlerProxy"			/>
      <arg value="com.sun.jini.fiddler.FiddlerRegistration"		/>
      <arg value="com.sun.jini.fiddler.ProxyVerifier"			/>
      <arg value="com.sun.jini.lookup.entry.BasicServiceType"		/>
      <arg value="com.sun.jini.reliableLog.LogException"		/>
      <arg value="net.jini.discovery.RemoteDiscoveryEvent"		/>
      <arg value="net.jini.lookup.entry.ServiceInfo"			/>

    </java>

    <!-- ##								-->
    <!-- ## Generate the jar file.					-->
    <!-- ##								-->

    <delete file="${build.lib-dl}/fiddler-dl.jar" quiet="true"/>

    <jar destfile="${build.lib-dl}/fiddler-dl.jar" index="false">
         
      <fileset dir="${build.classes}"  includesfile="${fiddler-dl.deps}" />
      
    </jar>

    <!-- ##								-->
    <!-- ## Generate the Preferred List					-->
    <!-- ##								-->

    <preferredlistgen>

      <plg-elements>

	<arg line="-cp"							/>
	<arg path="${build.classes}"					/>
  
	<arg line="-jar"						/>
	<arg path="${build.lib-dl}/fiddler-dl.jar"			/>
  
	<arg line="-jar"						/>
	<arg path="${build.lib-dl}/jsk-dl.jar"				/>
  
	<arg line="-proxy com.sun.jini.fiddler.FiddlerProxy"		/>
	<arg line="-proxy com.sun.jini.fiddler.FiddlerAdminProxy"	/>

      </plg-elements>

    </preferredlistgen>

  </target>


  <!-- ################################################################ -->
  <!-- ##								-->
  <!-- ## TARGET: this.stubs						-->
  <!-- ##								-->
  <!-- ################################################################ -->

  <target name="this.stubs"
          description="Builds the RMI stubs for ${ant.project.name}."
          depends="compile">

    <rmic base="${build.classes}" stubversion="1.2">

      <classpath refid="path.jini" />
      <include name="com/sun/jini/fiddler/FiddlerImpl.class" />

    </rmic>

  </target>

</project>

