2017-12-20 4 views
0

gradle.buildファイルを設定しようとしていますが、次の過渡的な依存関係に問題があります。Gradleに不正なメタデータの過渡的な依存関係を正しくプルダウンする方法はありますか?

org.glassfish.ha:ha-api:3.1.8

pom.xmlはバイナリが単に「jar」形式であるため、実際には正しくない「hk2-jar」形式のバイナリを指定しているようです。研究のビットを行った後、私は次のように出くわした:

How should gradle handle “hk2-jar” dependencies?

残念ながら、これは動作するようには思えませんでした。私は単純にそうような何かを行うことができるはず見つかったドキュメントを介してビットもっと読む:

configurations.all { 
    resolutionStrategy.force 'org.glassfish.ha:ha-api:[email protected]' 
} 

これは同様に、誤った結果が得られた:あなたが見ることができるように

Attempts to pull from the wrong URL

、それが試み実際には、次のURLをプルダウン:

http://repo-url/org/glassfish/ha/[email protected]/[email protected]

誰がどのように任意のアイデアを持っています私は適切なバイナリを適切に引き出し、間違った依存関係を除外できますか?

ありがとうございます!

EDIT

はちょうど私が遭遇したオリジナル問題はGradleのが私たちの内部ArtifactoryからHA-APIの依存関係をダウンロードしようとしたときにHK2-jarファイルがするように、403が返されているという事実であることを追加したいです(唯一のjarファイルがありません)私たちのリポジトリ内に存在しません:

* What went wrong: 
Could not resolve all dependencies for configuration ':compileClasspath'. 
> Could not determine artifacts for org.glassfish.ha:ha-api:3.1.8 
    > Could not get resource 'http://repo-url/artifactory/libs-release/org/glassfish/ha/ha-api/3.1.8/ha-api-3.1.8.hk2-jar'. 
     > Could not HEAD 'http://repo-url/artifactory/libs-release/org/glassfish/ha/ha-api/3.1.8/ha-api-3.1.8.hk2-jar'. Received status code 403 from server: Forbidden 
+0

@tkruse、私は元の問題を含んでいます。 – slashp

答えて

0

これは、いくつかの理由で、Artifactory(ないMavenの中央/ jcenter)を使用した場合、ほとんどの問題のようです。 1つのプロジェクトでの依存関係を使用するためにGradle forums

で説明

ソリューション:ライブラリプロジェクトに推移依存関係を変更するための

configurations.all { 
    resolutionStrategy.dependencySubstitution { 
     all { DependencySubstitution dependency -> 
     def requested = dependency.requested 
     if (requested instanceof ModuleComponentSelector && requested.group == 'org.glassfish.ha' && requested.name == 'ha-api') { 
      dependency.useTarget "org.glassfish.ha:ha-ap:${requested.version}@jar" 
     } 
     } 
    } 
} 

(これに応じたので、他のプロジェクトは、上記の操作を行う必要はありません):

publications { 
    foo(MavenPublication) { 
     pom.withXml { 
      def dependency = asNode().dependencies.dependency.find { 
       it.groupId.text() == 'org.glassfish.ha' && it.artifactId.text() == 'ha-api') 
      } 
      dependency.appendNode('type', 'jar')  
     } 
    } 
} 

これがArtifactoryでも実行できるかどうかを確認することは価値があります。

関連する問題