Maven Ant任务。传递性(pom)依赖项和HTTPS问题

5

正如你所知, 从2020年1月15日开始,Maven中央仓库要求仅支持HTTPS访问。我们的一个项目正在使用Ant和Maven Ant Tasks(仅用于依赖管理)。是的,我知道它已被弃用,但在旧的ant构建中使用pom.xml还有其他选择吗?

看起来Maven Ant Tasks存在一个bug,如果依赖树包含指向pom的链接,则始终会通过HTTP访问它(尽管本地配置了https://repo.maven.apache.org/maven2)。

有什么解决这个问题的想法吗?

P.S. 是的,这是工作配置(即通过HTTP工作),并且pom文件具有正确的参数

pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc</groupId>
  <artifactId>Test</artifactId>
  <version>4.5-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client</artifactId>
            <version>8.4.5</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>

build.xml的一部分

<artifact:dependencies filesetid="maven.classpath">
    <pom file="../pom.xml" />
</artifact:dependencies>

输出的一部分

[artifact:dependencies] Downloading: com/vaadin/vaadin-client/8.4.5/vaadin-client-8.4.5.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 6K from central
[artifact:dependencies] Downloading: com/vaadin/vaadin-root/8.4.5/vaadin-root-8.4.5.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 40K from central
[artifact:dependencies] Downloading: com/vaadin/vaadin-parent/1.1.0/vaadin-parent-1.1.0.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 8K from central
[artifact:dependencies] Downloading: com/vaadin/vaadin-shared/8.4.5/vaadin-shared-8.4.5.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 7K from central
[artifact:dependencies] Downloading: com/vaadin/vaadin-server/8.4.5/vaadin-server-8.4.5.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 13K from central
[artifact:dependencies] Downloading: org/jsoup/jsoup/1.11.2/jsoup-1.11.2.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 8K from central
[artifact:dependencies] Downloading: com/vaadin/external/gentyref/1.2.0.vaadin1/gentyref-1.2.0.vaadin1.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 5K from central
[artifact:dependencies] Downloading: com/google/gwt/gwt-elemental/2.8.2/gwt-elemental-2.8.2.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 1K from central
[artifact:dependencies] Downloading: com/google/gwt/gwt/2.8.2/gwt-2.8.2.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 9K from central
[artifact:dependencies] Downloading: org/sonatype/oss/oss-parent/4/oss-parent-4.pom from repository central at https://repo.maven.apache.org/maven2
[artifact:dependencies] Transferring 4K from central
[artifact:dependencies] Downloading: com/google/web/bindery/requestfactory/2.8.2/requestfactory-2.8.2.pom from repository central at http://repo1.maven.org/maven2
[artifact:dependencies] Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/com/google/web/bindery/requestfactory/2.8.2/requestfactory-2.8.2.pom
[artifact:dependencies] [WARNING] Unable to get resource 'com.google.web.bindery:requestfactory:pom:2.8.2' from repository central (http://repo1.maven.org/maven2): Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/com/google/web/bindery/requestfactory/2.8.2/requestfactory-2.8.2.pom
[artifact:dependencies] An error has occurred while processing the Maven artifact tasks.
[artifact:dependencies]  Diagnosis:
[artifact:dependencies] 
[artifact:dependencies] Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'com.google.gwt:gwt-elemental:jar': POM 'com.google.web.bindery:requestfactory' not found in repository: Unable to download the artifact from any repository
[artifact:dependencies] 
[artifact:dependencies]   com.google.web.bindery:requestfactory:pom:2.8.2
[artifact:dependencies] 
[artifact:dependencies] from the specified remote repositories:
[artifact:dependencies]   central (http://repo1.maven.org/maven2),
[artifact:dependencies]   sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
[artifact:dependencies] 
[artifact:dependencies]  for project com.google.web.bindery:requestfactory
[artifact:dependencies]   com.google.gwt:gwt-elemental:jar:2.8.2
[artifact:dependencies] 
[artifact:dependencies] from the specified remote repositories:
[artifact:dependencies]   central (https://repo.maven.apache.org/maven2),
[artifact:dependencies]   vaadin-snapshots (https://oss.sonatype.org/content/repositories/vaadin-snapshots/)
[artifact:dependencies] 
[artifact:dependencies] Path to dependency: 
[artifact:dependencies]     1) com.abc:Test:jar:4.5-SNAPSHOT
[artifact:dependencies]     2) com.vaadin:vaadin-client:jar:8.4.5
[artifact:dependencies] 
[artifact:dependencies] 

1
我强烈建议将项目仅迁移到Maven... - khmarbaise
3个回答

5

我们曾经也遇到过同样的问题,所以我调试了这个jar包,找出了可能存在的问题。结果发现你可以通过编辑位于jar包内部(相对路径)org\apache\maven\project下的pom-4.0.0.xml文件来轻松解决它。只需将url更改为https即可解决问题。


1
我在研究构建旧版Thrift时遇到了类似的问题。以下是我的解决方案:编辑build.xml文件,在artifact:dependencies块中添加一个remoteRepository
示例:
    <artifact:dependencies filesetId="build-dependency-jars" pomRefId="pom">
      <remoteRepository id="mavenCentral" url="https://repo1.maven.org/maven2"/>
    </artifact:dependencies>

1
你尝试过手动安装吗?
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

谢谢你的提示。实际上,我已经为我的特定情况找到了一个解决方法,但问题的目标有些不同。这个库(Maven Ant Task)是否仍然可用(想象一下,在CI服务器和其他专用PC上手动安装它和类似的依赖项)。这不是我想要实现的结果。 - FoxyBOA

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接