2016-07-18 5 views
1

Gradleを使用してスプリントブートベースのプロジェクトを構築するときに次のエラーが発生します。私は--debugオプションで構築しようとしましたが、同じエラーが発生し、それ以上の洞察はありませんでした。gradleがレイアウトエラーを推定できない


:clean 
:compileJava 
:processResources 
Copy over the Env properties 
Copy env properties from src/main/resources to C:\project-portal\build/resources/main/local.application.properties 
:classes 
:findMainClass 
:war 
Creating exploded war file :: C:\project-portal\build/project-portal 
:bootRepackage FAILED 

FAILURE:例外で失敗しましたビルドします。

  • 何が問題になりましたか: ':bootRepackage'タスクの実行に失敗しました。レイアウトを推測することができません

    'C:\プロジェクトポータル\ビルド\ LIBSの\プロジェクトポータル'

それは、レイアウトを推測することができません "とはどういう意味ですか?ありがとう!

アップデート#1 build.gradleを含める:

<pre> 
buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 
apply plugin: 'war' 

def deployDir = "" 
def configDir="" 

def appWarName = "project-portal" 

configurations.create('myConfiguration') 

configurations.myConfiguration { 
    if("$appEnv"=='local') { 
     configDir=localConfigDir 
     deployDir=localDeployDir 
    } else if("$appEnv"=='uat') { 
     configDir=uatConfigDir 
     deployDir=uatDeployDir 
    } 
    println "Config Dir :: $configDir" 
    println "Deploy Dir :: $deployDir" 
} 


processResources { 
    doLast { 
     println "Copy over the Env properties" 
     copy { 
      println "Copy env properties from src/main/resources to $buildDir/resources/main/${appEnv}.application.properties" 
      from "src/main/resources/${appEnv}.application.properties" 
      into "$buildDir/resources/main/" 
      rename { filename -> filename.replace "${appEnv}.application.properties", 'application.properties'} 
     } 
    } 
} 

springBoot { 
    mainClass= "com.company.Application" 
} 

bootRepackage { 
    mainClass = 'com.company.Application' 
} 

jar { 
    baseName = 'project-portal' 
    version = '' 
    exclude('src/main/resources/*.properties') 
} 

repositories { 
    mavenCentral() 
} 

sourceCompatibility = 1.7 
targetCompatibility = 1.7 

dependencies { 
    //compile("org.springframework.boot:spring-boot-starter-parent") 
    //compile("org.springframework.boot:spring-boot-starter") 
    compile("org.springframework.boot:spring-boot-starter-web") 
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 

    testCompile("junit:junit") 
    testCompile("org.springframework.boot:spring-boot-starter-test") 

    //hibernate 
    //compile 'org.eclipse.persistence:javax.persistence:2.1.0' 
    compile 'org.hibernate:hibernate-entitymanager:4.3.8.Final' 
    compile 'org.hibernate:hibernate-core:4.3.8.Final' 
    compile 'org.jboss.logging:jboss-logging:3.2.1.Final' 
    compile 'org.springframework.data:spring-data-jpa' 

    //Security 
    compile("org.springframework.boot:spring-boot-starter-security") 

    compile 'mysql:mysql-connector-java:5.1.34' 

    //After bug 
    compile 'aspectj:aspectjweaver:1.5.4' 

} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.9-rc-1' 
} 

war { 
    archiveName="$appWarName" 
    doLast { 
     println "Creating exploded war file :: $buildDir/$appWarName" 
     ant.unzip(src: war.archivePath, dest: "$buildDir/$appWarName") 
    } 
} 

task copyJar(type: Copy) { 
    println "Copy lib to $buildDir/lib" 
    it.dependsOn jar 
    from "$buildDir/libs" 
    into "$buildDir/web" 
} 

task deployApp(type: Copy) { 
    println "Copy dependencyJar to $buildDir" 
    it.dependsOn copyJar 
    it.dependsOn war 
    from "$buildDir/$appWarName/WEB-INF/lib" 
    into "$buildDir/externalJars" 
    from "$buildDir/libs" 
    into "$buildDir/externalJars" 
    from "$buildDir/$appWarName" 
    into "$deployDir/$appWarName" 
} 

</pre> 
+0

あなたはエラーに多くを見て、あなたのbuild.gradleを貼り付けることはできますか? – rajadilipkolli

+0

元の投稿に更新#1を追加しました。ありがとう! – Lucheng

答えて

1

問題がappWarName変数の値によって引き起こされます。 project-portalに設定し、Gradleのwarタスクには.warという拡張子が追加されないため、結果のwarアーカイブのフルネームはproject-portalで、拡張子はありません。

bootRepackageタスクは、ファイルの拡張子(sourceを参照)に基づいてファイルのレイアウトを決定しようとしますが、拡張子がないため失敗します。

修正は簡単です:

def appWarName = "project-portal.war"

+0

ありがとうNikita!それはそれだった。 – Lucheng

+0

喜んで、私はhlpすることができます。答えを受け入れる、plz –

+0

は答えを受け入れる方法を調べなければならなかった:-)もう一度おねがいします。 – Lucheng

関連する問題