Skip to content

Commit f0a0956

Browse files
authored
Merge pull request #161 from solrudev/develop
0.19.5
2 parents 29c1574 + efca5ec commit f0a0956

13 files changed

Lines changed: 192 additions & 188 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
types:
66
- opened
77
- synchronize
8-
- closed
98

109
permissions:
1110
contents: read
@@ -148,74 +147,4 @@ jobs:
148147
if ! grep -q -v -E '(failure|cancelled)' <<< "$results"; then
149148
echo "One or more required jobs failed"
150149
exit 1
151-
fi
152-
153-
publish:
154-
name: Upload artifacts
155-
runs-on: ubuntu-latest
156-
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.base.ref == 'master' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
157-
needs: [ build ]
158-
159-
steps:
160-
- name: Checkout
161-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
162-
with:
163-
persist-credentials: false
164-
165-
- name: Setup environment
166-
uses: ./.github/actions/setup-gradle-environment-action
167-
with:
168-
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
169-
170-
- name: Publish
171-
run: |
172-
./gradlew publishAndReleaseToMavenCentral
173-
env:
174-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
175-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
176-
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
177-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
178-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
179-
180-
publish-docs:
181-
name: Publish documentation
182-
runs-on: ubuntu-latest
183-
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.base.ref == 'master' && github.event.pull_request.merged == true
184-
needs: [ build ]
185-
186-
permissions:
187-
contents: write
188-
189-
steps:
190-
- name: Checkout
191-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
192-
with:
193-
persist-credentials: false
194-
fetch-depth: 0
195-
196-
- name: Setup environment
197-
uses: ./.github/actions/setup-gradle-environment-action
198-
with:
199-
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
200-
201-
- name: Set up Python
202-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # 6.0.0
203-
with:
204-
python-version: 3.13.9
205-
206-
- name: Prepare API docs
207-
run: |
208-
./gradlew :api-documentation:dokkaGenerate
209-
210-
- name: Build MkDocs
211-
run: |
212-
pip3 install --upgrade pip && pip3 install mkdocs-material mkdocs-minify-plugin
213-
mkdocs build
214-
215-
- name: Deploy docs
216-
if: success()
217-
uses: JamesIves/github-pages-deploy-action@4a3abc783e1a24aeb44c16e869ad83caf6b4cc23 # 4.7.4
218-
with:
219-
branch: gh-pages
220-
folder: site
221-
single-commit: true
150+
fi

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: publish
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- master
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
publish:
15+
name: Upload artifacts
16+
runs-on: ubuntu-latest
17+
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
22+
with:
23+
persist-credentials: false
24+
25+
- name: Setup environment
26+
uses: ./.github/actions/setup-gradle-environment-action
27+
with:
28+
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
29+
30+
- name: Publish
31+
run: |
32+
./gradlew publishAndReleaseToMavenCentral
33+
env:
34+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
35+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
36+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
37+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
38+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
39+
40+
publish-docs:
41+
name: Publish documentation
42+
runs-on: ubuntu-latest
43+
if: github.repository == 'solrudev/Ackpine' && github.event.pull_request.merged == true
44+
45+
permissions:
46+
contents: write
47+
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
51+
with:
52+
persist-credentials: false
53+
fetch-depth: 0
54+
55+
- name: Setup environment
56+
uses: ./.github/actions/setup-gradle-environment-action
57+
with:
58+
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # 6.0.0
62+
with:
63+
python-version: 3.13.12
64+
65+
- name: Prepare API docs
66+
run: |
67+
./gradlew :api-documentation:dokkaGenerate
68+
69+
- name: Build MkDocs
70+
run: |
71+
pip3 install --upgrade pip && pip3 install mkdocs-material mkdocs-minify-plugin
72+
mkdocs build
73+
74+
- name: Deploy docs
75+
if: success()
76+
uses: JamesIves/github-pages-deploy-action@4a3abc783e1a24aeb44c16e869ad83caf6b4cc23 # 4.7.4
77+
with:
78+
branch: gh-pages
79+
folder: site
80+
single-commit: true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Ackpine depends on Jetpack libraries, so it's also necessary to add the `google(
3737

3838
```toml
3939
[versions]
40-
ackpine = "0.19.4"
40+
ackpine = "0.19.5"
4141

4242
[libraries]
4343
ackpine-core = { module = "ru.solrudev.ackpine:ackpine-core", version.ref = "ackpine" }
@@ -81,7 +81,7 @@ ackpine = [
8181

8282
```kotlin
8383
dependencies {
84-
val ackpineVersion = "0.19.4"
84+
val ackpineVersion = "0.19.5"
8585
implementation("ru.solrudev.ackpine:ackpine-core:$ackpineVersion")
8686

8787
// optional - Kotlin extensions and Coroutines support

ackpine-core/src/androidTest/kotlin/ru/solrudev/ackpine/impl/testutil/SessionTest.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package ru.solrudev.ackpine.impl.testutil
1818

19-
import kotlinx.coroutines.CoroutineScope
2019
import kotlinx.coroutines.CoroutineStart.UNDISPATCHED
2120
import kotlinx.coroutines.Dispatchers
2221
import kotlinx.coroutines.async
22+
import kotlinx.coroutines.coroutineScope
2323
import kotlinx.coroutines.withContext
2424
import kotlinx.coroutines.withTimeout
2525
import ru.solrudev.ackpine.remote.RemoteSession
@@ -34,39 +34,42 @@ import kotlin.time.Duration
3434
import kotlin.time.Duration.Companion.seconds
3535

3636
@OptIn(ExperimentalContracts::class)
37-
context(scope: CoroutineScope)
3837
suspend fun <F : Failure> Session<F>.test(
3938
timeout: Duration = 30.seconds,
4039
block: suspend (Session<F>) -> Unit
4140
): Session.State.Completed<F> {
4241
contract {
4342
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
4443
}
45-
val resultDeferred = scope.async(start = UNDISPATCHED) {
46-
withContext(Dispatchers.Default.limitedParallelism(1)) {
44+
return coroutineScope {
45+
val resultDeferred = async(
46+
context = Dispatchers.Default.limitedParallelism(1),
47+
start = UNDISPATCHED
48+
) {
4749
withTimeout(timeout) {
4850
await()
4951
}
5052
}
53+
block(this@test)
54+
resultDeferred.await()
5155
}
52-
block(this)
53-
return resultDeferred.await()
5456
}
5557

5658
@OptIn(ExperimentalContracts::class)
57-
context(scope: CoroutineScope)
5859
suspend fun RemoteSession.test(
5960
timeout: Duration = 30.seconds,
6061
block: suspend (RemoteSession) -> Unit = {}
6162
): RemoteSession.State {
6263
contract {
6364
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
6465
}
65-
val resultDeferred = scope.async(start = UNDISPATCHED) {
66-
awaitWithTimeout(timeout)
66+
return coroutineScope {
67+
val resultDeferred = async(start = UNDISPATCHED) {
68+
awaitWithTimeout(timeout)
69+
}
70+
block(this@test)
71+
resultDeferred.await()
6772
}
68-
block(this)
69-
return resultDeferred.await()
7073
}
7174

7275
suspend fun RemoteSession.awaitWithTimeout(timeout: Duration = 30.seconds): RemoteSession.State {

ackpine-resources/src/main/kotlin/ru/solrudev/ackpine/resources/ResolvableString.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public sealed interface ResolvableString : Serializable {
165165
private class TransientResource(
166166
@param:StringRes private val stringId: Int,
167167
private val args: Array<out Serializable>
168-
) : Resource(stringId, args) {
168+
) : Resource(*args) {
169169

170170
override fun stringId() = stringId
171171

build-logic/src/main/kotlin/ru/solrudev/ackpine/gradle/AckpineLibraryPlugin.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AckpineLibraryPlugin : Plugin<Project> {
5252
?.named("libs")
5353
?.findVersion("kotlin-for-consumers")
5454
?.get()
55-
?.displayName
55+
?.requiredVersion
5656
?: coreLibrariesVersion
5757
val kotlinVersion = KotlinVersion.fromVersion(
5858
stdlibVersion
@@ -69,10 +69,7 @@ public class AckpineLibraryPlugin : Plugin<Project> {
6969
apiVersion = kotlinVersion
7070
jvmTarget = JVM_1_8
7171
jvmDefault = JvmDefaultMode.NO_COMPATIBILITY
72-
freeCompilerArgs.addAll(
73-
"-Xconsistent-data-class-copy-visibility",
74-
"-Xcontext-parameters"
75-
)
72+
freeCompilerArgs.addAll("-Xconsistent-data-class-copy-visibility")
7673
}
7774

7875
abiValidation {

build-logic/src/main/kotlin/ru/solrudev/ackpine/gradle/publishing/AckpineArtifact.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,20 @@
1616

1717
package ru.solrudev.ackpine.gradle.publishing
1818

19-
import org.gradle.api.model.ObjectFactory
2019
import org.gradle.api.provider.Property
21-
import org.gradle.kotlin.dsl.property
22-
import javax.inject.Inject
2320

2421
/**
2522
* Extension for Ackpine `library-publish` plugin.
2623
*/
27-
public open class AckpineArtifact @Inject constructor(objectFactory: ObjectFactory) {
24+
public interface AckpineArtifact {
2825

2926
/**
3027
* Name of the published artifact.
3128
*/
32-
public val name: Property<String> = objectFactory.property<String>().convention("")
29+
public val name: Property<String>
3330

3431
/**
3532
* Inception year of the published artifact.
3633
*/
37-
public val inceptionYear: Property<String> = objectFactory.property<String>().convention("2023")
34+
public val inceptionYear: Property<String>
3835
}

build-logic/src/main/kotlin/ru/solrudev/ackpine/gradle/publishing/AckpineLibraryPublishPlugin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class AckpineLibraryPublishPlugin : Plugin<Project> {
4141
}
4242
}
4343
val artifact = ackpineLibraryExtension.extensions.create<AckpineArtifact>("artifact")
44+
artifact.name.convention("")
45+
artifact.inceptionYear.convention("2023")
4446
configurePublishing(artifact.name, provider { description }, artifact.inceptionYear)
4547
}
4648
}

build-logic/src/main/kotlin/ru/solrudev/ackpine/gradle/publishing/OptionalDependenciesPlugin.kt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import groovy.util.Node
2020
import groovy.util.NodeList
2121
import org.gradle.api.Plugin
2222
import org.gradle.api.Project
23+
import org.gradle.api.artifacts.component.ModuleComponentSelector
2324
import org.gradle.api.artifacts.result.ResolvedComponentResult
2425
import org.gradle.api.provider.Provider
2526
import org.gradle.api.publish.PublishingExtension
@@ -58,25 +59,30 @@ public class OptionalDependenciesPlugin : Plugin<Project> {
5859
}
5960

6061
private fun Project.configurePom(
61-
optionalDependencies: Provider<ResolvedComponentResult>
62+
resolvedOptionalDependencies: Provider<ResolvedComponentResult>
6263
) = extensions.configure<PublishingExtension> {
6364
publications.withType<MavenPublication>().configureEach {
6465
pom.withXml {
65-
val dependencies = (asNode()
66-
.get("dependencies") as NodeList)
67-
.first() as Node
68-
optionalDependencies
69-
.get()
70-
.dependencies
71-
.forEach { optionalDependency ->
72-
val (groupId, artifactId, version) = optionalDependency.requested.displayName.split(':')
73-
dependencies.appendNode("dependency").run {
74-
appendNode("groupId", groupId)
75-
appendNode("artifactId", artifactId)
76-
appendNode("version", version)
77-
appendNode("optional", true)
78-
}
66+
val optionalDependencies = resolvedOptionalDependencies.get().dependencies
67+
if (optionalDependencies.isEmpty()) {
68+
return@withXml
69+
}
70+
val root = asNode()
71+
val dependencies = (root.get("dependencies") as NodeList).firstOrNull() as Node?
72+
?: root.appendNode("dependencies")
73+
for (optionalDependency in optionalDependencies) {
74+
val componentSelector = optionalDependency.requested
75+
check(componentSelector is ModuleComponentSelector) {
76+
"Optional dependency '${componentSelector.displayName}' is not a module dependency. " +
77+
"Only external module dependencies are supported."
7978
}
79+
dependencies.appendNode("dependency").run {
80+
appendNode("groupId", componentSelector.group)
81+
appendNode("artifactId", componentSelector.module)
82+
appendNode("version", componentSelector.version)
83+
appendNode("optional", true)
84+
}
85+
}
8086
}
8187
}
8288
}

0 commit comments

Comments
 (0)