Skip to content

Commit 41b940f

Browse files
authored
Merge pull request #37 from jitpack/regen_library
Regenerated library in Android Studio
2 parents a4b2ac5 + f55f886 commit 41b940f

File tree

12 files changed

+128
-56
lines changed

12 files changed

+128
-56
lines changed

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ Example Android library project that works with jitpack.io.
66

77
See this [Tutorial](https://medium.com/@ome450901/publish-an-android-library-by-jitpack-a0342684cbd0) on how to publish an Android Library with JitPack.
88

9-
For more details check out the [documentation](https://github.com/jitpack/jitpack.io/blob/master/ANDROID.md)
9+
For more details check out the [documentation](https://docs.jitpack.io/android/)
1010

1111
https://jitpack.io/#jitpack/android-example
1212

13-
Add it to your build.gradle with:
13+
Add it to your settings.gradle with:
1414
```gradle
15-
allprojects {
16-
repositories {
17-
maven { url "https://jitpack.io" }
18-
}
19-
}
15+
dependencyResolutionManagement {
16+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
17+
repositories {
18+
mavenCentral()
19+
maven { url 'https://jitpack.io' }
20+
}
21+
}
2022
```
2123
and:
2224

2325
```gradle
2426
dependencies {
25-
compile 'com.github.jitpack:android-example:{latest version}'
27+
implementation 'com.github.jitpack:android-example:{latest version}'
2628
}
2729
```
2830

@@ -33,16 +35,31 @@ https://github.com/jitpack-io/android-jitpack-library-example
3335

3436
## Adding the maven plugin
3537

36-
To enable installing into local maven repository and JitPack you need to add the [android-maven](https://github.com/dcendents/android-maven-gradle-plugin) plugin:
38+
To enable installing into local maven repository and JitPack you need to add the [maven-publish](https://developer.android.com/studio/build/maven-publish-plugin) plugin:
3739

38-
1. Add `classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'` to root build.gradle under `buildscript { dependencies {`
39-
2. Add `com.github.dcendents.android-maven` to the library/build.gradle
40+
Then add the publishing section to your library build.gradle:
41+
```gradle
42+
publishing {
43+
publications {
44+
release(MavenPublication) {
45+
groupId = 'com.my-company'
46+
artifactId = 'my-library'
47+
version = '1.0'
48+
49+
afterEvaluate {
50+
from components.release
51+
}
52+
}
53+
}
54+
}
55+
```
4056

4157
After these changes you should be able to run:
4258

43-
./gradlew install
59+
./gradlew publishToMavenLocal
4460

45-
from the root of your project. If install works and you have added a GitHub release it should work on jitpack.io
61+
from the root of your project.
62+
If `publishToMavenLocal` works and you have added a GitHub release it should work on jitpack.io
4663

4764
## Adding a sample app
4865

build.gradle

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = "1.6.10"
2+
ext.kotlin_version = "1.8.20"
33
repositories {
44
google()
55
mavenCentral()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.2.2'
8+
classpath 'com.android.tools.build:gradle:8.0.2'
99
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1010
}
1111
}
1212

13-
allprojects {
14-
repositories {
15-
google()
16-
maven { url "https://jitpack.io" }
17-
mavenCentral()
18-
}
19-
}
20-
21-
task clean(type: Delete) {
22-
delete rootProject.buildDir
23-
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

jitpack.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jdk:
2+
- openjdk17
3+

library/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

library/build.gradle

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
plugins {
22
id 'com.android.library'
3-
id 'kotlin-android'
3+
id 'org.jetbrains.kotlin.android'
44
id 'maven-publish'
55
}
66

7-
group = 'com.github.jitpack'
8-
version = '1.0'
9-
107
android {
11-
compileSdkVersion 31
8+
namespace 'io.jitpack.library'
9+
compileSdk 34
1210

1311
defaultConfig {
14-
minSdkVersion 21
15-
targetSdkVersion 31
16-
versionCode 1
17-
versionName "1.0"
12+
minSdk 24
13+
14+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15+
consumerProguardFiles "consumer-rules.pro"
1816
}
1917

2018
buildTypes {
@@ -23,28 +21,33 @@ android {
2321
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2422
}
2523
}
26-
24+
compileOptions {
25+
sourceCompatibility JavaVersion.VERSION_11
26+
targetCompatibility JavaVersion.VERSION_11
27+
}
2728
kotlinOptions {
28-
jvmTarget = '1.8'
29+
jvmTarget = '11'
2930
}
3031
}
3132

3233
dependencies {
33-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
34-
implementation 'androidx.core:core-ktx:1.7.0'
35-
implementation 'androidx.appcompat:appcompat:1.4.1'
36-
implementation 'com.google.android.material:material:1.5.0'
34+
implementation 'androidx.core:core-ktx:1.15.0'
35+
implementation 'androidx.appcompat:appcompat:1.7.0'
36+
implementation 'com.google.android.material:material:1.12.0'
37+
testImplementation 'junit:junit:4.13.2'
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
3740
}
3841

39-
afterEvaluate {
40-
publishing {
41-
publications {
42-
// Creates a Maven publication called "release".
43-
release(MavenPublication) {
42+
publishing {
43+
publications {
44+
release(MavenPublication) {
45+
groupId = 'io.jitpack'
46+
artifactId = 'library'
47+
version = '1.0'
48+
49+
afterEvaluate {
4450
from components.release
45-
groupId = 'com.github.jitpack'
46-
artifactId = 'android-example'
47-
version = '1.0'
4851
}
4952
}
5053
}

library/src/main/kotlin/io/jitpack/api/JitPack.kt renamed to library/consumer-rules.pro

File renamed without changes.

library/proguard-rules.pro

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
15
# For more details, see
26
# http://developer.android.com/guide/developing/tools/proguard.html
37

4-
# Add any project specific keep options here:
5-
68
# If your project uses WebView with JS, uncomment the following
79
# and specify the fully qualified class name to the JavaScript interface
810
# class:
911
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1012
# public *;
1113
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.jitpack.library
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("io.jitpack.library.test", appContext.packageName)
23+
}
24+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest package="io.jitpack.api">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
23

3-
<application />
4-
5-
</manifest>
4+
</manifest>

0 commit comments

Comments
 (0)