summaryrefslogtreecommitdiffstats
path: root/maven/make-copy-jars-one.sh
blob: 342aa1aa64b71da7a080b2b2e819c5d186fd15d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh

info()
{
  echo "make-copy-jars-one: info: ${NAME}: $1" 1>&2
}

fatal()
{
  echo "make-copy-jars-one: fatal: ${NAME}: $1" 1>&2
  exit 1
}

copy()
{
  SOURCE="$1"
  TARGET="$2"

  info "copy $1 $2.tmp" 1>&2
  cp -n "$1" "$2.tmp" || exit 1
  info "rename $2.tmp $2" 1>&2
  mv -n "$2.tmp" "$2" || exit 1
}

if [ $# -ne 2 ]
then
  info "usage: project version"
  exit 1
fi

NAME="$1"
shift
VERSION="$1"
shift

INPUT="input/jogamp-all-platforms"

if [ ! -d "${INPUT}" ]
then
  echo "make-copy-jars-one: error: ${INPUT} is not an existing directory" 1>&2
  echo "make-copy-jars-one: error: unpack jogamp-all-platforms.7z into 'input'" 1>&2
  exit 1
fi

if [ ! -d "projects/${NAME}" ]
then
  echo "make-copy-jars-one: error: unknown project ${NAME}" 1>&2
  exit 1
fi

# Produce platform list
PLATFORMS=`cat make-platforms.txt | awk '{print $1}'` || exit 1

# Keep a list of all files copied, for deployment later
MANIFEST_FILE="output/${NAME}/${VERSION}/manifest.txt"

#------------------------------------------------------------------------
# Copy all native jars, if necessary
#

NATIVES=`cat projects/${NAME}/natives` || exit 1
case "${NATIVES}" in
  "normal")
    info "natives: normal"

    for PLATFORM in ${PLATFORMS}
    do
      OUTPUT_NAME="${NAME}-${VERSION}-natives-${PLATFORM}.jar"
      SOURCE="${INPUT}/jar/${NAME}-natives-${PLATFORM}.jar"
      TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
      copy "${SOURCE}" "${TARGET}"
      echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"
    done
    ;;
  "atomic")
    info "natives: atomic-natives"

    for PLATFORM in ${PLATFORMS}
    do
      OUTPUT_NAME="${NAME}-${VERSION}-natives-${PLATFORM}.jar"
      SOURCE="${INPUT}/jar/atomic/${NAME}-natives-${PLATFORM}.jar"
      TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
      copy "${SOURCE}" "${TARGET}"
      echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"
    done
    ;;
  "none")
    info "natives: not required"
    ;;
  *)
    fatal "unknown value in projects/${NAME}/natives - ${NATIVES}"
    ;;
esac

#------------------------------------------------------------------------
# Copy the correct jar file for the module.
#

MAIN_JAR=`cat projects/${NAME}/main-jar` || exit 1
case "${MAIN_JAR}" in
  "dummy")
    info "main-jar: dummy (empty.jar)"
    OUTPUT_NAME="${NAME}.jar"
    SOURCE="empty.jar"
    ;;
  "atomic")
    info "main-jar: atomic"
    OUTPUT_NAME="${NAME}.jar"
    SOURCE="${INPUT}/jar/atomic/${OUTPUT_NAME}"
    ;;
  "normal")
    info "main-jar: normal"
    OUTPUT_NAME="${NAME}.jar"
    SOURCE="${INPUT}/jar/${OUTPUT_NAME}"
    ;;
  *)
    fatal "unknown value in projects/${NAME}/main-jar - ${MAIN_JAR}"
    ;;
esac

TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
copy "${SOURCE}" "${TARGET}"
echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

#------------------------------------------------------------------------
# Copy dummy source code jars, if necessary
#

SRC_ZIP=`cat projects/${NAME}/source-zip` || exit 1
if [ "${SRC_ZIP}" = "dummy-src" ]
then
  info "source-zip: dummy source zip required"
  OUTPUT_NAME="${NAME}-${VERSION}-sources.jar"
  SOURCE="empty.jar"
else
  info "source-zip: ${INPUT}/${SRC_ZIP}"
  OUTPUT_NAME="${NAME}-${VERSION}-sources.jar"
  SOURCE="${INPUT}/${SRC_ZIP}"
fi
TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
copy "${SOURCE}" "${TARGET}"
echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

#------------------------------------------------------------------------
# Copy dummy jars to 'javadoc' jars, as we don't publish real versions of these yet.
#

OUTPUT_NAME="${NAME}-${VERSION}-javadoc.jar"
SOURCE="empty.jar"
TARGET="output/${NAME}/${VERSION}/${OUTPUT_NAME}"
copy "${SOURCE}" "${TARGET}"
echo "${OUTPUT_NAME}" >> "${MANIFEST_FILE}"

#------------------------------------------------------------------------
# Copy atomics, if necessary
#

ATOMICS=`cat projects/${NAME}/atomics` || exit 1
if [ ! -z "${ATOMICS}" ]
then
  info "atomics: ${ATOMICS}"
  for ATOMIC in ${ATOMICS}
  do
    JAR_NAME="${NAME}-${VERSION}-${ATOMIC}.jar"
    SOURCE="${INPUT}/jar/atomic/${NAME}-${ATOMIC}.jar"
    TARGET="output/${NAME}/${VERSION}/${JAR_NAME}"
    copy "${SOURCE}" "${TARGET}"
    echo "${JAR_NAME}" >> "${MANIFEST_FILE}"
  done
else
  info "atomics: no atomics required"
fi