#!/bin/ksh
#
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0, which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception, which is available at
# https://www.gnu.org/software/classpath/license.html.
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#

#
# OVERVIEW:
# ---------
#
# This is an example of a shell script that shows how to record new sigfiles.
# This should not be distributed to customers.
#
# This is a shell script that is used to record new signature files.
# This will need to be modified to match the variable sigTestClasspath (in ts.jte)
# as well as to match the correct jdk version (via sig-test.map file).
#
# -Dsig.source=<sigTestClasspath var from ts.jte>
#              Note that the sig.source will need to refer to *all* classes which#              are under test as well as classes referred to or used by the#              classes under test.  (By "under test" we mean classes you are#              recording signatures of.)# -Dmap.file= point at desired sigtest map file in TS_HOME/bin# -Drecorder.type=sigtest (this will ALWAYS be "sigtest")
#
#
# NOTE:  this script was modified to run on mac (Mountain Lion) instead of Solaris.
#


#
#   !!! IMPORTANT !!!
#
# MUST ENSURE FOLLOWNG ENV VARS ARE SET FOR THIS TO WORK:
# TS_HOME    - top of your tck  (e.g. /files1/javaeetck)
# JAVA_HOME  - java home
# AS_HOME    - glassfish dir (e.g. /sun/glassfish4/glassfish)
# ANT_HOME   - Apache Ant installation
# 

AS_HOME=/sun/glassfish4/glassfish

pathsep=":"

# this is how we determine JAVA_HOME on mac
JAVA_HOME=`/usr/libexec/java_home -v 1.7`
echo "JAVA_HOME set to $JAVA_HOME"
sleep 5

sigtest_classes="${TS_HOME}/lib/sigtest.jar:${TS_HOME}/classes"

s1as_modules="${AS_HOME}/modules"

# pulled from ts.jte but then we changed s1as_modules to s1as_modules as we were
# running into some script failures that seem to be related to our particular
# mac terminal.  The safest fix seemed to be to rename it....so we did.

sigTestClasspath=${s1as_modules}/javax.json.jar${pathsep}${s1as_modules}/javax.batch-api.jar${pathsep}${s1as_modules}/javax.interceptor-api.jar${pathsep}${s1as_modules}/stax2-api.jar${pathsep}${s1as_modules}/javax.enterprise.concurrent-api.jar${pathsep}${s1as_modules}/javax.websocket-api.jar${pathsep}${s1as_modules}/javax.jms-api.jar${pathsep}${s1as_modules}/javax.xml.registry-api.jar${pathsep}${s1as_modules}/javax.enterprise.deploy-api.jar${pathsep}${s1as_modules}/javax.faces.jar${pathsep}${s1as_modules}/bean-validator.jar${pathsep}${s1as_modules}/endorsed/javax.annotation-api.jar${pathsep}${s1as_modules}/endorsed/jaxb-api-osgi.jar${pathsep}${s1as_modules}/endorsed/webservices-api-osgi.jar${pathsep}${s1as_modules}/javax.xml.rpc-api.jar${pathsep}${s1as_modules}/javax.ws.rs-api.jar${pathsep}${s1as_modules}/javax.ejb-api.jar${pathsep}${s1as_modules}/javax.mail.jar${pathsep}${s1as_modules}/javax.persistence.jar${pathsep}${s1as_modules}/javax.management.j2ee-api.jar${pathsep}${s1as_modules}/javax.resource-api.jar${pathsep}${s1as_modules}/javax.security.jacc-api.jar${pathsep}${s1as_modules}/javax.security.auth.message-api.jar${pathsep}${s1as_modules}/javax.servlet-api.jar${pathsep}${s1as_modules}/javax.el.jar${pathsep}${s1as_modules}/javax.servlet.jsp-api.jar${pathsep}${s1as_modules}/javax.servlet.jsp.jar${pathsep}${s1as_modules}/javax.servlet.jsp.jstl-api.jar${pathsep}${s1as_modules}/jakarta.transaction-api.jar${pathsep}${JAVA_HOME}/jre/lib/rt.jar${pathsep}${JAVA_HOME}/jre/lib/jce.jar${pathsep}${s1as_modules}/weld-osgi-bundle.jar



$ANT_HOME/bin/ant -find record-build.xml \
-Dsig.source="${sigtest_classes}${pathsep}${sigTestClasspath}" \
-Dmap.file=${TS_HOME}/install/jakartaee/bin/sig-test_se7.map  \
-Djava.endorsed.dirs=${AS_HOME}/modules/endorsed \
-Drecorder.type=sigtest \
record.sig.batch

