解包依赖项需要很长时间

Posted

技术标签:

【中文标题】解包依赖项需要很长时间【英文标题】:unpacking dependencies is taking very very long time 【发布时间】:2021-02-21 04:50:12 【问题描述】:

您好,我有一个带有模块的 Maven,在 intellij 中使用全新安装构建该模块时,完成构建需要很长时间。 这是我的 pom 文件

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.blah.cdo.hook</groupId>
    <artifactId>committerIdentityHook</artifactId>
    <version>0.11-SNAPSHOT</version>

    <organization>
        <name>CTO - blah</name>
        <url>http://www.blah.com/</url>
    </organization>

    <name>blah test Hook-5.16.3</name>
    <description>Verify commit author’s email address against HR Feed. Functional accounts adhere to this format:
        FID@blah.blah.com
    </description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-api</artifactId>
            <version>$bitbucket.version</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-spi</artifactId>
            <version>$bitbucket.version</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>apache-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>

        <dependency>
            <groupId>oracle.jdbc</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>12.1.0.2.0</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>1.7.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito2</artifactId>
            <version>1.7.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>1.7.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <classifier>runtime</classifier>
            <scope>test</scope>
            <version>0.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.blah.cto.bbengarch</groupId>
            <artifactId>AppEncryptDecrypt</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                <version>$amps.version</version>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>bitbucket</id>
                            <instanceId>bitbucket</instanceId>
                            <version>$bitbucket.version</version>
                            <dataVersion>$bitbucket.data.version</dataVersion>
                        </product>
                    </products>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>1.2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>

                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>$maven.compiler.source</source>
                    <target>$maven.compiler.target</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <systemPropertyVariables>
                        <jacoco-agent.destfile>$project.build.directory/jacoco/jacoco.exec</jacoco-agent.destfile>
                        <testEnvironment>true</testEnvironment>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.0</version>
                <executions>
                    <execution>
                        <id>default-instrument</id>
                        <goals>
                            <goal>instrument</goal>
                        </goals>

                    </execution>
                    <execution>
                        <id>default-restore-instrumented-classes</id>
                        <goals>
                            <goal>restore-instrumented-classes</goal>
                        </goals>

                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>$basedir/target/jacoco/jacoco.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
        <bitbucket.version>5.16.2</bitbucket.version>
        <bitbucket.data.version>$bitbucket.version</bitbucket.data.version>
        <amps.version>6.2.0</amps.version>
        <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <java.version>1.8</java.version>
    </properties>

    <scm>
        <connection>https://bitbucketdc-cluster04.blah.net/scm/bbengarch/committervalidator-hook.git</connection>
        <developerConnection>
            scm:git:https://bitbucketdc-cluster04.blah.net/scm/bbengarch/committervalidator-hook.git
        </developerConnection>
        <url>https://bitbucketdc-cluster04.blah.net/scm/bbengarch/committervalidator-hook.git</url>
        <tag>HEAD</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>JULES</id>
            <url>https://repo.blah.net/maven/content/repositories/BBENGARCH-SNAPSHOT/</url>
        </snapshotRepository>
        <repository>
            <id>JULES</id>
            <url>https://repo.blah.net/maven/content/repositories/BBENGARCH/</url>
        </repository>
    </distributionManagement>
</project>

在构建 jar 时 --- bitbucket-maven-plugin:6.2.0:copy-bundled-dependencies (default-copy-bundled-dependencies) @ committerIdentityHook --- 阶段 它需要很长时间,比如 1 小时 - 2小时。每次我改变一些东西,如果想用新的改变重建罐子,这对我来说变得非常困难。 下面是需要很长时间的解包依赖项。还有一些其他的,但我观察到这需要很长时间。 解压 c:\FAST\maven_repo\v360\oracle\jdbc\ojdbc6\12.1.0.2.0\ojdbc6-12.1.0.2.0.jar 到 H:\Susmitha\Projects\commhookcode-nov7\committervalidator-hook\commiterValidator-5.16 .3\target\classes 包含“”并排除“atlassian-plugin.xml,META-INF/MANIFEST.MF,META-INF/.DSA,META-INF/.SF”

请告诉我为什么需要很长时间以及如何简单地构建我的 jar。

谢谢。

【问题讨论】:

【参考方案1】:

我认为您问题的根源在于您的H: 文件系统的性能。根据驱动器名称,我猜测它实际上是一个 Windows 网络共享;即当您访问 H: 时,您的系统正在使用 SMB 与单独文件服务器上的文件系统通信,

问题在于 SMB 不是一个快速的协议,尤其是当您创建大量文件时。当您将 JAR 文件解压缩到网络共享中时,您将创建许多相对较小的文件。

我的建议:

更改构建设置,使构建目录位于本地驱动器上。

如果构建仍然不够快,请考虑将构建平台更改为 Linux 机器...因为 Linux 通常具有比 Windows 更好的文件系统性能。

【讨论】:

非常感谢。我将代码移到其他驱动器并尝试构建。它确实奏效了。只用了 46 秒。

以上是关于解包依赖项需要很长时间的主要内容,如果未能解决你的问题,请参考以下文章

这需要很长时间

为啥在 Alpine Linux 上安装 Pandas 需要很长时间

Excel 加载项需要很长时间才能保存

截断具有许多子分区的表需要很长时间

创建GSI需要很长时间

uniapp运行到小程序需要很长时间