2012-03-06 12 views
1

私はJavaアプリケーションをコンパイルしてパッケージ化しようとしていますが、依存関係として使用されるjarファイルを持つローカルリポジトリを指定しようとすると問題に直面します。私は自分のアプリケーションに必要なすべてのjarファイルを '/ home/test/lib'に保存しました。次のように私は私のbuild.gradleファイルとして持っていることである:私はGradleのビルドを実行するとローカルリポジトリ(gradle)の依存関係について混乱しています

apply plugin:'application' 
apply plugin:'java' 
apply plugin:'idea' 

    def repositoryPath = '/home/test/lib' 

    repositories { 
     repositoryPath 
    } 



dependencies { 
      "org.springframework:spring-orm:3.0.2.RELEASE" 
      "org.springframework:spring-context-support:3.0.2.RELEASE" 
      'commons-dbcp:commons-dbcp:1.4' 
      'org.apache.ibatis:ibatis-sqlmap:2.3.4.726' 
      'commons-dbutils:commons-dbutils:1.3' 
      'joda-time:joda-time:1.6' 
      'commons-lang:commons-lang:2.5' 
      'com.google.collections:google-collections:1.0' 
} 

jar { 
    baseName = 'testJar' 
} 

mainClassName = "com.some.test.testRunner" 

、私はエラーを「パッケージが*存在しない」取得しています。

私の前提として、gradleはlibフォルダ内の必要な外部ジャーを見つけることができません。誰かが私がここで間違っているかもしれないことを指摘できますか?

ありがとうございました

答えて

6

ビルドファイルについてのコメント私はあなたのサードパーティのライブラリを含む '/ home/test/lib'にフラットなディレクトリがあると仮定します。

def repositoryPath = '/home/test/lib' 

repositories { 
    flatDir { 
     dirs repositoryPath 
    } 
} 

/ホーム/テストは/ libには、ツタのリポジトリがある場合は、あなたが行うことができます:これはあなたがflatDirリポジトリを使用することができる場合であれば、それは次の構文で宣言されている

repositories { 
    ivy { 
     url repositoryPath 
    } 
} 

これは、Gradle user guideで詳細に説明されています。あなたの依存関係のスコープを宣言するために逃したあなたの「依存関係」セクション(など、ランタイムのコンパイル)で

dependencies { 
    compile "org.springframework:spring-orm:3.0.2.RELEASE" 
    compile "org.springframework:spring-context-support:3.0.2.RELEASE" 
    compile 'commons-dbcp:commons-dbcp:1.4' 
    compile 'org.apache.ibatis:ibatis-sqlmap:2.3.4.726' 
    compile 'commons-dbutils:commons-dbutils:1.3' 
    compile 'joda-time:joda-time:1.6' 
    compile 'commons-lang:commons-lang:2.5' 
    compile 'com.google.collections:google-collections:1.0' 
} 

あなたはflatdirリポジトリを使用する場合は、あなたの依存関係の定義のグループはしばしば省略されています:

dependencies { 
    compile ":spring-orm:3.0.2.RELEASE" 
    ... 
} 

はGradleので取り扱いの依存関係についての詳細な情報については、Gradleのユーザーガイドを見てください:http://gradle.org/docs/current/userguide/userguide_single.html#artifact_dependencies_tutorial

敬具、 ルネ

関連する問題