Skip to content

Commit

Permalink
调整 ui 和 api 的打包结构,增加versions-maven-plugin (#217)
Browse files Browse the repository at this point in the history
* 调整 JVM 参数适应高版本 JDK,移除内存优化参数,不分不适用,移除 DS copy

* 调整ui的打包,使无需copy dist到api resource;增加versions-maven-plugin
  • Loading branch information
zhzhenqin authored Mar 15, 2023
1 parent 83471ff commit a6ff27c
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 181 deletions.
57 changes: 23 additions & 34 deletions datasophon-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>datasophon</artifactId>
<groupId>com.datasophon</groupId>
<artifactId>datasophon</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>datasophon-api</artifactId>

Expand All @@ -43,8 +41,8 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -95,12 +93,18 @@
<dependency>
<groupId>com.datasophon</groupId>
<artifactId>datasophon-dao</artifactId>
<version>1.1.0</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.datasophon</groupId>
<artifactId>datasophon-common</artifactId>
<version>1.1.0</version>
<version>${project.version}</version>
</dependency>
<!-- ui 工程打包是一个空包,这里依赖主要是让 ui 先编译,这样前端就能自动打包到 tar 介质中-->
<dependency>
<groupId>com.datasophon</groupId>
<artifactId>datasophon-ui</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
Expand All @@ -115,7 +119,6 @@
<artifactId>akka-persistence_2.11</artifactId>
</dependency>


<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
Expand All @@ -131,60 +134,46 @@
<scope>test</scope>
</dependency>


</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-lib</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<!-- 打包后的包名是否包含assembly的id名 -->
<appendAssemblyId>false</appendAssemblyId>
<!-- 指定最后tar或者zip包的名字 -->
<finalName>datasophon-manager-${project.version}</finalName>
<!-- tar或者zip包的输出目录 -->
<outputDirectory>target/</outputDirectory>
<outputDirectory>${project.basedir}/target/</outputDirectory>
<descriptors>
<!-- 引用的assembly配置文件-->
<descriptor>src/main/resources/assembly.xml</descriptor>
<descriptor>${project.basedir}/src/main/resources/assembly.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass />
</manifest>
</archive>
</configuration>
<executions>
<!-- phase加入package后,则在执行maven package时就可以调用maven-assembly-plugin插件定义的打包方式 -->
<execution>
<!--名字任意 -->
<id>make-assembly</id>
<!-- 绑定到package生命周期阶段上 -->
<phase>package</phase>
<goals>
<!-- 只运行一次 -->
<goal>single</goal>
</goals>
<!-- 绑定到package生命周期阶段上 -->
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
44 changes: 32 additions & 12 deletions datasophon-api/src/main/resources/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
<excludes>
<!-- 排除该包,否则多个日志框架导致无法直接启动,需要手动删除 -->
<exclude>*:log4j</exclude>
<exclude>*:slf4j-log4j12</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<!--拷贝application.yml文件到jar包的外部conf目录下面-->
<fileSet>
Expand Down Expand Up @@ -77,8 +90,10 @@
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
<directoryMode>0755</directoryMode>
<filtered>true</filtered>
<outputDirectory>bin</outputDirectory>
<!-- Linux 脚本,需要打包为 unix 格式,否则换行可能有问题 -->
<lineEnding>unix</lineEnding>
</fileSet>

Expand All @@ -90,30 +105,35 @@
<fileSet>
<directory>${basedir}/src/main/resources/jmx</directory>
<outputDirectory>jmx</outputDirectory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/../datasophon-api/src/main/resources/sql</directory>
<outputDirectory>sql</outputDirectory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
</fileSet>

<!--拷贝lib包到jar包的外部lib下面-->
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>lib</outputDirectory>
<!-- 打包需要包含的文件 -->
<directory>${basedir}/../datasophon-ui/dist</directory>
<outputDirectory>/conf/front/views</outputDirectory>
<includes>
<include>*.jar</include>
<include>*.html</include>
<include>*.ico</include>
<include>*.js</include>
</includes>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>lib</outputDirectory>
<!-- 打包需要包含的文件 -->
<directory>${basedir}/../datasophon-ui/dist</directory>
<outputDirectory>/conf/front/static/resources/bundle-main</outputDirectory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
<includes>
<include>datasophon-api-${project.version}.jar</include>
<include>css/**</include>
<include>static/**</include>
</includes>
</fileSet>


</fileSets>
</assembly>
104 changes: 63 additions & 41 deletions datasophon-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,61 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>datasophon</artifactId>
<groupId>com.datasophon</groupId>
<artifactId>datasophon</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>datasophon-ui</artifactId>

<properties>
<build.node.version>v12.16.3</build.node.version>
<build.npm.version>6.14.4</build.npm.version>
<nodemodules.dir>node_modules</nodemodules.dir>
<dist.dir>dist</dist.dir>
<deployed.dir>.deployed</deployed.dir>
<dist.dir>dist</dist.dir>
<nodemodules.dir>node_modules</nodemodules.dir>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<!--<skip>true</skip>-->
<failOnError>false</failOnError>
<!--当配置true时,只清理filesets里的文件,构建目录中得文件不被清理.默认是flase.-->
<excludeDefaultDirectories>false</excludeDefaultDirectories>
<filesets>
<fileset>
<!--要清理的目录位置-->
<directory>${basedir}/dist</directory>
<!--是否跟随符号链接 (symbolic links)-->
<followSymlinks>false</followSymlinks>
<!--默认有些文件是不会被清理的,比如.svn文件,如果设置成false,则全部按照自定义的来处理-->
<useDefaultExcludes>true</useDefaultExcludes>
<!--对这些文件进行清理-->
</fileset>
</filesets>
</configuration>
</plugin>

<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.10.3</version>
<configuration>
<nodeVersion>${build.node.version}</nodeVersion>
<npmVersion>${build.npm.version}</npmVersion>

<nodeDownloadRoot>https://npm.taobao.org/mirrors/node/</nodeDownloadRoot>
<npmDownloadRoot>https://registry.npm.taobao.org/npm/-/</npmDownloadRoot>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
Expand All @@ -57,38 +85,32 @@
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install --registry=https://registry.npm.taobao.org --sass-binary-site=https://npm.taobao.org/mirrors/node-sass
</arguments>
<arguments>install --registry=https://registry.npm.taobao.org --sass-binary-site=https://npm.taobao.org/mirrors/node-sass</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>install</phase>
<phase>package</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>npm run deploy</id>
<goals>
<goal>npm</goal>
</goals>
<phase>install</phase>
<configuration>
<arguments>run deploy</arguments>
</configuration>
</execution>
<!-- deploy copy 这里无需再 copy 了,打包时,直接在 dist 下打包了
<execution>
<id>npm run deploy</id>
<goals>
<goal>npm</goal>
</goals>
<phase>install</phase>
<configuration>
<arguments>run deploy</arguments>
</configuration>
</execution>
-->
</executions>
<configuration>
<nodeVersion>${build.node.version}</nodeVersion>
<npmVersion>${build.npm.version}</npmVersion>

<nodeDownloadRoot>https://npm.taobao.org/mirrors/node/</nodeDownloadRoot>
<npmDownloadRoot>https://registry.npm.taobao.org/npm/-/</npmDownloadRoot>
</configuration>
</plugin>
</plugins>
</build>
Expand All @@ -101,21 +123,21 @@
</os>
</activation>
<properties>
<envClassifier>win</envClassifier>
<args.brunch>/C brunch</args.brunch>
<args.mkdir>/C mkdir</args.mkdir>
<args.npm>/C npm</args.npm>
<args.rm.clean>/C rmdir /S /Q</args.rm.clean>
<args.shell>/C</args.shell>
<dirsep>\</dirsep>
<envClassifier>win</envClassifier>
<executable.brunch>cmd</executable.brunch>
<executable.gzip>${basedir}\gzip-content.cmd</executable.gzip>
<args.brunch>/C brunch</args.brunch>
<node.executable>node.exe</node.executable>
<executable.mkdir>cmd</executable.mkdir>
<args.mkdir>/C mkdir</args.mkdir>
<executable.npm>cmd</executable.npm>
<args.npm>/C npm</args.npm>
<executable.rmdir>cmd</executable.rmdir>
<args.rm.clean>/C rmdir /S /Q</args.rm.clean>
<executable.shell>cmd</executable.shell>
<fileextension.shell>cmd</fileextension.shell>
<args.shell>/C</args.shell>
<node.executable>node.exe</node.executable>
</properties>
</profile>
<profile>
Expand All @@ -126,21 +148,21 @@
</os>
</activation>
<properties>
<envClassifier>linux</envClassifier>
<args.brunch />
<args.mkdir />
<args.npm />
<args.rm.clean>-rf</args.rm.clean>
<args.shell />
<dirsep>/</dirsep>
<envClassifier>linux</envClassifier>
<executable.brunch>brunch</executable.brunch>
<executable.gzip>gzip</executable.gzip>
<args.brunch/>
<node.executable>node</node.executable>
<executable.mkdir>mkdir</executable.mkdir>
<args.mkdir/>
<executable.npm>npm</executable.npm>
<args.npm/>
<executable.rmdir>rm</executable.rmdir>
<args.rm.clean>-rf</args.rm.clean>
<executable.shell>sh</executable.shell>
<fileextension.shell>sh</fileextension.shell>
<args.shell/>
<node.executable>node</node.executable>
</properties>
</profile>
</profiles>
Expand Down
Loading

0 comments on commit a6ff27c

Please sign in to comment.