首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将上传到Nexus

将上传到Nexus
EN

Stack Overflow用户
提问于 2018-12-13 16:50:58
回答 1查看 968关注 0票数 3

我建立了一个反应应用程序使用创建-反应-应用程序。

生产建设是通过以下方式在Jenkins完成的:

npm install --prod npm run build

然后我就有了“准备部署”神器。

但是我怎样才能在我的Nexus上得到这个神器呢?

我可以使用package.json的版本吗?

在上传之前,我需要自己做一个拉链或者类似的东西吗?

这将是相当不错的历史,它将更容易/更快地从工件上构建码头比再次构建更容易。

你们是怎么解决的?谢谢你的回答。

EN

回答 1

Stack Overflow用户

发布于 2022-04-01 12:19:28

我知道这个问题很老,但它可能会对别人有所帮助。

我最近不得不做一些类似的事情。我的做法是:

  1. 将项目转换为Maven one
  2. pom.xml中配置私有存储库
代码语言:javascript
运行
复制
    <distributionManagement>
        <snapshotRepository>
            <id>RepoId</id>
            <url>http://.../repositories/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>RepoId</id>
            <url>http://.../repositories/releases/</url>
        </repository>
    </distributionManagement>
  1. 配置maven干净插件以清空build目录
代码语言:javascript
运行
复制
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>build</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
  1. 配置maven jar插件以跳过jar创建
代码语言:javascript
运行
复制
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-jar</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
  1. 集成前端-maven-插件 -我的项目需要纱线,但它也可以与npm一起运行。
代码语言:javascript
运行
复制
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <!-- install node & yarn -->
                    <execution>
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v16.13.0</nodeVersion>
                            <yarnVersion>v1.22.17</yarnVersion>
                        </configuration>
                    </execution>

                    <!-- yarn install -->
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                    </execution>

                    <!-- yarn run build -->
                    <execution>
                        <id>yarn run build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
  1. 集成maven程序集插件,以便将build目录下的所有内容打包到zip文件中。
代码语言:javascript
运行
复制
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <!-- pack everything under /build into a zip -->
                    <execution>
                        <id>create-distribution</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

其中assembly.xml看起来像:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <outputDirectory>/</outputDirectory>
            <directory>build</directory>
        </fileSet>
    </fileSets>
</assembly>
  1. 最后,运行mvn clean deploy以便将zip文件上传到nexus。

此外,我发现这个解决方案用于同步package.json版本和pom.xml版本,但我没有使用它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53766588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档