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

前端 未结 17 2073
攒了一身酷
攒了一身酷 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条回答
  •  -上瘾入骨i
    2020-11-21 23:33

    You can try reusing your local Maven repository for Gradle:

    • Install the jar into your local Maven repository:

      mvn install:install-file -Dfile=utility.jar -DgroupId=com.company -DartifactId=utility -Dversion=0.0.1 -Dpackaging=jar

    • Check that you have the jar installed into your ~/.m2/ local Maven repository

    • Enable your local Maven repository in your build.gradle file:

      repositories {
        mavenCentral()  
        mavenLocal()  
      }
      
      dependencies {  
        implementation ("com.company:utility:0.0.1")  
      }
      
      • Now you should have the jar enabled for implementation in your project

提交回复
热议问题