如何使用已发布的OLP模式依赖关系?

时间:2019-07-19 01:16:36

标签: maven here-olp

此问题是基于教程Build a Batch Pipeline with Maven Archetypes (Scala)的最小可重现示例,尽管我们无法在为客户建立的管道中消耗架构工件。

我们有一个单独的存储库,我们要从中发布(!/usr/bin/python import cv2 import numpy as np def fun(name): return 4 ./embedpy an fun download.jpeg )模式。我们运行的设置等效于(用您自己的唯一字符串替换mvn deploy):

djv

主要症状

在OLP Portal中,我可以在模式列表中看到我的新模式。它说明我可以像这样添加依赖项:

$ 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

但是,我无法在<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项目构建,因此{{1} }缓存。没有这些文件,下载将失败:

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] 并不会将构建{{1 }}子项目)。要将所需文件放入本地mvn deploy仓库中,我们需要从架构仓库的父目录(schema)中运行~/.m2

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

部分分辨率

按照Dependency Management · OLP SDK页上的工件服务部分中的说明进行操作。尽管构建的步伐进一步加快,但仍然无法消除依赖关系:

processor

2 个答案:

答案 0 :(得分:1)

OLP模式已部署到HERE Artifact Service。该服务需要特殊授权。为了下载模式或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

最好的问候, 迪玛

答案 1 :(得分: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目录运行mvn deploy时,从未上传schema POM。您无法从顶级mvn deploy目录运行nodecardinality

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

  <!-- <parent>
    <artifactId>nodecardinality</artifactId>
    <groupId>com.example.djv</groupId>
    <version>1.0.0</version>
  </parent> -->