Skip to content

Commit a60bae1

Browse files
committed
[hotfix] Automatically add licence headers to generated model classes
1 parent 9cbeed0 commit a60bae1

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

create-client-model.sh

+41-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,50 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Add Apache license header to a file
18+
add_license_header() {
19+
local license="\
20+
/*
21+
* Licensed to the Apache Software Foundation (ASF) under one
22+
* or more contributor license agreements. See the NOTICE file
23+
* distributed with this work for additional information
24+
* regarding copyright ownership. The ASF licenses this file
25+
* to you under the Apache License, Version 2.0 (the
26+
* \"License\"); you may not use this file except in compliance
27+
* with the License. You may obtain a copy of the License at
28+
*
29+
* http://www.apache.org/licenses/LICENSE-2.0
30+
*
31+
* Unless required by applicable law or agreed to in writing,
32+
* software distributed under the License is distributed on an
33+
* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
34+
* KIND, either express or implied. See the License for the
35+
* specific language governing permissions and limitations
36+
* under the License.
37+
*/"
38+
39+
local file="$1"
40+
local temp_file="${file}.tmp"
41+
42+
echo "$license" > "$temp_file"
43+
cat "$file" >> "$temp_file"
44+
mv "$temp_file" "$file"
45+
}
46+
1747
# generate model
1848
mvn typescript-generator:generate -f streampipes-model/pom.xml
1949

50+
# add license header to the generated model file
51+
add_license_header streampipes-model/target/typescript-generator/streampipes-model.ts
52+
53+
# copy the model file to the UI project
54+
cp streampipes-model/target/typescript-generator/streampipes-model.ts ui/projects/streampipes/platform-services/src/lib/model/gen/
55+
2056
# generate model-client
2157
mvn typescript-generator:generate -f streampipes-model-client/pom.xml
2258

23-
# copy files
24-
mv streampipes-model/target/typescript-generator/streampipes-model.ts ui/projects/streampipes/platform-services/src/lib/model/gen/
25-
mv streampipes-model-client/target/typescript-generator/streampipes-model-client.ts ui/projects/streampipes/platform-services/src/lib/model/gen/
59+
# add license header to the generated model-client file
60+
add_license_header streampipes-model-client/target/typescript-generator/streampipes-model-client.ts
61+
62+
# copy the model-client file to the UI project
63+
cp streampipes-model-client/target/typescript-generator/streampipes-model-client.ts ui/projects/streampipes/platform-services/src/lib/model/gen/

0 commit comments

Comments
 (0)