2017-02-02 4 views
0

私はいくつかの依存関係のためにローカルなアーティファクトに依存するプロジェクトを持っています。Gradle:マルチプロジェクト構造への移行 - リポジトリを解決できません。

のGradleこのプロジェクトにビルドし、リポジトリのための適切な設定と、正常に動作します:

buildscript { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/libs-release" 
     } 
    } 
    dependencies { 
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
    } 
} 

repositories { 
    maven { 
     url "${artifactoryUrl}/repo" 
    } 
} 

artifactory { 
    contextUrl = "${artifactoryUrl}" 
    publish { 
     repository { 
      repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
      username = "${artifactoryUser}" // The publisher user name 
      password = "${artifactoryPassword}" // The publisher password 
     } 
     defaults { 
      // Reference to Gradle publications defined in the build script. 
      // This is how we tell the Artifactory Plugin which artifacts should be 
      // published to Artifactory. 
      publications('mavenJava') 
      publishArtifacts = true 
      // Properties to be attached to the published artifacts. 
      properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
     } 
    } 
    resolve { 
     repoKey = 'repo' 
    } 
} 

私はマルチプロジェクトの構造上のGradleのチュートリアルを行いました。 「リポジトリ」セクションをルートgradle.buildファイルに移動できるようです。私はGradleのビルドを実行したときしかし、私はartifactoryからすべての依存関係に乗るとエラーだ:

は、外部依存関係に

注意を解決できません:私も含むルートディレクトリでgradle.propertiesファイルを追加しましたすべての変数(artifactoryUrlなど)

したがって、サブプロジェクトは、ルートgradle.buildファイルに定義されているリポジトリを「参照」できないようです。助言がありますか?

allprojects { 
} 

subprojects { 
    buildscript { 
     repositories { 
      maven { 
       url "${artifactoryUrl}/libs-release" 
      } 
     } 
     dependencies { 
      classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
     } 
    } 

    repositories { 
     maven { 
      url "${artifactoryUrl}/repo" 
     } 
    } 

    artifactory { 
     contextUrl = "${artifactoryUrl}" 
     publish { 
      repository { 
       repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
       username = "${artifactoryUser}" // The publisher user name 
       password = "${artifactoryPassword}" // The publisher password 
      } 
      defaults { 
       // Reference to Gradle publications defined in the build script. 
       // This is how we tell the Artifactory Plugin which artifacts should be 
       // published to Artifactory. 
       publications('mavenJava') 
       publishArtifacts = true 
       // Properties to be attached to the published artifacts. 
       properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
      } 
     } 
     resolve { 
      repoKey = 'repo' 
     } 
    } 
} 
+0

'-i'または' -d'フラグを指定して実行するとどうなりますか?どこかに鉛があるはずです。 –

+0

'id'で表示される関連メッセージだけです:設定ファイルのローカルリポジトリが定義されていません。デフォルトパス:/home/elad/.m2/repositoryを使用してください。 –

+0

' apply plugin: 'がありません。更新された回答 –

答えて

0

あなたはsubprojectsまたはallprojectsブロックにrepository(およびartifactory)ブロック(複数可)を配置する必要があります。rootディレクトリに

UPDATE

build.gradleは次のようになります。そのように:

subprojects { 
    repositories { 
    maven { 
     url "${artifactoryUrl}/repo" 
    } 
    } 
    ... 
} 

これは、コンフィギュレーションは、あなたのサブプロジェクトのすべてのの設定の中に根build.gradleによって押し下げられていることを保証します。

はまたartifactoryのために、すべてのサブプロジェクトにartifactoryプラグインを適用することを忘れないでください:

subprojects { 
    apply plugin: "com.jfrog.artifactory" 

    ... 
} 
+0

しました。フルルートbuild.gradleファイルで質問を更新しました。レビューしてください。 –

+0

私はプラグインも同じ結果を追加しました... –

0

だから、いくつかの例を見た後、私はbuildscriptセクションがsubprojectsセクションの外であることを認識し、ありません内部。サブプロジェクトセクションにもapply plugin: 'com.jfrog.artifactory'を追加する必要があります。

buildscript { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/libs-release" 
     } 
    } 
    dependencies { 
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
    } 
} 

subprojects { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/repo" 
     } 
    } 

    artifactory { 
     contextUrl = "${artifactoryUrl}" 
     publish { 
      repository { 
       repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
       username = "${artifactoryUser}" // The publisher user name 
       password = "${artifactoryPassword}" // The publisher password 
      } 
     defaults { 
       // Reference to Gradle publications defined in the build script. 
       // This is how we tell the Artifactory Plugin which artifacts should be 
       // published to Artifactory. 
       publications('mavenJava') 
       publishArtifacts = true 
       // Properties to be attached to the published artifacts. 
       properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
      } 
     } 
     resolve { 
      repoKey = 'repo' 
     } 
    } 
} 
関連する問題