2016-10-16 7 views
0

私はgradleを使った小さなマルチプロジェクトセットアップを持っていますが、コンパイルはしません。 IDEの中で実行することはできますが、コンパイルしたいときは失敗します。 その後、GameプロジェクトのEngineプロジェクトの依存関係の1つを使用しようとすると、IDEの内部でも失敗します。 さらに詳しく説明します。依存関係を持つGradleマルチプロジェクトセットアップ - >すべての依存関係を解決できませんでした

:Engine:compileJava UP-TO-DATE 
:Engine:processResources UP-TO-DATE 
:Engine:classes UP-TO-DATE 
:Engine:jar 
:compileJava 

FAILURE: Build failed with an exception. 

* What went wrong: 
Could not resolve all dependencies for configuration ':compileClasspath'. 
> Could not find org.lwjgl:lwjgl:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl/3.0.1-SNAPSHOT/lwjgl-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl/3.0.1-SNAPSHOT/lwjgl-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-egl:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-egl/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-egl/3.0.1-SNAPSHOT/lwjgl-egl-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-egl/3.0.1-SNAPSHOT/lwjgl-egl-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-glfw:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-glfw/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-glfw/3.0.1-SNAPSHOT/lwjgl-glfw-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-glfw/3.0.1-SNAPSHOT/lwjgl-glfw-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-jemalloc:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-jemalloc/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-jemalloc/3.0.1-SNAPSHOT/lwjgl-jemalloc-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-jemalloc/3.0.1-SNAPSHOT/lwjgl-jemalloc-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-openal:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-openal/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-openal/3.0.1-SNAPSHOT/lwjgl-openal-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-openal/3.0.1-SNAPSHOT/lwjgl-openal-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-opencl:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opencl/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opencl/3.0.1-SNAPSHOT/lwjgl-opencl-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opencl/3.0.1-SNAPSHOT/lwjgl-opencl-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-opengl:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengl/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengl/3.0.1-SNAPSHOT/lwjgl-opengl-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengl/3.0.1-SNAPSHOT/lwjgl-opengl-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-opengles:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengles/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengles/3.0.1-SNAPSHOT/lwjgl-opengles-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-opengles/3.0.1-SNAPSHOT/lwjgl-opengles-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-stb:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-stb/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-stb/3.0.1-SNAPSHOT/lwjgl-stb-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-stb/3.0.1-SNAPSHOT/lwjgl-stb-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 
> Could not find org.lwjgl:lwjgl-vulkan:3.0.1-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-vulkan/3.0.1-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-vulkan/3.0.1-SNAPSHOT/lwjgl-vulkan-3.0.1-SNAPSHOT.pom 
     https://jcenter.bintray.com/org/lwjgl/lwjgl-vulkan/3.0.1-SNAPSHOT/lwjgl-vulkan-3.0.1-SNAPSHOT.jar 
    Required by: 
     project : > project :Engine 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 9.375 secs 

マイファイルhirachyは非常に簡単です:

プロジェクト\エンジン

プロジェクト\ゲーム

Engineプロジェクトを使用する必要があります私のゲームのプロジェクトなので、私は簡単にエンジンプロジェクトで物事を変更することができますか?ゲームのプロジェクトをコンパイルするときには、エンジンプロジェクトをコンパイルしてコンパイルする必要があります(例えば、Eclipseプロジェクトでは依存プロジェクトとして追加する場合と同じように) の新しい.jarファイルを作成してください。ゲームプロジェクトに必要なjarファイル

現在のところ、GameプロジェクトはEngineプロジェクトに依存していますが、これは私のIDE(エンジンプロジェクトがimportetのときはatleast)でかなりうまく動作しますが、ビルドを実行するとすぐに失敗します上記のエラーが表示されます。 エンジンプロジェクトに依存しているクラスにアクセスしたいが、完全なエンジンプロジェクトが依存しているゲームプロジェクトにはアクセスできないときにIDEで失敗する。

Gameプロジェクトのbuild.gradleファイル。

// Apply the java plugin to add support for Java 
apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 

// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use 'jcenter' for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    jcenter() 
} 

// In this section you declare the dependencies for your production and test code 
dependencies { 
    // The production code uses the SLF4J logging API at compile time 
    //compile 'org.slf4j:slf4j-api:1.7.21' 

    // Declare the dependency for your favourite test framework you want to use in your tests. 
    // TestNG is also supported by the Gradle Test task. Just change the 
    // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 
    // 'test.useTestNG()' to your build script. 
    //testCompile 'junit:junit:4.12' 

    compile project(':Engine') 
    runtime project(':Engine') 
} 

Gameプロジェクトのsettings.gradleファイル:

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 

// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use 'jcenter' for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    jcenter() 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '3.1' 
} 

sourceSets { 
    main.java.srcDir "src/main/java" 
} 

project.ext.lwjglVersion = "3.0.1-SNAPSHOT" 

import org.gradle.internal.os.OperatingSystem 

switch (OperatingSystem.current()) { 
    case OperatingSystem.WINDOWS: 
     project.ext.lwjglNatives = "natives-windows" 
     break 
    case OperatingSystem.LINUX: 
     project.ext.lwjglNatives = "natives-linux" 
     break 
    case OperatingSystem.MAC_OS: 
     project.ext.lwjglNatives = "natives-macos" 
     break 
} 

dependencies { 
    // LWJGL dependencies START 
    compile "org.lwjgl:lwjgl:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-egl:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-glfw:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-jemalloc:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-openal:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-opencl:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-opengl:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-opengles:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-stb:${lwjglVersion}" 
    compile "org.lwjgl:lwjgl-vulkan:${lwjglVersion}" 
    // LWJGL natives 
    runtime "org.lwjgl:lwjgl:${lwjglVersion}:${lwjglNatives}" 
    runtime "org.lwjgl:lwjgl-glfw:${lwjglVersion}:${lwjglNatives}" 
    runtime "org.lwjgl:lwjgl-jemalloc:${lwjglVersion}:${lwjglNatives}" 
    runtime "org.lwjgl:lwjgl-openal:${lwjglVersion}:${lwjglNatives}" 
    runtime "org.lwjgl:lwjgl-stb:${lwjglVersion}:${lwjglNatives}" 
    // LWJGL dependencies END 
} 

、なぜ午前:

include 'Engine' 
project (':Engine').projectDir = new File('../Engine') 

rootProject.name = 'Game' 

は、その後、私はここEngineプロジェクトのbuild.gradleファイルを持っています私はこのエラーを受け取り、実行可能な方法でそれを解決するにはどうすればいいですか?IDE、Eclipse、Intellijを使ってLinux、Windows、Mac上のプロジェクトですか? Gameプロジェクト内の

を構築gradlew

を実行しているときにエラーが発生します。エンジンプロジェクトの構築はうまくいきます。例えばEclipseプロジェクトの中でGameプロジェクトを実行してもうまく動作しますが、GameプロジェクトでEngineプロジェクトがアクセスできるクラスを構築したい場合やクラスを使用したい場合は失敗します。

答えて

1

EDIT(より良い回答)

私はプロジェクトを別々に編成します。お使いの設定で

Project/ 
    | 
    +- Game/ 
    +- Engine/ 
    +- build.gradle 
    +- settings.gradle 

は、この階層を使用してみてください。あなたの子プロジェクトのGradleの

include ':Game' 
include ':Engine' 
プロジェクトルートのあなたのbuild.gradleで

// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use 'jcenter' for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    jcenter() 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
} 

repositoriesノードはもう必要ありません。あなたのゲームプロジェクトの

settings.gradleはい、JCenterリポジトリに存在していないだけで

rootProject.name = 'Game' 
+0

です。だからこそ私は彼らが見つけられるリポジトリへのリンクを入れた: – ShadowDragon

+0

リポジトリへのリンクではうまく動作する。 [link](https://oss.sonatype.org/content/repositories/snapshots/org/lwjgl/)そしてそこにファイルがあり、Engineプロジェクトによってうまくダウンロードできます。ちょうどゲームプロジェクトはそれらをダウンロードする問題を持っているようだ。 (それらを見つけるためのリポジトリへのリンクはEngineプロジェクトにあります) – ShadowDragon

+0

新しい答えは良いですか? – Bipi

関連する問題