Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dist): replace wget to curl to download swagger-ui #2277

Merged
merged 20 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions hugegraph-dist/dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with this
# work for additional information regarding copyright ownership. The ASF
# licenses this file to You under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
VERSION=4.15.5
curl --version >/dev/null 2>&1 ||
{
echo 'ERROR: Please install `curl` first if you need `swagger-ui`'
exit
}
# TODO: perhaps it's necessary verify the checksum before reusing the existing tar
if [ ! -f v$VERSION.tar.gz ]; then
curl -s -S -L -o v$VERSION.tar.gz \
https://github.com/swagger-api/swagger-ui/archive/refs/tags/v$VERSION.tar.gz ||
{
echo 'ERROR: Download `swagger-ui` failed, please check your network connection'
exit
}
fi
tar zxf v$VERSION.tar.gz -C . >/dev/null 2>&1
echo "window.onload = function() { window.ui = SwaggerUIBundle({
url:'/openapi.json',dom_id:'#swagger-ui',deepLinking:true,layout:'StandaloneLayout',
presets:[SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ],
plugins:[SwaggerUIBundle.plugins.DownloadUrl]});};" > \
swagger-ui-$VERSION/dist/swagger-initializer.js
# conceal the VERSION from the outside
mv swagger-ui-$VERSION swagger-ui
echo 'INFO: Successfully download `swagger-ui`'
60 changes: 45 additions & 15 deletions hugegraph-dist/pom.xml
imbajin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,38 @@
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo file="${project.basedir}/dist.sh">
wget --version 1>/dev/null || exit
wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.15.5.tar.gz
tar zxvf v4.15.5.tar.gz
echo "window.onload = function() { window.ui = SwaggerUIBundle({
url:'/openapi.json',dom_id:'#swagger-ui',deepLinking:true,layout:'StandaloneLayout',
presets:[SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ],
plugins:[SwaggerUIBundle.plugins.DownloadUrl]});};" > swagger-ui-4.15.5/dist/swagger-initializer.js
cp -r swagger-ui-4.15.5/dist ../${final.name}/swagger-ui
</echo>
<exec executable="${shell-executable}" dir="${project.basedir}" failonerror="true">
<arg line="./dist.sh"/>
</exec>
</tasks>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath"/>
<if>
imbajin marked this conversation as resolved.
Show resolved Hide resolved
<contains string="${os.name}" substring="Linux"/>
<then>
<exec executable="${shell-executable}"
dir="${project.basedir}"
failonerror="false">
<arg line="./dist.sh"/>
</exec>
<exec executable="cp"
dir="${project.basedir}"
failonerror="false">
<arg value="-r"/>
<arg value="swagger-ui/dist"/>
<arg value="../${final.name}/swagger-ui"/>
</exec>
<exec executable="rm"
dir="${project.basedir}"
failonerror="false">
<arg value="-rf"/>
<arg value="swagger-ui"/>
</exec>
</then>
<else>
<!-- WARN: keep msg in one line -->
<echo
message="We only download swagger-ui in Linux env, you could check pom.xml in hugegraph-dist to modify it"/>
</else>
</if>
</target>
</configuration>
</execution>
<execution>
Expand All @@ -212,6 +229,19 @@
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
imbajin marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,29 @@
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-all</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<DependencyConvergence/>
<requireJavaVersion>
<version>[1.8,12)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.5.0,)</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down