Add external jar in gradle

房东的猫 提交于 2019-11-30 01:48:17

问题


How can I add an external library in gradle? My build.gradle contains:

buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT'
    }
}

My root folder is /FORGE/. I want to add /FORGE/build/libs/spigot.jar as a dependency.


回答1:


As explained in the documentation:

dependencies {
    compile files('libs/spigot.jar')
}

The above will add the libs/spigot.jar file to the compile configuration. You can of course add it to any other configuration (runtime, etc.).

Note that using build/libs is an extremely bad idea, since the whole build directory will be deleted as soon as you execute gradle clean. The build directory is used to store artifacts generated by the build.



来源:https://stackoverflow.com/questions/22734314/add-external-jar-in-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!