Skip to content

Commit 1b480d5

Browse files
authored
Merge pull request #2122 from shashankiitbhu/web3j-fix-android
Web3j fix android
2 parents bdbcdd7 + 9ce2517 commit 1b480d5

File tree

91 files changed

+2179
-1430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2179
-1430
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches: [ main ]
7+
branches:
8+
- main
9+
- web3j-android
810
workflow_dispatch:
911

1012
jobs:

.github/workflows/codeql.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
branches: [ 'main' ]
66
pull_request:
77
# The branches below must be a subset of the branches above
8-
branches: [ 'main' ]
8+
branches:
9+
- main
10+
- web3j-android
911
schedule:
1012
- cron: '35 2 * * 3'
1113

.github/workflows/publish-snapshot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: Publish snapshot
33
on:
44
workflow_run:
55
workflows: [ 'Build' ]
6-
branches: [ main ]
6+
branches:
7+
- main
8+
- web3j-android
79
types: [ completed ]
810

911
jobs:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ docs/build
5151
**/bin
5252

5353
# Besu-dev-quickstart logs
54-
integration-tests/src/test/resources/quorum-test-network/logs
54+
integration-tests/src/test/resources/quorum-test-network/logs
55+
56+
**/lint-baseline.xml
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kotlin version: 2.0.21
2+
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
3+
1. Kotlin compile daemon is ready
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kotlin version: 2.0.21
2+
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
3+
1. Kotlin compile daemon is ready
4+

abi/build.gradle

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
plugins {
22
id 'com.android.library'
3+
id 'maven-publish'
4+
}
5+
6+
publishing {
7+
publications {
8+
release(MavenPublication) {
9+
groupId = group
10+
artifactId = project.name
11+
version = version
12+
13+
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
14+
15+
pom {
16+
withXml {
17+
def dependenciesNode = asNode().appendNode('dependencies')
18+
configurations.api.allDependencies.each { dependency ->
19+
def dependencyNode = dependenciesNode.appendNode('dependency')
20+
dependencyNode.appendNode('groupId', dependency.group)
21+
dependencyNode.appendNode('artifactId', dependency.name)
22+
dependencyNode.appendNode('version', dependency.version)
23+
}
24+
}
25+
}
26+
}
27+
}
28+
repositories {
29+
mavenLocal()
30+
}
331
}
432

533
android {
@@ -9,8 +37,6 @@ android {
937
defaultConfig {
1038
minSdkVersion 24
1139
targetSdkVersion 33
12-
13-
1440
}
1541

1642
lint {

abi/src/main/java/org/web3j/abi/TypeDecoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ public static <T extends NumericType> T decodeNumeric(String input, Class<T> typ
151151

152152
BigInteger numericValue;
153153
if (Uint.class.isAssignableFrom(type) || Ufixed.class.isAssignableFrom(type)) {
154-
numericValue = new BigInteger(1, inputByteArray, valueOffset, typeLengthAsBytes);
154+
numericValue = new BigInteger(1, Arrays.copyOfRange(inputByteArray, valueOffset, valueOffset + typeLengthAsBytes));
155155
} else {
156-
numericValue = new BigInteger(inputByteArray, valueOffset, typeLengthAsBytes);
156+
numericValue = new BigInteger(Arrays.copyOfRange(inputByteArray, valueOffset, valueOffset + typeLengthAsBytes));
157157
}
158158
return type.getConstructor(BigInteger.class).newInstance(numericValue);
159159

android-test-utils/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
plugins {
22
id 'com.android.library'
3+
id 'maven-publish'
4+
}
5+
6+
publishing {
7+
publications {
8+
release(MavenPublication) {
9+
groupId = group
10+
artifactId = project.name
11+
version = version
12+
13+
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
14+
15+
pom {
16+
withXml {
17+
def dependenciesNode = asNode().appendNode('dependencies')
18+
configurations.api.allDependencies.each { dependency ->
19+
def dependencyNode = dependenciesNode.appendNode('dependency')
20+
dependencyNode.appendNode('groupId', dependency.group)
21+
dependencyNode.appendNode('artifactId', dependency.name)
22+
dependencyNode.appendNode('version', dependency.version)
23+
}
24+
}
25+
}
26+
}
27+
}
28+
repositories {
29+
mavenLocal()
30+
}
331
}
432

533
android {
@@ -19,6 +47,11 @@ android {
1947
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2048
}
2149
}
50+
51+
lint {
52+
baseline = file("lint-baseline.xml")
53+
}
54+
2255
compileOptions {
2356
sourceCompatibility JavaVersion.VERSION_1_8
2457
targetCompatibility JavaVersion.VERSION_1_8

besu/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
plugins {
22
id 'com.android.library'
3+
id 'maven-publish'
4+
}
5+
6+
publishing {
7+
publications {
8+
release(MavenPublication) {
9+
groupId = group
10+
artifactId = project.name
11+
version = version
12+
13+
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
14+
15+
pom {
16+
withXml {
17+
def dependenciesNode = asNode().appendNode('dependencies')
18+
configurations.api.allDependencies.each { dependency ->
19+
def dependencyNode = dependenciesNode.appendNode('dependency')
20+
dependencyNode.appendNode('groupId', dependency.group)
21+
dependencyNode.appendNode('artifactId', dependency.name)
22+
dependencyNode.appendNode('version', dependency.version)
23+
}
24+
}
25+
}
26+
}
27+
}
28+
repositories {
29+
mavenLocal()
30+
}
331
}
432

533
android {

build.gradle

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
12
plugins {
2-
id 'java'
3-
id 'idea'
3+
id 'com.android.library' version '8.5.1' apply false
44
id 'org.sonarqube' version '5.0.0.4638'
55
id 'jacoco'
66
id 'com.diffplug.spotless' version '6.25.0'
77
id 'io.codearte.nexus-staging' version '0.30.0'
88
id 'de.marcphilipp.nexus-publish' version '0.4.0'
99
id 'de.undercouch.download' version '4.1.2'
1010
id 'org.ajoberstar.git-publish' version '3.0.1'
11+
id 'com.android.application' version '8.5.1' apply false
12+
id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
13+
id 'maven-publish'
1114
}
1215

13-
14-
1516
ext {
1617
bouncycastleVersion = '1.78.1'
1718
jacksonVersion = '2.17.1'
1819
javaPoetVersion = '1.13.0'
19-
kotlinVersion = '1.9.24'
20-
kotlinPoetVersion = '1.16.0'
20+
kotlinVersion = '2.0.0'
21+
kotlinPoetVersion = '2.0.0'
2122
jnr_unixsocketVersion = '0.38.22'
2223
okhttpVersion = '4.12.0'
2324
rxjavaVersion = '2.2.21'
@@ -26,7 +27,6 @@ ext {
2627
picocliVersion = '4.7.6'
2728
ensAdraffyVersion = '0.2.0'
2829
kzg4844Version = '2.0.0'
29-
awsSdkVersion = '2.27.24'
3030
tuweniVersion = '2.4.2'
3131
// test dependencies
3232
equalsverifierVersion = '3.16.1'
@@ -38,46 +38,27 @@ ext {
3838
junitPlatformLauncherVersion = '1.5.2'
3939
}
4040

41-
42-
description 'Web3j base project.'
43-
44-
[
45-
'jacoco',
46-
'java',
47-
'javadoc',
48-
'publish',
49-
'repositories',
50-
'spotless'
51-
].each { buildScript ->
52-
download {
53-
src "https://raw.githubusercontent.com/hyperledger/web3j-build-tools/main/gradle/$buildScript/build.gradle"
54-
dest "$rootDir/gradle/$buildScript/build.gradle"
55-
overwrite false
56-
quiet true
57-
onlyIfModified true
58-
}
59-
}
60-
6141
allprojects {
6242
apply {
6343
[
64-
'java',
65-
'javadoc',
66-
'repositories',
67-
'spotless'
44+
'repositories'
6845
].each { buildScript ->
6946
from("$rootDir/gradle/$buildScript/build.gradle")
7047
}
7148
}
7249

50+
repositories {
51+
google()
52+
mavenCentral()
53+
}
54+
7355
tasks.withType(Test) {
7456
reports.html.destination = file("${reporting.baseDir}/${name}")
7557
useJUnitPlatform()
7658
}
7759

60+
7861
dependencies {
79-
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
80-
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoJunitVersion"
8162

8263
configurations.all {
8364
resolutionStrategy {
@@ -98,10 +79,3 @@ allprojects {
9879
apply from: "$rootDir/gradle/publish/build.gradle"
9980
}
10081
}
101-
configure(subprojects.findAll { it.name != 'integration-tests' }) {
102-
apply from: "$rootDir/gradle/jacoco/build.gradle"
103-
}
104-
105-
106-
tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle") }
107-
tasks.named("spotlessKotlin").configure { dependsOn("spotlessJava", "spotlessGroovyGradle") }

codegen/build.gradle

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
plugins {
22
id 'com.android.library'
33
id 'org.jetbrains.kotlin.android'
4+
id 'maven-publish'
5+
}
6+
7+
publishing {
8+
publications {
9+
release(MavenPublication) {
10+
groupId = group
11+
artifactId = project.name
12+
version = version
13+
14+
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
15+
16+
pom {
17+
withXml {
18+
def dependenciesNode = asNode().appendNode('dependencies')
19+
configurations.api.allDependencies.each { dependency ->
20+
def dependencyNode = dependenciesNode.appendNode('dependency')
21+
dependencyNode.appendNode('groupId', dependency.group)
22+
dependencyNode.appendNode('artifactId', dependency.name)
23+
dependencyNode.appendNode('version', dependency.version)
24+
}
25+
}
26+
}
27+
}
28+
}
29+
repositories {
30+
mavenLocal()
31+
}
432
}
533

634
android {
735
namespace 'com.org.web3j'
836
compileSdkVersion 34
937

1038
defaultConfig {
11-
minSdkVersion 24
39+
minSdkVersion 26
1240
targetSdkVersion 34
1341

1442
}
@@ -29,9 +57,10 @@ android {
2957
test {
3058
java.srcDirs = ['src/test/java']
3159
}
60+
3261
}
3362
kotlinOptions {
34-
jvmTarget = '17'
63+
jvmTarget = "17"
3564
}
3665
}
3766

@@ -49,11 +78,15 @@ dependencies {
4978
//testImplementation project(':core').sourceSets.test.output
5079
testImplementation "ch.qos.logback:logback-core:$logbackVersion"
5180
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
52-
testImplementation 'junit:junit:4.13.2'
81+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
82+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
83+
testImplementation 'org.mockito:mockito-core:5.5.0'
84+
testImplementation 'org.mockito:mockito-junit-jupiter:5.5.0'
5385

5486
implementation "org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion"
5587
implementation "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
5688
implementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
89+
// implementation 'org.eclipse.jdt:org.eclipse.jdt.core:3.32.0'
5790
testImplementation project(':android-test-utils')
5891
}
5992

0 commit comments

Comments
 (0)