summaryrefslogtreecommitdiffstats
path: root/maven/make-copy-jars-one.sh
blob: a53a813b4ff26280d49d2f0ed162b28b802dee95 (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
#!/bin/sh

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

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
if [ "${NATIVES}" = "natives" ]
then
  info "natives: ${NATIVES}"

  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
else
  if [ "${NATIVES}" = "atomic-natives" ]
  then
    info "natives: ${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
  else
    info "natives: not required"
  fi
fi

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

DUMMY=`cat projects/${NAME}/dummy-jar` || exit 1
if [ "${DUMMY}" = "dummy-jar" ]
then
  info "dummy-jar: required"
  OUTPUT_NAME="${NAME}.jar"
  SOURCE="empty.jar"
else
  info "dummy-jar: not required (copying main jar)"
  # Copy main jar
  OUTPUT_NAME="${NAME}.jar"
  SOURCE="${INPUT}/jar/${OUTPUT_NAME}"
fi
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