# Copyright AllSeen Alliance. All rights reserved.
#
#    Permission to use, copy, modify, and/or distribute this software for any
#    purpose with or without fee is hereby granted, provided that the above
#    copyright notice and this permission notice appear in all copies.
#
#    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
#    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
#    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
#    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
#    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
#    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
#    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# 
import os.path
Import('env')

sdk_propertiesClient_sample = env.Java('$OBJDIR_ALLJOYN_JAVA/samples/JavaSDKDoc/JavaSDKDocPropertiesClient', 'src',
                                       JAVACLASSPATH=env.GetBuildPath(env.subst('$JARDIR/alljoyn.jar')))

#if the manifest file does not yet exist create it unless clean has be specified.
if not env.GetOption('clean'):
    if not os.path.isfile('MANIFEST.MF'):
        manifest = ("Manifest-Version: 1.0\n" +
                   "Class-Path: alljoyn.jar\n" + 
                   "Main-Class: org.alljoyn.bus.samples.Client\n")
        file = open('MANIFEST.MF', 'w')
        file.write(manifest)
        file.close()

#add the manifest to the list of files used to build the *.jar file   
sdk_propertiesClient_sample.append('MANIFEST.MF')

env.Jar('$JARDIR/JavaSDKDocPropertiesClient.jar', sdk_propertiesClient_sample)
env.Requires(sdk_propertiesClient_sample, '$JARDIR/alljoyn.jar')

#add the sample to the dist with out adding the build files.
# The return value is the collection of files installed in the build destination.
returnValue = env.Install('$JAVA_DISTDIR/samples/JavaSDKDoc/JavaSDKDocPropertiesClient', ['src', '.classpath', '.project'])

#clean up the created manifest file
env.Clean('.', sdk_propertiesClient_sample)
#clean the build folder that remains after cleaning all other files.
env.Clean('.', 'build')

Return('returnValue')
