1

这个问题是基于教程Build a Batch Pipeline with Maven Archetypes (Scala)的最小可重复示例,尽管我们无法在为客户构建的管道中使用模式工件。

我们有一个单独的存储库,我们想从中发布(mvn deploy)模式。我们运行相当于(替换djv为您自己的唯一字符串)的设置:

$ mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo.archetypes \
                         -DarchetypeArtifactId=pom-root \
                         -DarchetypeVersion=1.1 \
                         -DgroupId=com.example.djv \
                         -DartifactId=nodecardinality \
                         -Dversion=1.0.0 \
                         -Dpackage=com.example.djv.nodecardinality
...
$ cd nodecardinality
$ mvn archetype:generate -DarchetypeGroupId=com.here.platform.schema \
                         -DarchetypeArtifactId=project_archetype \
                         -DarchetypeVersion=1.0.13 \
                         -DgroupId=com.example.djv.nodecardinality \
                         -DartifactId=schema \
                         -Dversion=1.0.0 \
                         -Dpackage=com.example.djv.nodecardinality.schema \
                         -DmajorVersion=1
...
$ cat << EOF > schema/proto/src/main/proto/com/example/djv/nodecardinality/schema/v1/schema.proto
syntax = "proto3";
> 
> package com.example.djv.nodecardinality.schema.v1;
> 
> message NodeCardinalityPartition {
>   repeated NodeCardinality node_cardinality = 1;
> }
> 
> message NodeCardinality {
>   string id = 1;
>   uint32 cardinality = 2;
> }
> EOF
$ # <edit schema/ds/pom.xml per the tutorial>
$ cd schema
$ mvn deploy

主要症状

在 OLP 门户中,我可以在模式列表中看到我的新模式。它解释说我可以像这样添加对它的依赖:

<dependency> 
  <groupId>com.example.djv.nodecardinality</groupId> 
  <artifactId>schema_v1_scala_2.11</artifactId> 
  <version>1.0.0</version> 
  <type>jar</type> 
</dependency>

但是,我无法下载processor项目中的工件:

$ cd processor
$ mvn install
...
[INFO] Building processor Direct1toN Batch Processor in Scala 1.0.0                                                                                                                                                
[INFO] --------------------------------[ jar ]---------------------------------                                                                                                                                    
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom                                             
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom                                                         
Downloading from central: https://repo.maven.apache.org/maven2/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom                                                                                     
[INFO] ------------------------------------------------------------------------                                                                                                                                    
[INFO] BUILD FAILURE                                                                                                                                                                                               
...                                                                                                                                                                 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal on project processor: Could not resolve dependencies for project com.example.nodecardinality:processor:jar:1.0.0: Failed to collect dependencies at com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0: Failed to read artifact descriptor for com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0: Could not transfer artifact com.example.djv:nodecardinality:pom:1.0.0 from/to HERE_PLATFORM_ARTIFACT (here+artifact-service://artifact-service): Cannot access here+artifact-service://artifact-service with type here using the available connector factories: BasicRepositoryConnectorFactory: Cannot access here+artifact-service://artifact-service with type here using the available layout factories: Maven2RepositoryLayoutFactory: Unsupported repository layout here -> [Help 1]
...

我们看到这个失败只是因为我们在为项目运行processor的同一台机器上运行项目构建,mvn deploy因此缓存schema中存在一些文件。~/.m2如果没有这些文件,下载就会失败:

[INFO] --------------------------------[ jar ]---------------------------------                                                                                                                                    
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                   
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                               
Downloading from central: https://repo.maven.apache.org/maven2/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                                                           
[WARNING] The POM for com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0 is missing, no dependency information available                                                                               
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.jar                   
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.jar                               
Downloading from central: https://repo.maven.apache.org/maven2/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.jar                                                           
[INFO] ------------------------------------------------------------------------                                                                                                                                    
[INFO] BUILD FAILURE                                                                                                                                                                                               
...                                                                                                                                                                   
[INFO] ------------------------------------------------------------------------                                                                                                                                    
[ERROR] Failed to execute goal on project processor: Could not resolve dependencies for project com.example.nodecardinality:processor:jar:1.0.0: Could not find artifact com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0 in HERE_PLATFORM_REPO (https://repo.platform.here.com/artifactory/open-location-platform/) -> [Help 1] 

次要症状

正如我们在上面看到的,mvn deploy从本地schema目录运行并不会将构建所需的所有内容都放入本地~/.m2存储库(即构建processor子项目)。要将所需文件放入本地~/.m2存储库,我们需要从模式存储库mvn install的父目录 ( ) 运行。nodecardinality

这使我们至少可以在本地(临时)进行开发。

部分分辨率

按照依赖管理·OLP SDK页面上的工件服务部分中的说明进行操作。尽管构建变得更远,但它仍然无法提取依赖项:

[INFO] --------------------------------[ jar ]---------------------------------                                                                                                                                    
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                   
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                               
Downloading from HERE_PLATFORM_ARTIFACT: here+artifact-service://artifact-service/com.example.djv.nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom                                        
Downloaded from HERE_PLATFORM_ARTIFACT: here+artifact-service://artifact-service/com.example.djv.nodecardinality/schema_v1_scala_2.11/1.0.0/schema_v1_scala_2.11-1.0.0.pom (3.4 kB at 1.6 kB/s)                    
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/schema_v1/1.0.0/schema_v1-1.0.0.pom
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/schema_v1/1.0.0/schema_v1-1.0.0.pom
Downloading from HERE_PLATFORM_ARTIFACT: here+artifact-service://artifact-service/com.example.djv.nodecardinality/schema_v1/1.0.0/schema_v1-1.0.0.pom
Downloaded from HERE_PLATFORM_ARTIFACT: here+artifact-service://artifact-service/com.example.djv.nodecardinality/schema_v1/1.0.0/schema_v1-1.0.0.pom (8.0 kB at 6.3 kB/s)
Downloading from HERE_PLATFORM_REPO: https://repo.platform.here.com/artifactory/open-location-platform/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom
Downloading from OLP Public repo: https://artifactory.in.here.com/artifactory/here-olp-sit/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom
Downloading from HERE_PLATFORM_ARTIFACT: here+artifact-service://artifact-service/com.example.djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom
Downloading from central: https://repo.maven.apache.org/maven2/com/example/djv/nodecardinality/1.0.0/nodecardinality-1.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE                  
...
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project processor: Could not resolve dependencies for project com.example.nodecardinality:processor:jar:1.0.0: Failed to collect dependencies at com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0: Failed to read artifact descriptor for com.example.djv.nodecardinality:schema_v1_scala_2.11:jar:1.0.0: Could not find artifact com.example.djv:nodecardinality:pom:1.0.0 in HERE_PLATFORM_REPO (https://repo.platform.here.com/artifactory/open-location-platform/) -> [Help 1]
4

2 回答 2

1

OLP 模式部署到 HERE 工件服务。该服务需要特别授权。为了下载模式或 java/scala 绑定,您应该在项目中包含 Maven Wagon。请参考https://developer.here.com/olp/documentation/sdk-developer-guide/dev_guide/topics/dependency-management.html中的“工件服务”部分

简而言之:

将货车的版本添加为属性:

 <artifact.wagon.version>1.6.1</artifact.wagon.version>

将占位符存储库添加到存储库列表中:

  <repositories>
    <repository>
      <id>HERE_PLATFORM_ARTIFACT</id>
    <layout>default</layout>
    <url>here+artifact-service://artifact-service</url> 
  </repository>
  </repositories>

将插件参考放在构建部分:

 <extensions>
  <extension>
    <groupId>com.here.platform.artifact</groupId>
    <artifactId>artifact-wagon</artifactId>
    <version>${artifact.wagon.version}</version>
  </extension>
</extensions>

请注意,您需要保存在~/.here目录中的有效“credentials.properties”文件。如何获得它请阅读https://developer.here.com/olp/documentation/sdk-developer-guide/dev_guide/topics/get-credentials.html

最好的问候, 迪玛

于 2019-08-03T11:19:34.530 回答
0

问题是使用父 Maven 项目进行部署。查看问题中最后一个错误的最后一句话:

Could not find artifact com.example.djv:nodecardinality:pom:1.0.0 in HERE_PLATFORM_REPO

当我们从目录com.example.djv:nodecardinality:pom:1.0.0运行时,从未上传过 POM 。您不能从顶级目录运行。mvn deployschemamvn deploynodecardinality

pom.xml简单的解决方案是在schema运行之前从目录中删除父项目指针mvn deploy

  <!-- <parent>
    <artifactId>nodecardinality</artifactId>
    <groupId>com.example.djv</groupId>
    <version>1.0.0</version>
  </parent> -->
于 2019-07-19T16:05:25.217 回答