如何从不同的Maven存储库制作travis-ci下载jar?

问题描述

我的java / scala项目正在使用maven作为构建工具,我想使用travis-ci来测试构建。我面临的问题是我的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.sense.flink</groupId>
    <artifactId>explore-flink</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>explore-flink</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.8</jdk.version>
        <scala.binary.version>2.12</scala.binary.version>
        <flink.version>1.11.1</flink.version>
        <guava.version>29.0-jre</guava.version>
        <junit.version>4.12</junit.version>
        <scala.version>2.12.7</scala.version>
        <geotools.version>21.2</geotools.version>
    </properties>

    <repositories>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-metrics-dropwizard</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-twitter_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-planner_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-api-java</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-scala_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-kafka_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-statebackend-rocksdb_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.fusesource.mqtt-client</groupId>
            <artifactId>mqtt-client</artifactId>
            <version>1.15</version>
            <!-- <scope>provided</scope> -->
        </dependency>
        <dependency>
            <groupId>com.addthis</groupId>
            <artifactId>stream-lib</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.26</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.26</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.geotools/ -->
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-referencing</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <!-- <dependency> <groupId>org.geotools</groupId> <artifactId>gt-epsg-hsql</artifactId> 
            <version>${geotools.version}</version> </dependency> -->
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-epsg-wkt</artifactId>
            <version>${geotools.version}</version>
            <!-- <scope>test</scope> -->
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-geojsondatastore</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-metadata</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <!-- Make Scala available in project. Pay extra attention to the version -->
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>affinity</artifactId>
            <version>3.1.11</version>
        </dependency>
        <dependency>
            <groupId>io.airlift.tpch</groupId>
            <artifactId>tpch</artifactId>
            <version>0.10</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>4.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <finalName>explore-flink</finalName>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- download source code in Eclipse,best practice -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>

            <!-- Set a compiler level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version><!--$NO-MVN-MAN-VER$ -->
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Maven Shade Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.0</version>
                <!-- Run shade goal on package phase -->
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>org.apache.flink:*</exclude>
                                    <!-- Also exclude very big transitive dependencies of Flink WARNING: 
                                        You have to remove these excludes if your code relies on other versions of 
                                        these dependencies. -->
                                    <exclude>org.slf4j:*</exclude>
                                    <exclude>log4j:*</exclude>
                                    <exclude>com.typesafe:config:*</exclude>
                                    <exclude>junit:junit:*</exclude>
                                    <exclude>com.codahale.metrics:*</exclude>
                                </excludes>
                            </artifactSet>
                            <filters>
                                <filter>
                                    <artifact>org.apache.flink:*</artifact>
                                    <excludes>
                                        <!-- exclude shaded google but include shaded curator -->
                                        <exclude>org/apache/flink/shaded/com/**</exclude>
                                        <exclude>web-docs/**</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <!-- Do not copy the signatures in the META-INF folder. Otherwise,this might cause SecurityExceptions when using the JAR. -->
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <!-- If you want to use ./bin/flink run <quickstart jar> uncomment 
                                the following lines. This will add a Main-Class entry to the manifest file -->
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.sense.flink.App</mainClass>
                                </transformer>
                                <!-- This bit merges the various GeoTools META-INF/services files -->
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            </transformers>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

当我在travis-ci上构建项目时,出现此错误:

[WARNING] The POM for org.geotools:gt-referencing:jar:21.2 is missing,no dependency information available
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-epsg-wkt/21.2/gt-epsg-wkt-21.2.pom
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-epsg-wkt/21.2/gt-epsg-wkt-21.2.pom
[WARNING] The POM for org.geotools:gt-epsg-wkt:jar:21.2 is missing,no dependency information available
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-geojsondatastore/21.2/gt-geojsondatastore-21.2.pom
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-geojsondatastore/21.2/gt-geojsondatastore-21.2.pom
[WARNING] The POM for org.geotools:gt-geojsondatastore:jar:21.2 is missing,no dependency information available
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-metadata/21.2/gt-metadata-21.2.pom
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-metadata/21.2/gt-metadata-21.2.pom
[WARNING] The POM for org.geotools:gt-metadata:jar:21.2 is missing,no dependency information available
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-shapefile/21.2/gt-shapefile-21.2.pom
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-shapefile/21.2/gt-shapefile-21.2.pom
[WARNING] The POM for org.geotools:gt-shapefile:jar:21.2 is missing,no dependency information available
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-referencing/21.2/gt-referencing-21.2.jar
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-epsg-wkt/21.2/gt-epsg-wkt-21.2.jar
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-geojsondatastore/21.2/gt-geojsondatastore-21.2.jar
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-metadata/21.2/gt-metadata-21.2.jar
[INFO] Downloading from sonatype: https://oss.sonatype.org/content/repositories/releases/org/geotools/gt-shapefile/21.2/gt-shapefile-21.2.jar
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-referencing/21.2/gt-referencing-21.2.jar
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-epsg-wkt/21.2/gt-epsg-wkt-21.2.jar
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-geojsondatastore/21.2/gt-geojsondatastore-21.2.jar
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-metadata/21.2/gt-metadata-21.2.jar
[INFO] Downloading from sonatype-apache: https://repository.apache.org/content/repositories/releases/org/geotools/gt-shapefile/21.2/gt-shapefile-21.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.005 s
[INFO] Finished at: 2020-09-03T07:24:56Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project explore-flink: Could not resolve dependencies for project org.sense.flink:explore-flink:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.geotools:gt-referencing:jar:21.2,org.geotools:gt-epsg-wkt:jar:21.2,org.geotools:gt-geojsondatastore:jar:21.2,org.geotools:gt-metadata:jar:21.2,org.geotools:gt-shapefile:jar:21.2: Failure to find org.geotools:gt-referencing:jar:21.2 in https://maven-central.storage-download.googleapis.com/maven2/ was cached in the local repository,resolution will not be reattempted until the update interval of google-maven-central has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors,re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions,please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The command "eval mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying,3 of 3.

我猜是travis正在从https://repository.apache.org/content/repositories/releases/org/geotools下载源,并且我将pom.xml设置为从http://download.osgeo.org/webdav/geotools/下载。如何管理.travis.yml文件从其他存储库中下载罐子?这是我的.travis.yml文件:

language: java
sudo: false
jdk:
  - openjdk8
scala: 2.12.7
cache:
  directories:
    - $HOME/.m2
branches:
  only:
    - master
script: mvn clean package

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...