Spring消息依赖关系连接问题



我最近通过遵循本教程将Spring消息传递模块连接到我的libgdx项目,以优雅地使用套接字:https://nexocode.com/blog/posts/spring-dependencies-in-gradle/

然后任务android:mergeDugJavaResource发誓我有多个文件META-INF/web fragment.xml

* What went wrong:
Execution failed for task ':android:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'META-INF/web-fragment.xml'. 

由于问题出现在启动时,而不是构建时,所以我向您展示gradle.build的

build.gradle(app_name(

buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.12'
classpath 'com.google.gms:google-services:4.3.5'
}
}
plugins {
id 'java-library'
id 'org.springframework.boot' version '2.1.0.RELEASE'
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "bogatiry-online"
gdxVersion = '1.9.14'
roboVMVersion = '2.3.12'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.3'
aiVersion = '1.8.2'
gdxControllersVersion = '2.1.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java-library"

dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":android") {
apply plugin: "com.android.application"
configurations { natives }
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
}
}
project(":ios") {
apply plugin: "java-library"
apply plugin: "robovm"

dependencies {
implementation project(":core")
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"

}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
api "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.0"
api "com.kotcrab.vis:vis-ui:1.3.0"
}
}

build.gradle(:核心(

plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
}
sourceCompatibility = 1.7
dependencies {
//Apache
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
//Json
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.3'
//Lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
//Spring
api platform('org.springframework.boot:spring-boot-dependencies:2.1.0.RELEASE')
implementation 'org.springframework.boot:spring-boot-starter-websocket'
dependencies {
constraints {
implementation 'org.springframework.boot:spring-boot-starter-websocket:2.4.5'
}
}
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project.name = appName + "-core"
bootJar {
enabled = false
}
jar {
enabled = true
}

build.gradle(:android((虽然我认为问题不在其中,但我没有在没有错误的情况下更改它(

apply plugin: 'com.google.gms.google-services'
android {
buildToolsVersion "30.0.3"
compileSdkVersion 30
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.drownedman.bogatiry"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives {
doFirst {
file("libs/armeabi/").mkdirs()
file("libs/armeabi-v7a/").mkdirs()
file("libs/arm64-v8a/").mkdirs()
file("libs/x86_64/").mkdirs()
file("libs/x86/").mkdirs()
configurations.natives.copy().files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
}
tasks.whenTaskAdded { packageTask ->
if (packageTask.name.contains("package")) {
packageTask.dependsOn 'copyAndroidNatives'
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.drownedman.bogatiry/com.drownedman.bogatiry.AndroidLauncher'
}
dependencies {
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:26.8.0')
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database:19.7.0'
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}
eclipse.project.name = appName + "-android"

我试过

  1. 文件->使缓存无效/重新启动
  2. 检查了版本的兼容性,一切似乎都很好
  3. 排除了一些";META-INF/";常见于此类错误中的文件(发现多个文件具有独立于操作系统的路径';META-INF/LICENSE';(。我可以以同样的方式排除此文件,但随后我在使用另一个文件时会出现类似的错误,然后再使用另一文件,依此类推

但对没有帮助

在回答我自己的问题时,我只是排除了这一长串文件,正如在类似的问题中所建议的那样。发现了不止一个具有独立于操作系统的路径';META-INF/LICENSE';

exclude 'META-INF/web-fragment.xml'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/spring.schemas'
exclude 'META-INF/spring.tooling'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/spring-configuration-metadata.json'
exclude 'META-INF/spring.factories'
exclude 'META-INF/additional-spring-configuration-metadata.json'

最新更新