How to add local .jar file dependency to build.gradle file?

前端 未结 17 2037
攒了一身酷
攒了一身酷 2020-11-21 23:23

So I have tried to add my local .jar file dependency to my build.gradle file:

apply plugin: \'java\'

sourceSets {
    main {
        java {
            srcD         


        
17条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 23:54

    I couldn't get the suggestion above at https://stackoverflow.com/a/20956456/1019307 to work. This worked for me though. For a file secondstring-20030401.jar that I stored in a libs/ directory in the root of the project:

    repositories {
        mavenCentral()
        // Not everything is available in a Maven/Gradle repository.  Use a local 'libs/' directory for these.
        flatDir {
           dirs 'libs'
       }
    }
    
    ...
    
    compile name: 'secondstring-20030401'
    

提交回复
热议问题