2015-12-12 31 views
10

私はmavenに慣れていたのと同じように、artifacts(APK/aarファイル)の構築プロセスをgradleでセットアップしようとしています。GradleはArtifactoryの特定のリポジトリに公開します

mvn release:prepare (Adjusts version, checks into SVN, creates the tag) 
mvn release:perform -Dgoals=deploy (Pushes the artifact to http://artifactory.XXX.local/artifactory/libs-releases-local/) 

私はgradleコマンドを実行して同様の結果を得たいと考えています。私はhttps://github.com/researchgate/gradle-releaseプラグインをリリース管理に使用しています(これはうまくいきますので、私はリリースでうまくいきます)。私-LIB-アンドロイド-0.0.2 \> gradlew artifactoryPublish:私はコマンドgradlew artifactoryPublishを実行したとき(それはGradleのファイルにrepoKeyを尊重していないかのように)しかし、アーチファクトが

Dいくつかの他の場所に配備されています。 .. .. [buildinfo] このビルドでbuildInfoプロパティファイルを使用していません。 :artifactoryPublishビルド記述子を展開する: http://artifactory.XXX.local/artifactory/api/buildビルドが正常に行われました。 がデプロイされました。 下Artifactoryでそれを閲覧http://artifactory.XXX.local/artifactory/webapp/builds/my-lib-android-0.0.2/1449880830949>

BUILD SUCCESSFUL

合計時間:9.692秒

だから私の質問は、アーティファクトがに似たURLにプッシュされるように、私は私の設定を修正することができる方法でありますこの:

http://artifactory.XXX.local/artifactory/libs-releases-local/com/example/my-lib-android/0.0.2/my-lib-android-0.0.2.aar 

build.gradleファイル:

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.0' 
     classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.1.2') 
     classpath 'net.researchgate:gradle-release:2.3.4' 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 
plugins { 
    id 'net.researchgate.release' version '2.3.4' 
} 

apply plugin: "com.jfrog.artifactory" 
apply plugin: 'maven-publish' 
apply plugin: 'net.researchgate.release' 

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url 'http://artifactory.XXX.local/artifactory/libs-releases-local' 
     } 
    } 
} 

artifactory { 
    contextUrl = "${artifactory_contextUrl}" 
    //The base Artifactory URL if not overridden by the publisher/resolver 
    publish {  
     repository { 
      repoKey = "libs-releases-local" 
      username = "${artifactory_user}" 
      password = "${artifactory_password}" 
      maven = true 

     } 
    } 
} 

release { 
    revertOnFail = false 
} 
task build{ 

} 

gradle.propertiesファイル:

version=my-lib-android-0.0.3-SNAPSHOT 
artifactory_user=myUserName 
artifactory_password=myPasssword 
artifactory_contextUrl=http://artifactory.XXX.local/artifactory 
+0

の読み出し、Iは '' ID "com.jfrog.artifactory" バージョン "3.1.0" プラグインを追加'artifactoryPublish {.. ..}'ブロックも参照してください。しかし、それは役に立たなかった。 – PCM

+0

あなたは 'maven-publish'を使っていますが、ここでの答えに' artifactory'の代わりに 'artifactory-publish'を使ってください。http://stackoverflow.com/questions/22352475/upload-artifact-to-artifactory -using-gradle – RaGe

+0

あなたのmaven-publishプラグインに 'publishing {}'を定義しましたか? – RaGe

答えて

0

android-mavenプラグインを使用:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.9.2' 
     classpath 'com.github.dcendents:android-maven-plugin:1.0' 
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.2.0' 
    } 
} 

apply plugin: 'android-library' 
apply plugin: 'com.jfrog.artifactory-upload' 
apply plugin: 'android-maven' 


configurations { 
    published 
} 

task sourceJar(type: Jar) { 
    from android.sourceSets.main.java 
    classifier "sources" 
} 

artifactoryPublish { 
    dependsOn sourceJar 
} 

artifacts { 
    published sourceJar 
} 

artifactory { 
    contextUrl = "${artifactory_contextUrl}" 
    publish { 
     repository { 
      repoKey = "libs-releases-local" 
      username = "${artifactory_user}" 
      password = "${artifactory_password}" 
     } 
     defaults { 
      publishConfigs('archives', 'published') 
      publishPom = true //Publish generated POM files to Artifactory (true by default) 
      publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default) 
     } 
    } 
} 
+0

「gradlew clean」を実行すると、「** buildToolsVersionが指定されていません。**」「 – PCM

0

は、私は通常、このようなmavenDeployer-プラグインでそれを行います。 あなたのケースに合っているかどうかわかりませんが、ここに残しておきます。

apply plugin: 'maven' 
uploadArchives { 
    repositories { 
     mavenDeployer { 
      repository(url: 'http://arandom.nexus.com:8081/nexus/content/repositories/releases') { 
       authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD); 
      } 
      snapshotRepository(url: 'http://arandom.nexus.com:8081/nexus/content/repositories/snapshots') { 
       authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD); 
      } 
      pom.groupId = "groupId" 
      pom.artifactId = "artifactId" 
      pom.version = "${versionMajor}.${versionMinor}.${versionPatch}" 
     } 
    } 
} 

いくつかはさらに、ユーザ@RaGeからコメント(今除去)に基づいて、ローカルリポジトリhere

+0

私はまだこれを試しています! – PCM

関連する問題