如何使用Maven / travis从github存储库以zip / tar.gz打包,压缩和部署二进制文件到bintray.com通用存储库 - java

由于Github禁用了下载,因此我们需要使用新服务(例如Bintray.com)发布二进制文件。对于我们的用例,我需要构建一个包(使用appassembler-maven-plugin),然后对该构建进行zip和tar.gz并将其部署到bintray。

最好每天晚上由travis发行并通过mvn release插件发布。

当前pom看起来像这样:

<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>myproject</groupId>
    <artifactId>myproject</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <scm>
        <url>https://github.com/d0x/fromGithubToBintray</url>
        <connection>scm:git:git://github.com/d0x/fromGithubToBintray.git</connection>
        <developerConnection>scm:git:[email protected]:d0x/fromGithubToBintray.git</developerConnection>
    </scm>

    <developers>
        <developer>
            <name>Christian Schneider</name>
            <url>https://github.com/d0x</url>
            <id>d0x</id>
        </developer>
    </developers>

<!--    <distributionManagement> -->
<!--        <repository> -->
<!--            <id>bintray</id> -->
<!--            <url>https://api.bintray.com/maven/d0x/fromGithubToBintray/downloads</url> -->
<!--        </repository> -->
<!--    </distributionManagement> -->


    <properties>
        <mainClass>fromGithubToBintray.Main</mainClass>

        <java-version>1.7</java-version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <!-- ... -->        
    </dependencies>

    <build>
        <plugins>

            <!-- To build a clean binary pacakge to distribute -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <programs>
                        <program>
                            <mainClass>${mainClass}</mainClass>
                            <name>fromGithubToBintray</name>
                        </program>
                    </programs>

                    <extraJvmArguments>-Djava.awt.headless=true</extraJvmArguments>
                </configuration>
            </plugin>

            <!-- To specify the Java Version -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

如何调整pom文件来做到这一点?

复制:

我将小例子上传到了github:https://github.com/d0x/fromGithubToBintray

要执行此操作,请执行以下操作:

git clone https://github.com/d0x/fromGithubToBintray.git
cd fromGithubToBintray
mvn clean package appassembler:组装
chmod + x target / appassembler / bin / fromGithubToBintray
./target/appassembler/bin/fromGithubToBintray

这应该打印You did it!。现在的目标是上传压缩文件,并将此appassembler文件夹上传到Bintray。

研究完成:

This tutorial显示如何使用Bintray.com发布到Maven存储库。
我还看到Netty项目在Bintray上托管its downloads。但是在詹金斯的Poms中,我看不到与Bintray相关的东西。

参考方案

问题是Bintray不支持SNAPSHOT(Bintray仅用于发行版)。您需要的是Artifactory + Bintray组合,该组合将快照部署到Artifactory,并偶尔(当您离开时)向Bintray发行“可生产的”版本。

根据项目的性质,您可能有资格获得oss.jfrog.org上的免费帐户。要求您的交付物是JCenter中包含的开源库/产品。

从Artifactory推送到Bintray是一个非常简单的过程,您只需单击Artifactory UI中的按钮或执行REST调用即可执行该过程。请记住-它必须是发行版,而不是快照。

有多种方法可以将SNAPSHOT转换为发行版,包括手动更改POM中的版本,Maven发行插件等。
当您将oss.jfrog.org用作Artifactory服务器时,它包含一个特殊的插件,该插件可将SHAPSHOTs转换为发行版,并一次性部署到Bintray。

休眠映射<键,设置<值>> - java

我有以下表格:@Entity @Table(name = "events") Event --id --name @Entity @Table(name = "state") State --id --name @Entity @Table(name = "action") Action --id …

无法从ArrayList <String>转换为List <Comparable> - java

当我写下面的代码时,编译器说 无法从ArrayList<String>转换为List<Comparable>private List<Comparable> get(){ return new ArrayList<String>(); } 但是当我用通配符编写返回类型时,代码会编译。private List&l…

合并List <T>和List <Optional <T >> - java

鉴于: List<Integer> integers = new ArrayList<>(Arrays.asList( 10, 12 )); List<Optional<Integer>> optionalIntegers = Arrays.asList( Optional.of(5), Optional.em…

实例化类型<?>的泛型类 - java

我正在为SCJP / OCPJP学习,并且遇到了一个对我来说很奇怪的示例问题。该示例代码实例化了两个通用集合:List<?> list = new ArrayList<?>(); List<? extends Object> list2 = new ArrayList<? extends Object>(); …

List <Dog>是List <Animal>的子类吗?为什么Java泛型不是隐式多态的? - java

我对Java泛型如何处理继承/多态感到困惑。假设以下层次结构-动物(父母)狗-猫(儿童)因此,假设我有一个方法doSomething(List<Animal> animals)。根据继承和多态性的所有规则,我假设List<Dog>是List<Animal>,而List<Cat>是List<Animal&g…