我正在尝试编译其他开发人员的开源自定义库。
我已经编译或找到依赖项,但无法在 gradle 中构建
无法导入java的内部库包org.objectweb.asm
它是一个java内部库,所以它必须在tools.jar中,但是build.properties它已经导入java的tools.jar并已经应用插件java,所以我不知道
这里是build.properties(主要部分)
allprojects {
apply plugin: 'java'
group 'com.nemosw.spigot'
version '1.2.21'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
repositories {
// junit
mavenCentral()
// nms spigot & mox
mavenLocal()
}
}
project(':core') {
processResources {
filesMatching('**/*.yml') {
expand project.properties
}
}
repositories {
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
flatDir { dirs 'libs' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
compileOnly files(Jvm.current().toolsJar)
compile 'com.nemosw.mox:mox-collections:1.0'
compile 'com.nemosw.mox:mox-task:1.0'
compile 'com.nemosw.mox:mox-math:1.0.2'
compile 'com.nemosw.mox:mox-tools:1.1'
}
}
其他部分可以在这里找到: https://github.com/nemosrc/tap
您还需要修复一些依赖项并编译他的 mox 库(全部)
https://github.com/nemosrc/mox-math
https://github.com/nemosrc/mox-tools
https://github.com/nemosrc/mox-collections
https://github.com/nemosrc/mox-task
由于库失败而导致大量错误。
C:\tap\core\src\main\java\com\nemosw\spigot\tap\event\ASMEntityEventExecutor.java:6: error: package org.objectweb.asm does not exist import org.objectweb.asm.ClassWriter; ^
C:\tap\core\src\main\java\com\nemosw\spigot\tap\event\ASMEntityEventExecutor.java:7: error: package org.objectweb.asm does not exist import org.objectweb.asm.MethodVisitor; ^
C:\tap\core\src\main\java\com\nemosw\spigot\tap\event\ASMEntityEventExecutor.java:8: error: package org.objectweb.asm does not exist import org.objectweb.asm.Type; ^
C:\tap\core\src\main\java\com\nemosw\spigot\tap\event\ASMEntityEventExecutor.java:15: error: package org.objectweb.asm does not exist import static org.objectweb.asm.Opcodes.*; ^
C:\tap\core\src\main\java\com\nemosw\spigot\tap\event\ASMEventExecutor.java:9: error: package org.objectweb.asm does not exist import org.objectweb.asm.ClassWriter;
最佳答案
您可以在依赖项 block 中添加依赖项 -
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
compileOnly files(Jvm.current().toolsJar)
compile 'com.nemosw.mox:mox-collections:1.0'
compile 'com.nemosw.mox:mox-task:1.0'
compile 'com.nemosw.mox:mox-math:1.0.2'
compile 'com.nemosw.mox:mox-tools:1.1'
compile 'org.ow2.asm:asm:'7.1'
}
您可以从此站点找到更多依赖项 https://mvnrepository.com/
关于java - 无法导入包 org.objectweb.asm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57305919/