This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch pd-store in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
commit d5fa5c8e33330393c90a608a4b7ab5559c125be8 Author: V_Galaxy <[email protected]> AuthorDate: Fri Aug 25 15:20:44 2023 +0800 chore(dist): replace wget to curl to download swagger-ui (#2277) Main Changes: 1. replace `wget` by `curl` when downloading `swagger-ui` 2. silence the output of `curl` and `tar` commands 3. reuse the existing `v4.15.5.tar.gz` before downloading 4. avoid downloading `swagger-ui` in non-Linux platforms to prevent build failures (there might be a cross-platform build approach available 🤔) 5. wrapp the script content within `<![CDATA[ ... ]]>` blocks ensures that the script retains its original format when generating the `dist.sh` script (also suppresses automatic indentation) 6. remove intermediate files at the end of the script **An alternative approach**, during the generation of the `dist.sh` script, only the `${final.name}` property from the build process is utilized. It might be possible to separately store a `dist.sh` script within hugegraph-dist, then use `sed` during the build process to replace the value of `${final.name}`, **thereby avoiding the need to embed script content within the pom file**. --------- Co-authored-by: imbajin <[email protected]> --- hugegraph-server/hugegraph-dist/dist.sh | 46 +++++++ hugegraph-server/hugegraph-dist/pom.xml | 232 ++++++++++++++++++++++---------- pom.xml | 26 ++++ 3 files changed, 234 insertions(+), 70 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/dist.sh b/hugegraph-server/hugegraph-dist/dist.sh new file mode 100644 index 000000000..64029d49a --- /dev/null +++ b/hugegraph-server/hugegraph-dist/dist.sh @@ -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`' diff --git a/hugegraph-server/hugegraph-dist/pom.xml b/hugegraph-server/hugegraph-dist/pom.xml index fe2287f59..8a9738dda 100644 --- a/hugegraph-server/hugegraph-dist/pom.xml +++ b/hugegraph-server/hugegraph-dist/pom.xml @@ -129,30 +129,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> @@ -173,52 +149,168 @@ </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 zxf 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 - rm -rfv swagger-ui-4.15.5 dist.sh - </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> + + <pluginManagement> + <plugins> + <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> + <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> + <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> + </executions> + </plugin> + </plugins> + </pluginManagement> </build> + + <profiles> + <profile> + <id>assembly-hugegraph</id> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + </plugin> + </plugins> + </build> + <activation> + <!-- usage refer: https://github.com/apache/hugegraph/pull/2277 --> + <property> + <name>!skip-assembly-hugegraph</name> + </property> + </activation> + </profile> + <profile> + <id>unix-package</id> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + </plugin> + </plugins> + </build> + <activation> + <os> + <family>unix</family> + <name>Linux</name> + </os> + </activation> + </profile> + <profile> + <id>mac-package</id> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + </plugin> + </plugins> + </build> + <activation> + <os> + <family>mac</family> + </os> + </activation> + </profile> + <profile> + <id>tar-package</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.8</version> + <executions> + <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> + </build> + <activation> + <!-- usage refer: https://github.com/apache/incubator-hugegraph/pull/2277 --> + <property> + <name>!skip-tar-package</name> + </property> + </activation> + </profile> + </profiles> </project> diff --git a/pom.xml b/pom.xml index 8a98fd6f1..aacd037ed 100644 --- a/pom.xml +++ b/pom.xml @@ -146,6 +146,32 @@ <consoleOutput>true</consoleOutput> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <executions> + <execution> + <id>enforce-version</id> + <goals> + <goal>enforce</goal> + </goals> + <!-- no need to execute in child POMs --> + <inherited>false</inherited> + <configuration> + <rules> + <!-- TODO: uncomment for checking dependency conflicts --> + <!-- <DependencyConvergence/> --> + <requireJavaVersion> + <version>[1.8,12)</version> + </requireJavaVersion> + <requireMavenVersion> + <version>[3.5.0,)</version> + </requireMavenVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> </plugins> </pluginManagement> </build>
