Я экспериментирую с транзитивными зависимостями в библиотеке Android. Я получил сообщение об ошибке ниже.
Другой вопрос, на мой взгляд, Что такое Spring Depedency Management и могу ли я использовать эту функциональность вместе с ним?
tfs.gradle
apply plugin: 'digital.wup.android-maven-publish'
apply plugin: 'maven-publish'
def external = {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
name 'Emre Akturk'
email '_mail_comes_here'
organization 'KocSistem'
organizationUrl 'https://www.kocsistem.com.tr'
}
}
}
task androidSourcesJar(type: Jar) {
classifier 'sources'
from android.sourceSets.main.java.srcDirs
}
task androidJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
}
publishing {
publications {
bundle(MavenPublication) {
from components.android
artifact androidJar
artifact androidSourcesJar
groupId 'com.oneframe.android'
artifactId "$project.name"
version android.defaultConfig.versionName
pom.withXml {
def root = asNode()
root.appendNode('name', "Networking")
root.appendNode('description', "A library for http communication")
root.children().last() + external
}
}
}
repositories {
maven {
name "Bellatrix"
url '_url_comes_here'
credentials {
username "_username_comes_here"
password "_token_comes_here"
}
}
}
repositories {
maven {
name "Desktop"
url uri("/Users/emreaktrk/Desktop/")
}
}
}
build.gradle (библиотека)
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
provided 'com.android.support:appcompat-v7:28.0.0'
api group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.1'
api group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.11.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply from: 'tfs.gradle'
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oneframe.android</groupId>
<artifactId>trans</artifactId>
<version>2.0</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<name>Networking</name>
<description>A library for http communication</description>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Umut Boz</name>
<email>umut.boz@kocsistem.com.tr</email>
<organization>KocSistem</organization>
<organizationUrl>https://www.kocsistem.com.tr</organizationUrl>
</developer>
<developer>
<name>Emre Akturk</name>
<email>emre_akturk@kocsistem.com.tr</email>
<organization>KocSistem</organization>
<organizationUrl>https://www.kocsistem.com.tr</organizationUrl>
</developer>
</developers>
<scm>
<url>http://bellatrix:8080/tfs/ArgeMimariCollection/OneFrameAndroid/_git/Networking</url>
<tag>master</tag>
</scm>
</project>
Go.java (в модуле библиотеки)
package com.oneframe.android.trans;
import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
public class Go {
public Go() {
Log4jJsonObjectMapper mapper = new Log4jJsonObjectMapper();
}
}
MainActivity.java (модуль приложения)
package com.oneframe.android;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.oneframe.android.trans.Go;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Go go = new Go();
}
}
Logcat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.oneframe.android, PID: 28694
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/logging/log4j/core/jackson/Log4jJsonObjectMapper;
at com.oneframe.android.trans.Go.<init>(Go.java:8)
at com.oneframe.android.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
...