在与aws codeartifact for maven repo集成后,在aws codebuild中增加maven构建时间

xn1cxnb4  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(367)

当aws代码构建从https://repo1.maven.org/maven2 构建时间大约为60秒(这是下载jar、构建和运行测试的时间)。
但是在更新maven repos以从aws codeartifact服务加载(即我在aws codeartifact中创建了一个存储库以连接到maven中央存储库)之后,构建时间一直在200秒以上。
由于一个aws服务(aws codebuild)正在与同一区域中的另一个aws服务(aws codeartifact)进行通信,因此现在的构建时间应该不会更短。所以他们会使用aws网络,对吗?
有人能分享一些关于增加构建时间的信息吗?
更新:添加以下maven依赖项:

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.1.1.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
  <apache-commons.version>2.6</apache-commons.version>
  <java.version>11</java.version>
  <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
  <thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version>
  <thymeleaf-extras-java8time.version>3.0.3.RELEASE</thymeleaf-extras-java8time.version>
  <mybatis-starter.version>2.1.1</mybatis-starter.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>${mybatis-starter.version}</version>
  </dependency>

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-data-redis</artifactId>
  </dependency>

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.security.oauth.boot</groupId>
    <artifactId>spring-security-oauth2-autoconfigure</artifactId>
    <version>2.1.1.RELEASE</version>
  </dependency>
  <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-resource-server</artifactId>
  </dependency>

  <!-- AWS -->
  <dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>s3</artifactId>
  </dependency>
  <dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>apache-client</artifactId>
  </dependency>
  <dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>netty-nio-client</artifactId>
  </dependency>
  <dependency>
    <artifactId>aws-java-sdk-s3</artifactId>
    <groupId>com.amazonaws</groupId>
  </dependency>
  <!-- End of AWS -->

  <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-json -->
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-json</artifactId>
  </dependency>
  <dependency>
    <groupId>nz.net.ultraq.thymeleaf</groupId>
    <artifactId>thymeleaf-layout-dialect</artifactId>
  </dependency>

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
  </dependency>
  <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
  </dependency>
  <dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
  </dependency>

  <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>${apache-commons.version}</version>
  </dependency>

  <dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter-test</artifactId>
    <version>${mybatis-starter.version}</version>
    <scope>test</scope>
  </dependency>
</dependencies>
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>bom</artifactId>
      <version>2.10.42</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-bom</artifactId>
      <version>1.11.700</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>repackage</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack</id>
          <phase>package</phase>
          <goals>
            <goal>unpack</goal>
          </goals>
          <configuration>
            <artifactItems>
              <artifactItem>
                <groupId>${project.groupId}</groupId>
                <artifactId>${project.artifactId}</artifactId>
                <version>${project.version}</version>
              </artifactItem>
            </artifactItems>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>

</build>

下载依赖项时的代码生成日志示例:

[INFO] Scanning for projects...
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/bom/2.9.16/bom-2.9.16.pom
Progress (1): 4.1/47 kB
Progress (1): 8.2/47 kB
Progress (1): 12/47 kB 
Progress (1): 16/47 kB
Progress (1): 20/47 kB
Progress (1): 25/47 kB
Progress (1): 29/47 kB
Progress (1): 33/47 kB
Progress (1): 35/47 kB
Progress (1): 39/47 kB
Progress (1): 43/47 kB
Progress (1): 47 kB   

Downloaded from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/bom/2.9.16/bom-2.9.16.pom (47 kB at 46 kB/s)
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/aws-sdk-java-pom/2.9.16/aws-sdk-java-pom-2.9.16.pom
Progress (1): 4.1/57 kB
Progress (1): 8.2/57 kB
Progress (1): 12/57 kB 
Progress (1): 16/57 kB
Progress (1): 20/57 kB
Progress (1): 25/57 kB
Progress (1): 29/57 kB
Progress (1): 33/57 kB
Progress (1): 37/57 kB
Progress (1): 41/57 kB
Progress (1): 44/57 kB
Progress (1): 48/57 kB
Progress (1): 52/57 kB
Progress (1): 56/57 kB
Progress (1): 57 kB 

Downloaded from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/aws-sdk-java-pom/2.9.16/aws-sdk-java-pom-2.9.16.pom (57 kB at 118 kB/s)
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/com/amazonaws/aws-java-sdk-bom/1.11.657/aws-java-sdk-bom-1.11.657.pom
Progress (1): 4.1/41 kB
Progress (1): 8.2/41 kB
Progress (1): 12/41 kB 
Progress (1): 16/41 kB
Progress (1): 20/41 kB
Progress (1): 25/41 kB
Progress (1): 29/41 kB
Progress (1): 33/41 kB
Progress (1): 35/41 kB
Progress (1): 39/41 kB
Progress (1): 41 kB
eivgtgni

eivgtgni1#

maven中央存储库由一个为公共读访问优化的cdn提供服务。私有codeartifact存储库包括诸如aws身份验证、资产加密、上游存储库和影响每个请求时间的外部连接等功能。
aws codeartifact团队意识到性能不是您(或我们)想要的,特别是对于maven。感谢您提供了一组依赖项,以便我们可以使用它们来基线化和衡量我们的性能改进工作。我们计划明年改进这个。与此同时,您是否考虑过为aws代码构建启用缓存?

相关问题