我正在做一个mod jar。我需要在最终的jar(org.apache.httpcomponents:httpasyncclient:4.1.5)中包含一个外部库。我正在使用Shadow插件来制作脂肪罐。但是,我无法正确地包含依赖项。
下面是我的build.gradle
:
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
}
}
plugins {
id "com.github.johnrengelman.shadow" version "4.0.4"
id "java"
}
apply plugin: "net.minecraftforge.gradle.forge"
configurations {
shade
implementation.extendsFrom shade
}
repositories {
jcenter()
}
dependencies {
compile "org.apache.httpcomponents:httpasyncclient:4.1.5"
shade "org.apache.httpcomponents:httpasyncclient:4.1.5"
}
shadowJar {
classifier = ''
configurations = [project.configurations.shade]
finalizedBy 'reobfShadowJar'
}
reobf {
shadowJar {}
}
tasks.build.dependsOn reobfShadowJar
shadowJar.finalizedBy('reobfShadowJar')
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
archivesBaseName = "${mod_id}"
version = "${mod_version}"
group = "com.<modid>.<modid>"
minecraft {
version = "1.8.9-11.15.1.2318-1.8.9"
runDir = "run"
replace "@VERSION@", project.version
replaceIn "<Modid>.java"
mappings = "stable_22"
}
processResources {
inputs.property "mod_version", project.version
inputs.property "mc_version", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "mod_id":"${mod_id}",
"mod_name":"${mod_name}",
"mod_version":"${mod_version}",
"mod_description":"${mod_description}",
"mc_version":"${mc_version}"
}
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
当我在IDEA中运行“Minecraft客户端”运行配置时,一切都按预期工作。但是,当我运行gradlew build
时,在运行时,我得到Error: net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: /org/apache/http/concurrent/FutureCallback
。为什么mod加载器找不到类,即使它们在jar中?(我可能做错了)。
1条答案
按热度按时间bcs8qyzn1#
我不得不重新安置
org.apache
。我想它干扰了现有的依赖性。之前这不起作用的原因是我使用了一个不存在的gradle.properties
占位符。