如何让travis ci从不同的maven存储库下载JAR?

yyyllmsg  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(309)

我的java/scala项目使用maven作为构建工具,我想使用travisci来测试构建。我面临的问题是 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.

我猜特拉维斯是从https://repository.apache.org/content/repositories/releases/org/geotools 然后我开始 pom.xml 从下载 http://download.osgeo.org/webdav/geotools/ . 我怎么做 Mage .travis.yml 从不同的存储库下载jar文件?这是我的 .travis.yml 文件:

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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题