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 8 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
46 changes: 46 additions & 0 deletions hugegraph-dist/dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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`'
69 changes: 0 additions & 69 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 @@ -124,30 +124,6 @@
</resources>

<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>assembly-hugegraph</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${top.level.dir}
</outputDirectory>
<descriptor>
${assembly.descriptor.dir}/assembly.xml
</descriptor>
<finalName>${final.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand All @@ -168,51 +144,6 @@
</filesets>
</configuration>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-swagger-ui</id>
<phase>package</phase>
<goals>
<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>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<tar destfile="${final.destfile}" compression="gzip">
<tarfileset dir="${top.level.dir}/" filemode="755">
<include name="${final.name}/**"/>
</tarfileset>
</tar>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
153 changes: 153 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,93 @@
<consoleOutput>true</consoleOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>assembly-hugegraph</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${top.level.dir}
</outputDirectory>
<descriptor>
${assembly.descriptor.dir}/assembly.xml
</descriptor>
VGalaxies marked this conversation as resolved.
Show resolved Hide resolved
<finalName>${final.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>download-swagger-ui</id>
<phase>prepare-package</phase>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this step will not be inherited by other modules?

<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="${shell-executable}"
dir="${project.basedir}"
failonerror="false">
<arg line="./dist.sh"/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>install-swagger-ui</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<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>
</target>
</configuration>
</execution>
<execution>
<id>tar-package</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<tar destfile="${final.destfile}" compression="gzip">
<tarfileset dir="${top.level.dir}/" filemode="755">
<include name="${final.name}/**"/>
</tarfileset>
</tar>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

Expand Down Expand Up @@ -676,8 +763,74 @@
</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>
<profile>
<id>unix-package</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
imbajin marked this conversation as resolved.
Show resolved Hide resolved
</os>
<file>
<exists>dist.sh</exists>
</file>
</activation>
</profile>
<profile>
<id>mac-package</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
<activation>
<os>
<family>mac</family>
</os>
<file>
<exists>dist.sh</exists>
</file>
</activation>
</profile>
</profiles>
</project>