├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── deploy-docs.yml
│ └── gradle-build.yml
├── .gitignore
├── .idea
└── detekt.xml
├── .run
├── gradm.gradmDependencyUpdates.run.xml
├── gradm.integration-testing.run.xml
├── gradm.publish.run.xml
├── gradm.publishSnapshot.run.xml
├── gradm.publishToMavenLocal.run.xml
├── gradm.spotlessApply.run.xml
├── gradm.syncExamples.run.xml
└── gradm.syncGradleEnterpriseVersion.run.xml
├── LICENSE
├── README.md
├── build-logic
├── gradm
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradm.integration.github.yml
│ ├── gradm.yml
│ └── settings.gradle.kts
├── initialization
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ ├── gradm.api.settings.gradle.kts
│ │ ├── gradm.develocity.settings.gradle.kts
│ │ ├── gradm.settings.gradle.kts
│ │ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── initialization
│ │ ├── GradmApi.kt
│ │ └── Settings.kt
└── project
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
│ └── src
│ └── main
│ └── kotlin
│ ├── gradm.publishing.gradle.kts
│ ├── gradm.root.examples-updater.gradle.kts
│ ├── gradm.root.git.gradle.kts
│ ├── gradm.root.gradle.kts
│ ├── gradm.root.spotless.gradle.kts
│ └── me
│ └── omico
│ └── gradm
│ └── project
│ └── internal
│ └── Examples.kt
├── build.gradle.kts
├── detekt
└── detekt.yml
├── docs
├── .gitignore
├── .vuepress
│ ├── .gitignore
│ ├── config.ts
│ └── configs
│ │ ├── index.ts
│ │ └── sidebar
│ │ ├── en-US.ts
│ │ ├── index.ts
│ │ └── zh-Hans.ts
├── README.md
├── composite-build.md
├── getting-started.md
├── package-lock.json
├── package.json
└── zh-Hans
│ ├── README.md
│ ├── composite-build.md
│ └── getting-started.md
├── examples
├── gradm-getting-started
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── gradm
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ ├── gradm.integration.github.yml
│ │ ├── gradm3.yml
│ │ └── settings.gradle.kts
│ └── settings.gradle.kts
├── gradm-with-composite-build
│ ├── .gitignore
│ ├── build-logic
│ │ ├── gradm
│ │ │ ├── .gitignore
│ │ │ ├── build.gradle.kts
│ │ │ ├── gradm.yml
│ │ │ └── settings.gradle.kts
│ │ └── project
│ │ │ ├── .gitignore
│ │ │ ├── build.gradle.kts
│ │ │ ├── settings.gradle.kts
│ │ │ └── src
│ │ │ └── main
│ │ │ └── kotlin
│ │ │ ├── gradm-with-composite-build.android.library.gradle.kts
│ │ │ ├── gradm-with-composite-build.root.gradle.kts
│ │ │ └── gradm-with-composite-build.root.spotless.gradle.kts
│ ├── build.gradle.kts
│ ├── example
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src
│ │ │ └── main
│ │ │ └── kotlin
│ │ │ └── MainActivity.kt
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle.kts
├── gradm-with-kotlin-multiplatform
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── gradm
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ ├── gradm.yml
│ │ └── settings.gradle.kts
│ └── settings.gradle.kts
└── template
│ └── gradm.yml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── gradm-api
├── .gitignore
├── build.gradle.kts
├── datastore
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ └── src
│ │ ├── main
│ │ └── kotlin
│ │ │ └── me
│ │ │ └── omico
│ │ │ └── gradm
│ │ │ └── datastore
│ │ │ ├── GradmDataStore.kt
│ │ │ ├── GradmLocalConfiguration.kt
│ │ │ ├── GradmLocalConfigurationScope.kt
│ │ │ ├── GradmMetadata.kt
│ │ │ ├── GradmMetadataScope.kt
│ │ │ ├── internal
│ │ │ ├── GradmLocalConfigurationUpdater.kt
│ │ │ └── GradmMetadataUpdater.kt
│ │ │ └── maven
│ │ │ └── MavenMetadata.kt
│ │ └── test
│ │ └── kotlin
│ │ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── datastore
│ │ └── GradmDataStoreTest.kt
├── settings.gradle.kts
└── test
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── kotlin
│ └── me
│ └── omico
│ └── gradm
│ └── test
│ └── Test.kt
├── gradm-codegen
├── .gitignore
├── build.gradle.kts
├── gradle.properties
└── src
│ └── main
│ └── kotlin
│ └── me
│ └── omico
│ └── gradm
│ └── internal
│ └── codegen
│ ├── CodeGenerator.kt
│ ├── Dependencies.kt
│ ├── Plugin.kt
│ ├── Repositories.kt
│ ├── Self.kt
│ └── Versions.kt
├── gradm-gradle-plugin
├── .gitignore
├── build.gradle.kts
├── gradle.properties
└── src
│ └── main
│ └── kotlin
│ └── me
│ └── omico
│ └── gradm
│ ├── GradmExperimentalExtension.kt
│ ├── GradmFormatExtension.kt
│ ├── GradmPlugin.kt
│ ├── internal
│ ├── GradmExperimentalExtensionImpl.kt
│ ├── GradmExtensionImpl.kt
│ └── GradmFormatExtensionImpl.kt
│ ├── service
│ └── GradmWorkerService.kt
│ └── task
│ ├── GradmDependenciesTask.kt
│ ├── GradmDependencyUpdates.kt
│ ├── GradmInitialization.kt
│ ├── GradmSourcesGenerator.kt
│ └── GradmTask.kt
├── gradm-integration
├── api
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── integration
│ │ ├── GradmIntegration.kt
│ │ ├── GradmIntegrationExtension.kt
│ │ ├── GradmIntegrationExtensionImpl.kt
│ │ ├── GradmIntegrationHolder.kt
│ │ ├── GradmIntegrationOwner.kt
│ │ ├── GradmIntegrationPlugin.kt
│ │ ├── GradmIntegrationsExtension.kt
│ │ ├── GradmProjectWithIntegration.kt
│ │ └── internal
│ │ └── GradmProjectWithIntegrationImpl.kt
├── github
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── integration
│ │ └── github
│ │ ├── GradmGitHubIntegrationExtension.kt
│ │ ├── GradmGitHubIntegrationPlugin.kt
│ │ └── internal
│ │ ├── GithubFetcher.kt
│ │ ├── GithubVersionConfiguration.kt
│ │ ├── GradmGitHubIntegrationExtensionImpl.kt
│ │ └── GradmGithubIntegrationConfiguration.kt
└── runtime
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── gradle.properties
│ └── src
│ └── main
│ └── kotlin
│ └── me
│ └── omico
│ └── gradm
│ └── integration
│ ├── GradmIntegrationManager.kt
│ └── internal
│ ├── GradmIntegrationConfiguration.kt
│ └── GradmIntegrationHolderImpl.kt
├── gradm-runtime
├── .gitignore
├── build.gradle.kts
├── gradle.properties
└── src
│ ├── main
│ ├── kotlin
│ │ └── me
│ │ │ └── omico
│ │ │ └── gradm
│ │ │ ├── Gradm.kt
│ │ │ ├── GradmConfiguration.kt
│ │ │ ├── GradmExtension.kt
│ │ │ ├── GradmGeneratedPlugin.kt
│ │ │ ├── VersionsMeta.kt
│ │ │ ├── internal
│ │ │ ├── Hash.kt
│ │ │ ├── Yaml.kt
│ │ │ ├── config
│ │ │ │ ├── Dependencies.kt
│ │ │ │ ├── Plugins.kt
│ │ │ │ ├── Repositories.kt
│ │ │ │ ├── Versions.kt
│ │ │ │ └── format
│ │ │ │ │ ├── Builder.kt
│ │ │ │ │ ├── Comment.kt
│ │ │ │ │ ├── Formatter.kt
│ │ │ │ │ ├── FormatterScope.kt
│ │ │ │ │ ├── ScalarStyle.kt
│ │ │ │ │ ├── Yaml.kt
│ │ │ │ │ └── node
│ │ │ │ │ ├── CollectionNode.kt
│ │ │ │ │ ├── MappingNode.kt
│ │ │ │ │ ├── Node.kt
│ │ │ │ │ ├── ScalarNode.kt
│ │ │ │ │ └── SequenceNode.kt
│ │ │ └── maven
│ │ │ │ ├── MavenMetadataResovler.kt
│ │ │ │ ├── MavenUpdates.kt
│ │ │ │ ├── Version.kt
│ │ │ │ ├── Xml.kt
│ │ │ │ └── bom
│ │ │ │ ├── MavenBomPom.kt
│ │ │ │ └── MavenPomPomResolver.kt
│ │ │ ├── path
│ │ │ └── GradmProjectPaths.kt
│ │ │ ├── service
│ │ │ └── GradmBuildService.kt
│ │ │ └── utility
│ │ │ └── Path.kt
│ └── kotlinTemplates
│ │ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── GradmVersion.kt
│ └── test
│ ├── kotlin
│ └── me
│ │ └── omico
│ │ └── gradm
│ │ └── internal
│ │ ├── config
│ │ └── format
│ │ │ └── FormatterTest.kt
│ │ └── maven
│ │ └── VersionTest.kt
│ └── resources
│ ├── format-test.yml
│ ├── gradm.formatted.yml
│ └── gradm.unformatted.yml
├── integration-testing
├── .gitignore
├── build.gradle.kts
└── src
│ └── test
│ └── kotlin
│ └── me
│ └── omico
│ └── gradm
│ ├── GettingStartedTest.kt
│ ├── WithCompositeBuildTest.kt
│ ├── WithKotlinMultiplatformTest.kt
│ └── utility
│ └── Gradle.kt
├── settings.gradle.kts
└── spotless
└── copyright.kt
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text eol=lf
2 | *.bat text eol=crlf
3 | *.jar binary
4 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-docs.yml:
--------------------------------------------------------------------------------
1 | name: Deploy docs
2 |
3 | on:
4 | push:
5 | branches:
6 | - release
7 | paths:
8 | - '.github/workflows/deploy-docs.yml'
9 | - 'docs/**'
10 | workflow_dispatch:
11 |
12 | permissions:
13 | contents: read
14 | pages: write
15 | id-token: write
16 |
17 | concurrency:
18 | group: 'pages'
19 | cancel-in-progress: false
20 |
21 | jobs:
22 | build:
23 | runs-on: ubuntu-latest
24 |
25 | steps:
26 | - uses: actions/checkout@v4
27 |
28 | - uses: actions/setup-node@v4
29 | with:
30 | node-version: 18
31 | cache: npm
32 | cache-dependency-path: './docs/package-lock.json'
33 |
34 | - name: Setup Pages
35 | id: pages
36 | uses: actions/configure-pages@v5
37 |
38 | - name: Build
39 | run: |
40 | cd ./docs
41 | npm ci
42 | npm run docs:build
43 |
44 | - uses: actions/upload-pages-artifact@v3
45 | with:
46 | path: ./docs/.vuepress/dist
47 |
48 | deploy:
49 | needs: build
50 |
51 | environment:
52 | name: github-pages
53 | url: ${{ steps.deployment.outputs.page_url }}
54 |
55 | runs-on: ubuntu-latest
56 |
57 | steps:
58 | - name: Deploy to GitHub Pages
59 | id: deployment
60 | uses: actions/deploy-pages@v4
61 |
--------------------------------------------------------------------------------
/.github/workflows/gradle-build.yml:
--------------------------------------------------------------------------------
1 | name: Gradle Build
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - 'main'
8 | workflow_dispatch:
9 |
10 | concurrency:
11 | group: '${{ github.workflow }}-${{ github.ref }}'
12 | cancel-in-progress: false
13 |
14 | jobs:
15 | gradle-build:
16 | name: Gradle Build
17 | runs-on: ubuntu-latest
18 | env:
19 | DEPENDENCY_GRAPH_EXCLUDE_PROJECTS: ':(gradm|initialization|project)'
20 | steps:
21 | - uses: actions/checkout@v4
22 | with:
23 | fetch-depth: 0
24 |
25 | - uses: actions/setup-java@v4
26 | with:
27 | distribution: 'temurin'
28 | java-version: '17'
29 |
30 | - name: Setup Gradle
31 | uses: gradle/actions/setup-gradle@v4
32 | with:
33 | cache-read-only: ${{ github.ref != 'refs/heads/main' }}
34 | dependency-graph: generate-and-upload
35 |
36 | - run: ./gradlew build --no-daemon --stacktrace
37 |
38 | gradle-submit-dependency-graph:
39 | name: Gradle Submit Dependency Graph
40 | uses: OmicoDev/gradle-project-initializer-template/.github/workflows/gradle-submit-dependency-graph.yml@main
41 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
42 | needs: gradle-build
43 | permissions:
44 | contents: write
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.gradle
3 | /.idea
4 | /.kotlin
5 | /build
6 | /local.properties
7 |
8 | !/.idea/detekt.xml
9 | !/.idea/jsonSchemas.xml
10 |
--------------------------------------------------------------------------------
/.idea/detekt.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/gradm.gradmDependencyUpdates.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 | false
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.run/gradm.integration-testing.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 | false
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.run/gradm.publish.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | true
22 | true
23 | false
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.run/gradm.publishSnapshot.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | true
21 | true
22 | false
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.run/gradm.publishToMavenLocal.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | true
21 | true
22 | false
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.run/gradm.spotlessApply.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.run/gradm.syncExamples.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | true
20 | true
21 | false
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.run/gradm.syncGradleEnterpriseVersion.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gradm
2 |
3 | 
4 | 
5 |
6 | Gradm (**Gra**dle **d**ependencies **m**anager) is a new way to manage dependencies easier and more efficient.
7 |
8 | For more information, please see the [documentation](https://gradm.omico.me/).
9 |
10 | ## License
11 |
12 | ```txt
13 | Copyright 2022 Omico
14 |
15 | Licensed under the Apache License, Version 2.0 (the "License");
16 | you may not use this file except in compliance with the License.
17 | You may obtain a copy of the License at
18 |
19 | https://www.apache.org/licenses/LICENSE-2.0
20 |
21 | Unless required by applicable law or agreed to in writing, software
22 | distributed under the License is distributed on an "AS IS" BASIS,
23 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | See the License for the specific language governing permissions and
25 | limitations under the License.
26 | ```
27 |
--------------------------------------------------------------------------------
/build-logic/gradm/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 |
--------------------------------------------------------------------------------
/build-logic/gradm/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | id("me.omico.gradm") version "4.0.0-beta03"
4 | id("me.omico.gradm.integration.github") version "4.0.0-beta03"
5 | }
6 |
7 | repositories {
8 | mavenCentral()
9 | }
10 |
11 | gradm {
12 | pluginId = "gradm.gradm"
13 | debug = true
14 | }
15 |
--------------------------------------------------------------------------------
/build-logic/gradm/gradm.integration.github.yml:
--------------------------------------------------------------------------------
1 | github:
2 | versions:
3 | - repository: gradle/gradle
4 | regex: "v([\\d].[\\d](.[1-9])?)"
5 | matchType: "partial"
6 |
--------------------------------------------------------------------------------
/build-logic/gradm/gradm.yml:
--------------------------------------------------------------------------------
1 | versions:
2 | consensus: "0.13.0"
3 | elucidator: "0.14.0"
4 | junit: "5.10.3"
5 | kotlinpoet: "1.17.0"
6 | kotlinx:
7 | coroutines: "1.8.1"
8 | serialization: "1.6.3"
9 | plugins:
10 | develocity: "3.17.6"
11 | spotless: "7.0.0.BETA1"
12 | snakeyaml: "2.7"
13 |
14 | repositories:
15 | mavenLocal:
16 | omico:
17 | mavenCentral:
18 | gradlePluginPortal:
19 | noUpdates:
20 |
21 | plugins:
22 | gradlePluginPortal:
23 | com.diffplug.spotless: ${versions.plugins.spotless}
24 | com.gradle.develocity: ${versions.plugins.develocity}
25 |
26 | dependencies:
27 | mavenCentral:
28 | com.squareup:
29 | kotlinpoet:
30 | alias: libs.kotlinpoet
31 | version: ${versions.kotlinpoet}
32 | org.jetbrains.kotlinx:
33 | kotlinx-coroutines-core:
34 | alias: libs.kotlinx.coroutines
35 | version: ${versions.kotlinx.coroutines}
36 | kotlinx-serialization-json:
37 | alias: libs.kotlinx.serialization.json
38 | version: ${versions.kotlinx.serialization}
39 | kotlinx-serialization-protobuf:
40 | alias: libs.kotlinx.serialization.protobuf
41 | version: ${versions.kotlinx.serialization}
42 | org.junit:
43 | junit-bom:
44 | alias: libs.junit.bom
45 | version: ${versions.junit}
46 | org.junit.jupiter:
47 | junit-jupiter:
48 | alias: libs.junit.jupiter
49 | noSpecificVersion: true
50 | org.snakeyaml:
51 | snakeyaml-engine:
52 | alias: libs.snakeyaml
53 | version: ${versions.snakeyaml}
54 | omico:
55 | me.omico.consensus:
56 | consensus-gradle-plugins:
57 | alias: consensusGradlePlugins
58 | version: ${versions.consensus}
59 | me.omico.elucidator:
60 | elucidator:
61 | alias: libs.elucidator
62 | version: ${versions.elucidator}
63 |
--------------------------------------------------------------------------------
/build-logic/gradm/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-gradm"
2 |
3 | pluginManagement {
4 | repositories {
5 | maven(url = "https://maven.omico.me")
6 | gradlePluginPortal()
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/build-logic/initialization/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 |
--------------------------------------------------------------------------------
/build-logic/initialization/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | }
4 |
5 | dependencies {
6 | implementation(com.gradle.develocity)
7 | implementation(gradmGeneratedJar)
8 | }
9 |
--------------------------------------------------------------------------------
/build-logic/initialization/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-initialization"
2 |
3 | pluginManagement {
4 | includeBuild("../gradm")
5 | }
6 |
7 | plugins {
8 | id("gradm.gradm")
9 | }
10 |
--------------------------------------------------------------------------------
/build-logic/initialization/src/main/kotlin/gradm.api.settings.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.gradm.addDeclaredRepositories
2 | import me.omico.gradm.initialization.includeGradmApi
3 |
4 | addDeclaredRepositories()
5 |
6 | plugins {
7 | id("gradm.gradm")
8 | }
9 |
10 | includeBuild("../build-logic/project")
11 |
12 | includeGradmApi(":datastore")
13 | includeGradmApi(":test")
14 |
--------------------------------------------------------------------------------
/build-logic/initialization/src/main/kotlin/gradm.develocity.settings.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.gradle.develocity")
3 | }
4 |
5 | develocity {
6 | buildScan {
7 | termsOfUseUrl = "https://gradle.com/terms-of-service"
8 | termsOfUseAgree = "yes"
9 | publishing {
10 | val isOffline = providers.provider { gradle.startParameter.isOffline }
11 | onlyIf { !isOffline.getOrElse(false) }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/build-logic/initialization/src/main/kotlin/gradm.settings.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.gradm.addDeclaredRepositories
2 | import me.omico.gradm.initialization.gradmApiModules
3 | import me.omico.gradm.initialization.includeGradm
4 | import me.omico.gradm.initialization.syncPropertiesToGradmApi
5 |
6 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
7 |
8 | addDeclaredRepositories()
9 |
10 | plugins {
11 | id("gradm.develocity")
12 | id("gradm.gradm")
13 | }
14 |
15 | includeBuild("build-logic/project")
16 |
17 | syncPropertiesToGradmApi()
18 | includeBuild("gradm-api") {
19 | dependencySubstitution {
20 | val version = extra["project.version"] as String
21 | gradmApiModules.forEach { module ->
22 | substitute(module("me.omico.gradm:gradm-api-$module:$version")).using(project(":gradm-api-$module"))
23 | }
24 | }
25 | }
26 |
27 | includeGradm(":gradm-codegen")
28 | includeGradm(":gradm-gradle-plugin")
29 | includeGradm(":gradm-integration:api")
30 | includeGradm(":gradm-integration:github")
31 | includeGradm(":gradm-integration:runtime")
32 | includeGradm(":gradm-runtime")
33 |
34 | include(":integration-testing")
35 |
--------------------------------------------------------------------------------
/build-logic/initialization/src/main/kotlin/me/omico/gradm/initialization/GradmApi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.initialization
17 |
18 | import org.gradle.api.initialization.Settings
19 | import java.io.File
20 |
21 | internal fun Settings.syncPropertiesToGradmApi() {
22 | settingsDir.resolve("gradle.properties")
23 | .copyTo(
24 | target = settingsDir.resolve("gradm-api/gradle.properties"),
25 | overwrite = true,
26 | )
27 | settingsDir.resolve("local.properties")
28 | .takeIf(File::exists)
29 | ?.copyTo(
30 | target = settingsDir.resolve("gradm-api/local.properties"),
31 | overwrite = true,
32 | )
33 | }
34 |
35 | internal fun Settings.includeGradmApi(path: String) {
36 | include(path)
37 | project(path).name = "gradm-api${path.replace(":", "-")}"
38 | }
39 |
40 | internal val Settings.gradmApiModules: Set
41 | get() = settingsDir.resolve("gradm-api").walk()
42 | .maxDepth(1)
43 | .filter(File::isDirectory)
44 | .map(File::getName)
45 | .filterNot { it in ignoredList }
46 | .toSet()
47 |
48 | private val ignoredList = listOf(
49 | "gradm-api",
50 | ".gradle",
51 | "build",
52 | )
53 |
--------------------------------------------------------------------------------
/build-logic/initialization/src/main/kotlin/me/omico/gradm/initialization/Settings.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.initialization
17 |
18 | import org.gradle.api.initialization.Settings
19 |
20 | internal fun Settings.includeGradm(path: String) {
21 | include(path)
22 | project(path).name = path.removePrefix(":").replace(":", "-")
23 | }
24 |
--------------------------------------------------------------------------------
/build-logic/project/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 |
--------------------------------------------------------------------------------
/build-logic/project/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | }
4 |
5 | dependencies {
6 | implementation(com.diffplug.spotless)
7 | implementation(consensusGradlePlugins)
8 | implementation(embeddedKotlin("gradle-plugin"))
9 | implementation(embeddedKotlin("serialization"))
10 | implementation(gradmGeneratedJar)
11 | }
12 |
--------------------------------------------------------------------------------
/build-logic/project/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-build-logic-project"
2 |
3 | pluginManagement {
4 | includeBuild("../gradm")
5 | }
6 |
7 | plugins {
8 | id("gradm.gradm")
9 | }
10 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/gradm.publishing.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.api.dsl.by
2 | import me.omico.consensus.api.dsl.isAutomatedPublishingGradlePlugin
3 |
4 | plugins {
5 | id("me.omico.consensus.publishing")
6 | }
7 |
8 | consensus {
9 | publishing {
10 | when {
11 | environmentVariables.getOrDefault("CI", false) -> publishToNexusRepository()
12 | else -> publishToLocalRepository("MAVEN_OMICO_LOCAL_URI")
13 | }
14 | signing {
15 | if (isSnapshot) return@signing
16 | useGpgCmd()
17 | sign(publications)
18 | }
19 | afterEvaluate {
20 | if (!isAutomatedPublishingGradlePlugin) {
21 | createMavenPublication {
22 | from(components["java"])
23 | }
24 | }
25 | publications.all {
26 | if (this !is MavenPublication) return@all
27 | pom {
28 | name by gradleProperty("POM_NAME")
29 | description by gradleProperty("POM_DESCRIPTION")
30 | url by "https://github.com/Omico/Gradm"
31 | licenses {
32 | license {
33 | name by "The Apache Software License, Version 2.0"
34 | url by "https://www.apache.org/licenses/LICENSE-2.0.txt"
35 | }
36 | }
37 | developers {
38 | developer {
39 | id by "Omico"
40 | name by "Omico"
41 | }
42 | }
43 | scm {
44 | url by "https://github.com/Omico/Gradm"
45 | connection by "scm:git:https://github.com/Omico/Gradm.git"
46 | developerConnection by "scm:git:https://github.com/Omico/Gradm.git"
47 | }
48 | }
49 | }
50 | }
51 | }
52 | }
53 |
54 | extensions.findByType()?.apply {
55 | withSourcesJar()
56 | withJavadocJar()
57 | }
58 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/gradm.root.examples-updater.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.api.dsl.requireRootProject
2 | import me.omico.gradm.project.internal.replacePluginVersions
3 |
4 | plugins {
5 | id("gradm.gradm")
6 | }
7 |
8 | requireRootProject()
9 |
10 | val syncExamples by tasks.registering {
11 | file("examples").walk()
12 | .filter { it.endsWith("settings.gradle.kts") || it.endsWith("build.gradle.kts") }
13 | .forEach { file ->
14 | buildString {
15 | file.readLines().forEach { line ->
16 | line
17 | .replacePluginVersions(
18 | "me.omico.gradm" to properties["project.version"].toString(),
19 | "me.omico.gradm.integration.github" to properties["project.version"].toString(),
20 | "com.gradle.develocity" to versions.plugins.develocity,
21 | )
22 | .let(::appendLine)
23 | }
24 | }.let(file::writeText)
25 | }
26 | listOf(
27 | "examples/gradm-getting-started/gradm/gradm3.yml",
28 | "examples/gradm-with-composite-build/build-logic/gradm/gradm.yml",
29 | "examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml",
30 | ).forEach {
31 | file("examples/template/gradm.yml").copyTo(file(it), overwrite = true)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/gradm.root.git.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.api.dsl.requireRootProject
2 |
3 | plugins {
4 | id("me.omico.consensus.git")
5 | }
6 |
7 | requireRootProject()
8 |
9 | consensus {
10 | git {
11 | hooks {
12 | preCommit {
13 | appendLine("#!/bin/sh")
14 | appendLine()
15 | if (file("gradlew").exists()) {
16 | appendLine("# Give gradlew execute permission")
17 | appendLine("git ls-files \"*gradlew\" | xargs git update-index --add --chmod=+x")
18 | appendLine()
19 | }
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/gradm.root.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("me.omico.consensus.root")
3 | id("gradm.gradm")
4 | id("gradm.root.examples-updater")
5 | id("gradm.root.git")
6 | id("gradm.root.spotless")
7 | }
8 |
9 | val wrapper: Wrapper by tasks.named("wrapper") {
10 | gradleVersion = versions.gradle
11 | distributionType = Wrapper.DistributionType.BIN
12 | }
13 |
14 | val syncGradleWrapperForExamples by tasks.registering {
15 | file("examples").walk().maxDepth(1)
16 | .filter { directory -> directory.resolve("settings.gradle.kts").exists() }
17 | .map(File::getName)
18 | .forEach { example ->
19 | copy {
20 | from(wrapper.scriptFile, wrapper.batchScript)
21 | into("examples/$example")
22 | }
23 | copy {
24 | from(wrapper.jarFile, wrapper.propertiesFile)
25 | into("examples/$example/gradle/wrapper")
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/gradm.root.spotless.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.api.dsl.requireRootProject
2 | import me.omico.consensus.api.dsl.rootGradle
3 | import me.omico.consensus.spotless.ConsensusSpotlessTokens
4 |
5 | plugins {
6 | id("me.omico.consensus.spotless")
7 | }
8 |
9 | requireRootProject()
10 |
11 | consensus {
12 | spotless {
13 | rootProject {
14 | freshmark(
15 | excludeTargets = setOf("**/node_modules/**"),
16 | )
17 | gradleProperties()
18 | intelliJIDEARunConfiguration()
19 | }
20 | allprojects {
21 | kotlin(
22 | targets = ConsensusSpotlessTokens.Kotlin.targets + setOf(
23 | "build-logic/initialization/src/**/*.kt",
24 | ),
25 | licenseHeaderFile = rootGradle.rootProject.file("spotless/copyright.kt"),
26 | )
27 | kotlinGradle()
28 | }
29 | }
30 | }
31 |
32 | subprojects {
33 | rootProject.tasks {
34 | spotlessApply { dependsOn(this@subprojects.tasks.spotlessApply) }
35 | spotlessCheck { dependsOn(this@subprojects.tasks.spotlessCheck) }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/build-logic/project/src/main/kotlin/me/omico/gradm/project/internal/Examples.kt:
--------------------------------------------------------------------------------
1 | package me.omico.gradm.project.internal
2 |
3 | internal fun String.replacePluginVersions(vararg pairs: Pair): String =
4 | pairs.fold(this) { acc, (pluginId, version) -> acc.replacePluginVersion(pluginId, version) }
5 |
6 | private fun String.replacePluginVersion(pluginId: String, version: String): String =
7 | replace(
8 | regex = """\s+id\("$pluginId"\)\s+version\s+"(.*)"""".toRegex(),
9 | replacement = " id(\"$pluginId\") version \"$version\"",
10 | )
11 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("gradm.root")
3 | }
4 |
5 | listOf(
6 | "spotlessApply",
7 | "spotlessCheck",
8 | ).forEach { taskName ->
9 | tasks[taskName].dependsOn(gradle.includedBuild("gradm-api").task(":$taskName"))
10 | }
11 |
12 | listOf(
13 | "publishToMavenLocal",
14 | "publish",
15 | ).forEach { taskName ->
16 | tasks.register(taskName) {
17 | listOf(
18 | "datastore",
19 | ).forEach { module ->
20 | dependsOn(gradle.includedBuild("gradm-api").task(":gradm-api-$module:$taskName"))
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/detekt/detekt.yml:
--------------------------------------------------------------------------------
1 | complexity:
2 | LongParameterList:
3 | active: false
4 | TooManyFunctions:
5 | active: false
6 |
7 | naming:
8 | MatchingDeclarationName:
9 | active: false
10 |
11 | style:
12 | MagicNumber:
13 | active: false
14 | MaxLineLength:
15 | active: false
16 | ReturnCount:
17 | active: false
18 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /node_modules
3 |
--------------------------------------------------------------------------------
/docs/.vuepress/.gitignore:
--------------------------------------------------------------------------------
1 | /.cache
2 | /.temp
3 | /dist
4 |
--------------------------------------------------------------------------------
/docs/.vuepress/config.ts:
--------------------------------------------------------------------------------
1 | import {viteBundler} from "@vuepress/bundler-vite"
2 | import {backToTopPlugin} from "@vuepress/plugin-back-to-top"
3 | import {gitPlugin} from "@vuepress/plugin-git"
4 | import {defaultTheme} from "@vuepress/theme-default"
5 | import {defineUserConfig} from "vuepress"
6 | import {sidebar_en_us, sidebar_zh_hans} from "./configs"
7 |
8 | export default defineUserConfig(
9 | {
10 | bundler: viteBundler(),
11 | locales: {
12 | "/": {
13 | lang: "en-US",
14 | title: "Gradm",
15 | },
16 | "/zh-Hans/": {
17 | lang: "zh-Hans",
18 | title: "Gradm",
19 | },
20 | },
21 | theme: defaultTheme(
22 | {
23 | docsRepo: "Omico/Gradm",
24 | docsDir: "docs",
25 | docsBranch: "main",
26 | editLink: true,
27 | locales: {
28 | "/": {
29 | sidebar: sidebar_en_us,
30 | },
31 | "/zh-Hans/": {
32 | sidebar: sidebar_zh_hans,
33 | selectLanguageName: "简体中文",
34 | selectLanguageText: "语言",
35 | selectLanguageAriaLabel: "选择语言",
36 | editLinkText: "在 GitHub 上编辑此页",
37 | lastUpdatedText: "上次更新",
38 | contributorsText: "贡献者",
39 | },
40 | },
41 | },
42 | ),
43 | plugins: [
44 | backToTopPlugin(),
45 | gitPlugin(
46 | {
47 | contributors: false,
48 | },
49 | ),
50 | ],
51 | },
52 | )
53 |
--------------------------------------------------------------------------------
/docs/.vuepress/configs/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./sidebar/index"
2 |
--------------------------------------------------------------------------------
/docs/.vuepress/configs/sidebar/en-US.ts:
--------------------------------------------------------------------------------
1 | import type {SidebarOptions} from "@vuepress/theme-default"
2 |
3 | export const sidebar_en_us: SidebarOptions = {
4 | "/": [
5 | {
6 | text: "Guide",
7 | children: [
8 | "/README.md",
9 | "/getting-started.md",
10 | "/composite-build.md",
11 | ],
12 | },
13 | ],
14 | }
15 |
--------------------------------------------------------------------------------
/docs/.vuepress/configs/sidebar/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./zh-Hans"
2 | export * from "./en-US"
3 |
--------------------------------------------------------------------------------
/docs/.vuepress/configs/sidebar/zh-Hans.ts:
--------------------------------------------------------------------------------
1 | import type {SidebarOptions} from "@vuepress/theme-default"
2 |
3 | export const sidebar_zh_hans: SidebarOptions = {
4 | "/zh-Hans/": [
5 | {
6 | text: "指南",
7 | children: [
8 | "/zh-Hans/README.md",
9 | "/zh-Hans/getting-started.md",
10 | "/zh-Hans/composite-build.md",
11 | ],
12 | },
13 | ],
14 | }
15 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | 
4 | 
5 |
6 | Gradm (**Gra**dle **d**ependencies **m**anager) is a new way to manage dependencies easier and more efficient.
7 |
8 | ## Why Gradm?
9 |
10 | The Gradle version catalogs is an excellent move for us. But it also brings a lot of problems, and becomes more and more painful:
11 |
12 | * The Generated code is fully Java, with very poor readability.
13 | * ~~No official dependencies update support.~~
14 | * Terrible restrictions, like naming: , .
15 | * And more...?
16 |
17 | **Gradm** was born for the above problems. It has an excellent ability of dependencies management and versions update:
18 |
19 | * The Generated code is fully Kotlin and can quickly obtain dependency information through code jumps.
20 | * Provides the same usage as the Gradle version catalog and removes naming restrictions.
21 | * Provide dependency update support. (Will appear in Gradle build output, if updates exist.)
22 | * Less configuration code, no need configure repositories in gradle files.
23 | * More features are under development...
24 |
25 | Want to know more about what the Gradm generated code plugin does, please check me.omico.gradm.generated.GradmPlugin for more information.
26 |
--------------------------------------------------------------------------------
/docs/composite-build.md:
--------------------------------------------------------------------------------
1 | # Use in composite build
2 |
3 | 
4 | 
5 |
6 | **Assuming you have read [getting-started](./getting-started).**
7 |
8 | Create a `build-logic/project` folder in your root path.
9 |
10 | Create a new `settings.gradle.kts` to `build-logic/project/settings.gradle.kts`, add the following:
11 |
12 | ```kotlin
13 | pluginManagement {
14 | includeBuild("build-logic/gradm")
15 | }
16 |
17 | plugins {
18 | id("") // default is "me.omico.gradm.generated"
19 | }
20 | ```
21 |
22 | Copy `gradm` folder from [getting-started](./getting-started) to `build-logic/gradm`.
23 |
24 | ## Customizing
25 |
26 | If you want to customize some *.gradle.kts scripts, you may want to use versions or dependencies directly.
27 |
28 | Assuming you have defined some scripts into `build-logic/project/main/src/kotlin` module.
29 |
30 | You can do this by adding the following to `build-logic/project/build.gradle.kts`:
31 |
32 | ```kotlin
33 | dependencies {
34 | implementation(gradmGeneratedJar)
35 | }
36 | ```
37 |
38 | You can see a actual example in [build-logic.android.library.gradle.kts](https://github.com/Omico/Gradm/blob/release/examples/gradm-with-composite-build/build-logic/convention/src/main/kotlin/build-logic.android.library.gradle.kts).
39 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gradm-docs",
3 | "private": true,
4 | "type": "module",
5 | "scripts": {
6 | "npm:update": "npm update",
7 | "docs:dev": "vuepress dev",
8 | "docs:build": "vuepress build"
9 | },
10 | "devDependencies": {
11 | "@vuepress/bundler-vite": "^2.0.0-rc.13",
12 | "@vuepress/plugin-back-to-top": "next",
13 | "@vuepress/plugin-git": "next",
14 | "@vuepress/theme-default": "next",
15 | "vuepress": "next"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/docs/zh-Hans/README.md:
--------------------------------------------------------------------------------
1 | # 简介
2 |
3 | 
4 | 
5 |
6 | Gradm (**Gra**dle **d**ependencies **m**anager) 是一种新的简洁并高效的方式来管理依赖。
7 |
8 | ## 为什么是 Gradm?
9 |
10 | Gradle version catalogs 是一个很好的改进。但是也带来了很多问题,而且变得越来越痛苦:
11 |
12 | * 生成的代码是完全 Java 的。可用,但是可读性极差。
13 | * ~~没有官方的依赖更新支持。~~
14 | * 拥有诸多限制,比如命名:, .
15 | * 或许还有更多。。。?
16 |
17 | **Gradm** 就是在这样的背景下诞生的。它拥有优秀的依赖管理和版本更新能力:
18 |
19 | * 生成的代码是完全 Kotlin 的,并且可以通过代码跳转快速获取依赖信息。
20 | * 提供了与 Gradle version catalogs 相同的使用方式,并且移除了命名限制。
21 | * 提供了依赖更新支持。(如果存在更新,将会出现在 Gradle 构建输出中)
22 | * 更少的配置代码,不需要在 Gradle 文件中配置仓库(repositories)。
23 | * 更多功能正在开发中。。。
24 |
25 | 想知道更多关于 Gradm 生成的代码插件做了什么,请查看 me.omico.gradm.generated.GradmPlugin 了解更多信息。
26 |
--------------------------------------------------------------------------------
/docs/zh-Hans/composite-build.md:
--------------------------------------------------------------------------------
1 | # 在复合构建中使用
2 |
3 | 
4 | 
5 |
6 | **假设你已经阅读[入门](./getting-started).**
7 |
8 | 在你的根目录下创建 `build-logic/project` 文件夹。
9 |
10 | 新建一个 `settings.gradle.kts` 到 `build-logic/project/settings.gradle.kts`,并添加以下内容:
11 |
12 | ```kotlin
13 | pluginManagement {
14 | includeBuild("build-logic/gradm")
15 | }
16 |
17 | plugins {
18 | id("") // 默认是 "me.omico.gradm.generated"
19 | }
20 | ```
21 |
22 | 从[入门](./getting-started)复制 `gradm` 文件夹到 `build-logic/gradm`。
23 |
24 | ## 自定义
25 |
26 | 如果你想自定义一些 *.gradle.kts 脚本,你可能想直接使用版本或依赖。
27 |
28 | 假设您已经将一些脚本定义到 "convention" 模块中。
29 |
30 | 您可以通过将以下内容添加到 `convention\build.gradle.kts` 来做到这一点:
31 |
32 | ```kotlin
33 | dependencies {
34 | implementation(gradmGeneratedJar)
35 | }
36 | ```
37 |
38 | 你可以在[build-logic.android.library.gradle.kts](https://github.com/Omico/Gradm/blob/release/examples/gradm-with-composite-build/build-logic/convention/src/main/kotlin/build-logic.android.library.gradle.kts)
39 | 中看到一个实际的例子。
40 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .gradle
3 | .idea
4 | /build
5 | /local.properties
6 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | }
4 |
5 | dependencies {
6 | // DSL is generated by Gradm
7 | compileOnly(okhttp)
8 | compileOnly(okhttp.dnsOverHttps)
9 | compileOnly(okhttp.interceptor.logging)
10 | }
11 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradle.properties:
--------------------------------------------------------------------------------
1 | android.nonTransitiveRClass=true
2 | android.useAndroidX=true
3 |
4 | kotlin.code.style=official
5 |
6 | org.gradle.caching=true
7 | org.gradle.configuration-cache=true
8 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
9 | org.gradle.parallel=true
10 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Omico/Gradm/3048c760b0ad881d8f3ab31f705c87334d29bf36/examples/gradm-getting-started/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradm/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradm/build.gradle.kts:
--------------------------------------------------------------------------------
1 | buildscript {
2 | configurations.all {
3 | resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
4 | }
5 | }
6 |
7 | plugins {
8 | `kotlin-dsl`
9 | id("me.omico.gradm") version "4.0.0-SNAPSHOT"
10 | id("me.omico.gradm.integration.github") version "4.0.0-SNAPSHOT"
11 | }
12 |
13 | repositories {
14 | mavenCentral()
15 | }
16 |
17 | gradm {
18 | pluginId = "gradm" // default: "me.omico.gradm.generated"
19 | configurationFilePath = "gradm3.yml" // default: "gradm.yml"
20 | debug = true // default: false
21 | format {
22 | enabled = true // default: true
23 | indent = 2 // default: 2
24 | }
25 | integrations {
26 | github {
27 | enabled = true // default: true
28 | configurationFilePath = "gradm.integration.github.yml" // default: "gradm.integration.github.yml"
29 | }
30 | }
31 | experimental {
32 | kotlinMultiplatformSupport = false // default: false
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradm/gradm.integration.github.yml:
--------------------------------------------------------------------------------
1 | github:
2 | versions:
3 | - repository: gradle/gradle
4 | # tag is v7.5.0, but actual Gradle version is 7.5
5 | regex: "v([\\d].[\\d](.[1-9])?)"
6 | # the tags published by Gradle on GitHub do not match exactly
7 | # so we need to specify that and let Gradm recognizes it as a partial match
8 | matchType: "partial" # partial or exact, default is exact
9 | - # for final use, versions.llvm
10 | repository: llvm/llvm-project
11 | alias: llvm # default alias is repository name
12 | # regex for GitHub tag, default regex is follow by
13 | # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
14 | regex: llvmorg-([0-9]+.[0-9]+.[0-9]+)
15 | group: 1 # default is 1
16 | - repository: pinterest/ktlint
17 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradm/gradm3.yml:
--------------------------------------------------------------------------------
1 | versions:
2 | android: "7.4.1"
3 | androidx:
4 | activity: "1.7.0"
5 | compose:
6 | bom: "2023.04.00"
7 | compiler: "1.4.0-alpha02"
8 | consensus: "0.3.0"
9 | gradle: "8.2.1"
10 | jetbrains.compose: "1.4.0"
11 | kotlin: "1.8.21"
12 | material: "1.7.0-alpha03"
13 | okhttp: "5.0.0-alpha.10"
14 | omico:
15 | cloudflare: "1.0.0-SNAPSHOT"
16 | cryonics: "1.0.0-SNAPSHOT"
17 | spotless: "6.18.0"
18 |
19 | repositories:
20 | mavenLocal:
21 | omico:
22 | google:
23 | mavenCentral:
24 | jetbrainsCompose:
25 | url: "https://maven.pkg.jetbrains.space/public/p/compose/dev"
26 | sonatypeSnapshots:
27 | url: "https://s01.oss.sonatype.org/content/repositories/snapshots"
28 | gradlePluginPortal:
29 | noUpdates:
30 | customNoUpdates:
31 | noUpdates: true
32 |
33 | plugins:
34 | gradlePluginPortal:
35 | com.diffplug.spotless: ${versions.spotless}
36 | jetbrainsCompose:
37 | org.jetbrains.compose: ${versions.jetbrains.compose}
38 | noUpdates:
39 | com.android.library: ${versions.android}
40 | org.jetbrains.kotlin.android: ${versions.kotlin}
41 | org.jetbrains.kotlin.jvm: ${versions.kotlin}
42 | org.jetbrains.kotlin.multiplatform: ${versions.kotlin}
43 | omico:
44 | me.omico.consensus.api: ${versions.consensus}
45 | me.omico.consensus.git: ${versions.consensus}
46 | me.omico.consensus.publishing: ${versions.consensus}
47 | me.omico.consensus.spotless: ${versions.consensus}
48 |
49 | dependencies:
50 | customNoUpdates:
51 | me.omico.cryonics:
52 | cryonics:
53 | alias: omico.cryonics
54 | version: ${versions.omico.cryonics}
55 | google:
56 | androidx.activity:
57 | activity-compose:
58 | alias: androidx.activity.compose
59 | version: ${versions.androidx.activity}
60 | androidx.compose:
61 | compose-bom:
62 | alias: androidx.compose.bom
63 | version: ${versions.androidx.compose.bom}
64 | bom: true
65 | androidx.compose.material:
66 | material:
67 | alias: androidx.compose.material
68 | noSpecificVersion: true
69 | material-icons-extended:
70 | alias: androidx.compose.material.icons.extended
71 | noSpecificVersion: true
72 | androidx.compose.material3:
73 | material3:
74 | alias: androidx.compose.material3
75 | noSpecificVersion: true
76 | androidx.compose.ui:
77 | ui:
78 | alias: androidx.compose.ui
79 | noSpecificVersion: true
80 | ui-tooling:
81 | alias: androidx.compose.ui.tooling
82 | noSpecificVersion: true
83 | ui-tooling-preview:
84 | alias: androidx.compose.ui.tooling.preview
85 | noSpecificVersion: true
86 | com.google.android.material:
87 | material:
88 | alias: material
89 | version: ${versions.material}
90 | mavenCentral:
91 | com.squareup.okhttp3:
92 | logging-interceptor:
93 | alias: okhttp.interceptor.logging
94 | noSpecificVersion: true
95 | okhttp:
96 | alias: okhttp
97 | noSpecificVersion: true
98 | okhttp-bom:
99 | alias: okhttp.bom
100 | version: ${versions.okhttp}
101 | bom: true
102 | okhttp-dnsoverhttps:
103 | alias: okhttp.dnsOverHttps
104 | noSpecificVersion: true
105 | noUpdates:
106 | me.omico.cloudflare.api:
107 | cloudflare-dns:
108 | alias: omico.cloudflare.dns
109 | version: ${versions.omico.cloudflare}
110 | omico:
111 | me.omico.consensus:
112 | consensus-dsl:
113 | alias: me.omico.consensus.dsl
114 | version: ${versions.consensus}
115 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/gradm/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-getting-started-gradm"
2 |
3 | pluginManagement {
4 | repositories {
5 | mavenLocal()
6 | maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
7 | maven(url = "https://maven.omico.me")
8 | mavenCentral()
9 | gradlePluginPortal()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/gradm-getting-started/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-getting-started"
2 |
3 | pluginManagement {
4 | includeBuild("gradm") // include Gradm here
5 | }
6 |
7 | plugins {
8 | id("com.gradle.develocity") version "3.17.6"
9 | id("gradm") // configured by GradmExtension
10 | }
11 |
12 | develocity {
13 | buildScan {
14 | termsOfUseUrl = "https://gradle.com/terms-of-service"
15 | termsOfUseAgree = "yes"
16 | publishing {
17 | val isOffline = providers.provider { gradle.startParameter.isOffline }
18 | onlyIf { !isOffline.getOrElse(false) }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.gradle
3 | /.idea
4 | /build
5 | /local.properties
6 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/gradm/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/gradm/build.gradle.kts:
--------------------------------------------------------------------------------
1 | buildscript {
2 | configurations.all {
3 | resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
4 | }
5 | }
6 |
7 | plugins {
8 | `kotlin-dsl`
9 | id("me.omico.gradm") version "4.0.0-SNAPSHOT"
10 | }
11 |
12 | repositories {
13 | mavenCentral()
14 | }
15 |
16 | gradm {
17 | pluginId = "gradm-with-composite-build.gradm"
18 | debug = true
19 | }
20 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/gradm/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-with-composite-build-gradm"
2 |
3 | pluginManagement {
4 | repositories {
5 | mavenLocal()
6 | maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
7 | maven(url = "https://maven.omico.me")
8 | mavenCentral()
9 | gradlePluginPortal()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | }
4 |
5 | dependencies {
6 | implementation(com.diffplug.spotless)
7 | implementation(gradmGeneratedJar)
8 | implementation(org.jetbrains.kotlin.android)
9 | implementation(com.android.library)
10 | implementation(me.omico.consensus.api)
11 | implementation(me.omico.consensus.dsl)
12 | implementation(me.omico.consensus.spotless)
13 | }
14 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-with-composite-build-project"
2 |
3 | pluginManagement {
4 | includeBuild("../gradm")
5 | }
6 |
7 | plugins {
8 | id("gradm-with-composite-build.gradm")
9 | }
10 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/src/main/kotlin/gradm-with-composite-build.android.library.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("UnstableApiUsage")
2 |
3 | plugins {
4 | kotlin("android")
5 | id("com.android.library")
6 | id("gradm-with-composite-build.gradm")
7 | }
8 |
9 | android {
10 | compileSdk = 33
11 | namespace = "me.omico.gradm.example"
12 | defaultConfig {
13 | minSdk = 21
14 | }
15 | composeOptions {
16 | // You must add gradmGeneratedJar to dependencies, otherwise you won't be able to use.
17 | kotlinCompilerExtensionVersion = versions.androidx.compose.compiler
18 | }
19 | compileOptions {
20 | sourceCompatibility = JavaVersion.VERSION_11
21 | targetCompatibility = JavaVersion.VERSION_11
22 | }
23 | }
24 |
25 | kotlin {
26 | jvmToolchain(11)
27 | }
28 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/src/main/kotlin/gradm-with-composite-build.root.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.dsl.requireRootProject
2 |
3 | plugins {
4 | id("gradm-with-composite-build.gradm")
5 | id("gradm-with-composite-build.root.spotless")
6 | }
7 |
8 | requireRootProject()
9 |
10 | val wrapper: Wrapper by tasks.named("wrapper") {
11 | gradleVersion = versions.gradle
12 | distributionType = Wrapper.DistributionType.BIN
13 | }
14 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build-logic/project/src/main/kotlin/gradm-with-composite-build.root.spotless.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.consensus.dsl.consensus
2 | import me.omico.consensus.dsl.requireRootProject
3 |
4 | plugins {
5 | id("com.diffplug.spotless")
6 | id("me.omico.consensus.spotless")
7 | }
8 |
9 | requireRootProject()
10 |
11 | consensus {
12 | spotless {
13 | freshmark()
14 | gradleProperties()
15 | kotlin()
16 | kotlinGradle()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("gradm-with-composite-build.root")
3 | }
4 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/example/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/example/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("gradm-with-composite-build.android.library")
3 | }
4 |
5 | dependencies {
6 | // Androidx
7 | compileOnly(androidx.activity.compose)
8 | compileOnly(androidx.compose.material)
9 | compileOnly(androidx.compose.material.icons.extended)
10 | compileOnly(androidx.compose.material3)
11 | compileOnly(androidx.compose.ui)
12 | compileOnly(androidx.compose.ui.tooling)
13 | compileOnly(androidx.compose.ui.tooling.preview)
14 | // Material
15 | compileOnly(material)
16 | // Square
17 | compileOnly(okhttp)
18 | compileOnly(okhttp.dnsOverHttps)
19 | compileOnly(okhttp.interceptor.logging)
20 | }
21 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/example/src/main/kotlin/MainActivity.kt:
--------------------------------------------------------------------------------
1 | import androidx.activity.ComponentActivity
2 |
3 | class MainActivity : ComponentActivity()
4 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/gradle.properties:
--------------------------------------------------------------------------------
1 | android.nonTransitiveRClass=true
2 | android.useAndroidX=true
3 |
4 | kotlin.code.style=official
5 |
6 | org.gradle.caching=true
7 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
8 | org.gradle.parallel=true
9 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Omico/Gradm/3048c760b0ad881d8f3ab31f705c87334d29bf36/examples/gradm-with-composite-build/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/examples/gradm-with-composite-build/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-with-composite-build-root"
2 |
3 | pluginManagement {
4 | repositories {
5 | maven(url = "https://maven.omico.me")
6 | google()
7 | mavenCentral()
8 | gradlePluginPortal()
9 | }
10 | includeBuild("build-logic/gradm")
11 | }
12 |
13 | buildscript {
14 | configurations.all {
15 | resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
16 | }
17 | }
18 |
19 | plugins {
20 | id("com.gradle.develocity") version "3.17.6"
21 | id("gradm-with-composite-build.gradm")
22 | }
23 |
24 | develocity {
25 | buildScan {
26 | termsOfUseUrl = "https://gradle.com/terms-of-service"
27 | termsOfUseAgree = "yes"
28 | publishing {
29 | val isOffline = providers.provider { gradle.startParameter.isOffline }
30 | onlyIf { !isOffline.getOrElse(false) }
31 | }
32 | }
33 | }
34 |
35 | includeBuild("build-logic/project")
36 |
37 | include(":example")
38 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .gradle
3 | .idea
4 | /build
5 | /local.properties
6 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import me.omico.gradm.dependency.Okhttp
2 |
3 | plugins {
4 | kotlin("multiplatform")
5 | }
6 |
7 | kotlin {
8 | jvm()
9 | sourceSets {
10 | commonMain {
11 | dependencies {
12 | // Assume okhttp conflict with other plugins,
13 | // you can directly use me.omico.gradm.dependency.Okhttp instead.
14 | implementation(Okhttp)
15 | }
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradle.properties:
--------------------------------------------------------------------------------
1 | android.useAndroidX=true
2 |
3 | kotlin.code.style=official
4 | kotlin.mpp.androidSourceSetLayoutVersion=2
5 |
6 | org.gradle.caching=true
7 | org.gradle.configuration-cache=true
8 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
9 | org.gradle.parallel=true
10 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Omico/Gradm/3048c760b0ad881d8f3ab31f705c87334d29bf36/examples/gradm-with-kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradm/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradm/build.gradle.kts:
--------------------------------------------------------------------------------
1 | buildscript {
2 | configurations.all {
3 | resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
4 | }
5 | }
6 |
7 | plugins {
8 | `kotlin-dsl`
9 | id("me.omico.gradm") version "4.0.0-SNAPSHOT"
10 | }
11 |
12 | repositories {
13 | mavenCentral()
14 | }
15 |
16 | gradm {
17 | pluginId = "gradm"
18 | debug = true
19 | experimental {
20 | kotlinMultiplatformSupport = true
21 | kotlinMultiplatformIgnoredExtensions = listOf("androidx")
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradm/gradm.yml:
--------------------------------------------------------------------------------
1 | versions:
2 | android: "7.4.1"
3 | androidx:
4 | activity: "1.7.0"
5 | compose:
6 | bom: "2023.04.00"
7 | compiler: "1.4.0-alpha02"
8 | consensus: "0.3.0"
9 | gradle: "8.2.1"
10 | jetbrains.compose: "1.4.0"
11 | kotlin: "1.8.21"
12 | material: "1.7.0-alpha03"
13 | okhttp: "5.0.0-alpha.10"
14 | omico:
15 | cloudflare: "1.0.0-SNAPSHOT"
16 | cryonics: "1.0.0-SNAPSHOT"
17 | spotless: "6.18.0"
18 |
19 | repositories:
20 | mavenLocal:
21 | omico:
22 | google:
23 | mavenCentral:
24 | jetbrainsCompose:
25 | url: "https://maven.pkg.jetbrains.space/public/p/compose/dev"
26 | sonatypeSnapshots:
27 | url: "https://s01.oss.sonatype.org/content/repositories/snapshots"
28 | gradlePluginPortal:
29 | noUpdates:
30 | customNoUpdates:
31 | noUpdates: true
32 |
33 | plugins:
34 | gradlePluginPortal:
35 | com.diffplug.spotless: ${versions.spotless}
36 | jetbrainsCompose:
37 | org.jetbrains.compose: ${versions.jetbrains.compose}
38 | noUpdates:
39 | com.android.library: ${versions.android}
40 | org.jetbrains.kotlin.android: ${versions.kotlin}
41 | org.jetbrains.kotlin.jvm: ${versions.kotlin}
42 | org.jetbrains.kotlin.multiplatform: ${versions.kotlin}
43 | omico:
44 | me.omico.consensus.api: ${versions.consensus}
45 | me.omico.consensus.git: ${versions.consensus}
46 | me.omico.consensus.publishing: ${versions.consensus}
47 | me.omico.consensus.spotless: ${versions.consensus}
48 |
49 | dependencies:
50 | customNoUpdates:
51 | me.omico.cryonics:
52 | cryonics:
53 | alias: omico.cryonics
54 | version: ${versions.omico.cryonics}
55 | google:
56 | androidx.activity:
57 | activity-compose:
58 | alias: androidx.activity.compose
59 | version: ${versions.androidx.activity}
60 | androidx.compose:
61 | compose-bom:
62 | alias: androidx.compose.bom
63 | version: ${versions.androidx.compose.bom}
64 | bom: true
65 | androidx.compose.material:
66 | material:
67 | alias: androidx.compose.material
68 | noSpecificVersion: true
69 | material-icons-extended:
70 | alias: androidx.compose.material.icons.extended
71 | noSpecificVersion: true
72 | androidx.compose.material3:
73 | material3:
74 | alias: androidx.compose.material3
75 | noSpecificVersion: true
76 | androidx.compose.ui:
77 | ui:
78 | alias: androidx.compose.ui
79 | noSpecificVersion: true
80 | ui-tooling:
81 | alias: androidx.compose.ui.tooling
82 | noSpecificVersion: true
83 | ui-tooling-preview:
84 | alias: androidx.compose.ui.tooling.preview
85 | noSpecificVersion: true
86 | com.google.android.material:
87 | material:
88 | alias: material
89 | version: ${versions.material}
90 | mavenCentral:
91 | com.squareup.okhttp3:
92 | logging-interceptor:
93 | alias: okhttp.interceptor.logging
94 | noSpecificVersion: true
95 | okhttp:
96 | alias: okhttp
97 | noSpecificVersion: true
98 | okhttp-bom:
99 | alias: okhttp.bom
100 | version: ${versions.okhttp}
101 | bom: true
102 | okhttp-dnsoverhttps:
103 | alias: okhttp.dnsOverHttps
104 | noSpecificVersion: true
105 | noUpdates:
106 | me.omico.cloudflare.api:
107 | cloudflare-dns:
108 | alias: omico.cloudflare.dns
109 | version: ${versions.omico.cloudflare}
110 | omico:
111 | me.omico.consensus:
112 | consensus-dsl:
113 | alias: me.omico.consensus.dsl
114 | version: ${versions.consensus}
115 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/gradm/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-with-kotlin-multiplatform-gradm"
2 |
3 | pluginManagement {
4 | repositories {
5 | mavenLocal()
6 | maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
7 | maven(url = "https://maven.omico.me")
8 | mavenCentral()
9 | gradlePluginPortal()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/gradm-with-kotlin-multiplatform/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("UnstableApiUsage")
2 |
3 | rootProject.name = "gradm-with-kotlin-multiplatform"
4 |
5 | pluginManagement {
6 | includeBuild("gradm")
7 | }
8 |
9 | plugins {
10 | id("com.gradle.develocity") version "3.17.6"
11 | id("gradm")
12 | }
13 |
14 | develocity {
15 | buildScan {
16 | termsOfUseUrl = "https://gradle.com/terms-of-service"
17 | termsOfUseAgree = "yes"
18 | publishing {
19 | val isOffline = providers.provider { gradle.startParameter.isOffline }
20 | onlyIf { !isOffline.getOrElse(false) }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/template/gradm.yml:
--------------------------------------------------------------------------------
1 | versions:
2 | android: "7.4.1"
3 | androidx:
4 | activity: "1.7.0"
5 | compose:
6 | bom: "2023.04.00"
7 | compiler: "1.4.0-alpha02"
8 | consensus: "0.3.0"
9 | gradle: "8.2.1"
10 | jetbrains.compose: "1.4.0"
11 | kotlin: "1.8.21"
12 | material: "1.7.0-alpha03"
13 | okhttp: "5.0.0-alpha.10"
14 | omico:
15 | cloudflare: "1.0.0-SNAPSHOT"
16 | cryonics: "1.0.0-SNAPSHOT"
17 | spotless: "6.18.0"
18 |
19 | repositories:
20 | mavenLocal:
21 | omico:
22 | google:
23 | mavenCentral:
24 | jetbrainsCompose:
25 | url: "https://maven.pkg.jetbrains.space/public/p/compose/dev"
26 | sonatypeSnapshots:
27 | url: "https://s01.oss.sonatype.org/content/repositories/snapshots"
28 | gradlePluginPortal:
29 | noUpdates:
30 | customNoUpdates:
31 | noUpdates: true
32 |
33 | plugins:
34 | gradlePluginPortal:
35 | com.diffplug.spotless: ${versions.spotless}
36 | jetbrainsCompose:
37 | org.jetbrains.compose: ${versions.jetbrains.compose}
38 | noUpdates:
39 | com.android.library: ${versions.android}
40 | org.jetbrains.kotlin.android: ${versions.kotlin}
41 | org.jetbrains.kotlin.jvm: ${versions.kotlin}
42 | org.jetbrains.kotlin.multiplatform: ${versions.kotlin}
43 | omico:
44 | me.omico.consensus.api: ${versions.consensus}
45 | me.omico.consensus.git: ${versions.consensus}
46 | me.omico.consensus.publishing: ${versions.consensus}
47 | me.omico.consensus.spotless: ${versions.consensus}
48 |
49 | dependencies:
50 | customNoUpdates:
51 | me.omico.cryonics:
52 | cryonics:
53 | alias: omico.cryonics
54 | version: ${versions.omico.cryonics}
55 | google:
56 | androidx.activity:
57 | activity-compose:
58 | alias: androidx.activity.compose
59 | version: ${versions.androidx.activity}
60 | androidx.compose:
61 | compose-bom:
62 | alias: androidx.compose.bom
63 | version: ${versions.androidx.compose.bom}
64 | bom: true
65 | androidx.compose.material:
66 | material:
67 | alias: androidx.compose.material
68 | noSpecificVersion: true
69 | material-icons-extended:
70 | alias: androidx.compose.material.icons.extended
71 | noSpecificVersion: true
72 | androidx.compose.material3:
73 | material3:
74 | alias: androidx.compose.material3
75 | noSpecificVersion: true
76 | androidx.compose.ui:
77 | ui:
78 | alias: androidx.compose.ui
79 | noSpecificVersion: true
80 | ui-tooling:
81 | alias: androidx.compose.ui.tooling
82 | noSpecificVersion: true
83 | ui-tooling-preview:
84 | alias: androidx.compose.ui.tooling.preview
85 | noSpecificVersion: true
86 | com.google.android.material:
87 | material:
88 | alias: material
89 | version: ${versions.material}
90 | mavenCentral:
91 | com.squareup.okhttp3:
92 | logging-interceptor:
93 | alias: okhttp.interceptor.logging
94 | noSpecificVersion: true
95 | okhttp:
96 | alias: okhttp
97 | noSpecificVersion: true
98 | okhttp-bom:
99 | alias: okhttp.bom
100 | version: ${versions.okhttp}
101 | bom: true
102 | okhttp-dnsoverhttps:
103 | alias: okhttp.dnsOverHttps
104 | noSpecificVersion: true
105 | noUpdates:
106 | me.omico.cloudflare.api:
107 | cloudflare-dns:
108 | alias: omico.cloudflare.dns
109 | version: ${versions.omico.cloudflare}
110 | omico:
111 | me.omico.consensus:
112 | consensus-dsl:
113 | alias: me.omico.consensus.dsl
114 | version: ${versions.consensus}
115 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin.code.style=official
2 |
3 | org.gradle.caching=true
4 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
5 | org.gradle.kotlin.dsl.allWarningsAsErrors=true
6 | org.gradle.parallel=true
7 |
8 | project.group=me.omico.gradm
9 | project.version=4.0.0-SNAPSHOT
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Omico/Gradm/3048c760b0ad881d8f3ab31f705c87334d29bf36/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/gradm-api/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /build
3 | /gradle.properties
4 | /local.properties
5 |
--------------------------------------------------------------------------------
/gradm-api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("gradm.root")
3 | }
4 |
--------------------------------------------------------------------------------
/gradm-api/datastore/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/gradm-api/datastore/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | kotlin("plugin.serialization")
4 | id("gradm.publishing")
5 | }
6 |
7 | kotlin {
8 | jvmToolchain(11)
9 | sourceSets {
10 | all {
11 | languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
12 | }
13 | }
14 | }
15 |
16 | dependencies {
17 | implementation(libs.kotlinx.serialization.protobuf)
18 | }
19 |
20 | dependencies {
21 | testImplementation(projects.gradmApiTest)
22 | }
23 |
24 | tasks {
25 | jar {
26 | dependsOn(test)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/gradm-api/datastore/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm datastore API
2 | POM_NAME=Gradm datastore API
3 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/GradmLocalConfiguration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore
17 |
18 | import kotlinx.serialization.Serializable
19 | import kotlinx.serialization.protobuf.ProtoNumber
20 |
21 | @Serializable
22 | data class GradmLocalConfiguration(
23 | @ProtoNumber(1) val configurationPaths: Set = setOf(),
24 | )
25 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/GradmLocalConfigurationScope.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore
17 |
18 | interface GradmLocalConfigurationScope {
19 | fun insertConfigurationPath(path: String)
20 | fun insertConfigurationPaths(paths: Set)
21 | }
22 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/GradmMetadata.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore
17 |
18 | import kotlinx.serialization.Serializable
19 | import kotlinx.serialization.protobuf.ProtoNumber
20 | import me.omico.gradm.datastore.maven.MavenMetadata
21 |
22 | @Serializable
23 | data class GradmMetadata(
24 | @ProtoNumber(1) val timestamp: Long = System.currentTimeMillis(),
25 | @ProtoNumber(2) val maven: List = listOf(),
26 | )
27 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/GradmMetadataScope.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore
17 |
18 | import me.omico.gradm.datastore.maven.MavenMetadata
19 |
20 | interface GradmMetadataScope {
21 | fun insert(metadata: MavenMetadata)
22 | fun insert(metadata: List)
23 | }
24 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/internal/GradmLocalConfigurationUpdater.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore.internal
17 |
18 | import me.omico.gradm.datastore.GradmDataStore
19 | import me.omico.gradm.datastore.GradmLocalConfigurationScope
20 | import java.nio.file.Path
21 | import kotlin.io.path.Path
22 | import kotlin.io.path.absolutePathString
23 | import kotlin.io.path.exists
24 |
25 | internal class GradmLocalConfigurationUpdater : GradmLocalConfigurationScope {
26 | private val configurationPaths = mutableSetOf()
27 |
28 | override fun insertConfigurationPath(path: String) {
29 | configurationPaths += path
30 | }
31 |
32 | override fun insertConfigurationPaths(paths: Set) {
33 | configurationPaths += paths
34 | }
35 |
36 | fun update() {
37 | if (configurationPaths.isEmpty()) return
38 | val newConfigurationPaths = configurationPaths
39 | .apply { addAll(GradmDataStore.localConfiguration.configurationPaths) }
40 | .map(::Path)
41 | .filter(Path::exists)
42 | .map(Path::absolutePathString)
43 | .toSet()
44 | GradmDataStore.localConfiguration.copy(
45 | configurationPaths = newConfigurationPaths,
46 | ).let(GradmDataStore::updateLocalConfiguration)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/internal/GradmMetadataUpdater.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore.internal
17 |
18 | import me.omico.gradm.datastore.GradmDataStore
19 | import me.omico.gradm.datastore.GradmMetadataScope
20 | import me.omico.gradm.datastore.maven.MavenMetadata
21 |
22 | internal class GradmMetadataUpdater : GradmMetadataScope {
23 | private val newMavenMetadataList = mutableListOf()
24 |
25 | override fun insert(metadata: MavenMetadata) {
26 | newMavenMetadataList.add(metadata)
27 | }
28 |
29 | override fun insert(metadata: List) {
30 | newMavenMetadataList.addAll(metadata)
31 | }
32 |
33 | fun update() {
34 | if (newMavenMetadataList.isEmpty()) return
35 | val mavenUris = newMavenMetadataList.map(MavenMetadata::uri)
36 | GradmDataStore.metadata.maven.filterNot { it.uri in mavenUris }.let { oldMavenMetadataList ->
37 | GradmDataStore.metadata.copy(
38 | timestamp = System.currentTimeMillis(),
39 | maven = oldMavenMetadataList + newMavenMetadataList,
40 | ).let(GradmDataStore::updateMetadata)
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/main/kotlin/me/omico/gradm/datastore/maven/MavenMetadata.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore.maven
17 |
18 | import kotlinx.serialization.Serializable
19 | import kotlinx.serialization.protobuf.ProtoNumber
20 |
21 | @Serializable
22 | data class MavenMetadata(
23 | @ProtoNumber(1) val uri: String,
24 | @ProtoNumber(2) val repository: String,
25 | @ProtoNumber(3) val groupId: String,
26 | @ProtoNumber(4) val artifactId: String,
27 | @ProtoNumber(5) val latestVersion: String,
28 | @ProtoNumber(6) val versions: List,
29 | @ProtoNumber(7) val lastUpdated: Long,
30 | )
31 |
32 | inline val MavenMetadata.module: String
33 | get() = "$groupId:$artifactId"
34 |
--------------------------------------------------------------------------------
/gradm-api/datastore/src/test/kotlin/me/omico/gradm/datastore/GradmDataStoreTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.datastore
17 |
18 | import me.omico.gradm.datastore.maven.MavenMetadata
19 | import me.omico.gradm.test.resources
20 | import org.junit.jupiter.api.Test
21 | import org.junit.jupiter.api.assertDoesNotThrow
22 | import org.junit.jupiter.api.io.TempDir
23 | import java.nio.file.Path
24 |
25 | class GradmDataStoreTest {
26 | @Test
27 | fun `test load`(@TempDir tempDir: Path) {
28 | assertDoesNotThrow {
29 | GradmDataStore.load(
30 | localConfigurationFile = tempDir.resolve(".gradm"),
31 | metadataFile = tempDir.resolve(".metadata"),
32 | )
33 | }
34 | }
35 |
36 | @Test
37 | fun `test save`(@TempDir tempDir: Path) {
38 | `test load`(tempDir)
39 | val testConfigurationPath = resources("gradm.formatted.yml").toString()
40 | assertDoesNotThrow {
41 | GradmDataStore.updateLocalConfiguration {
42 | insertConfigurationPath(testConfigurationPath)
43 | }
44 | }
45 | assert(GradmDataStore.localConfiguration.configurationPaths == setOf(testConfigurationPath))
46 | val testMavenMetadata = MavenMetadata(
47 | uri = "test",
48 | repository = "test",
49 | groupId = "test",
50 | artifactId = "test",
51 | latestVersion = "1.0.0",
52 | versions = listOf("1.0.0"),
53 | lastUpdated = 5000,
54 | )
55 | assertDoesNotThrow {
56 | GradmDataStore.updateMetadata {
57 | insert(testMavenMetadata)
58 | }
59 | }
60 | assert(GradmDataStore.metadata.maven.first() == testMavenMetadata)
61 | `test load`(tempDir)
62 | assert(GradmDataStore.metadata.maven.first() == testMavenMetadata)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/gradm-api/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-api"
2 |
3 | pluginManagement {
4 | includeBuild("../build-logic/initialization")
5 | }
6 |
7 | plugins {
8 | id("gradm.api")
9 | }
10 |
--------------------------------------------------------------------------------
/gradm-api/test/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/gradm-api/test/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | }
4 |
5 | kotlin {
6 | jvmToolchain(11)
7 | }
8 |
9 | dependencies {
10 | api(platform(libs.junit.bom))
11 | api(libs.junit.jupiter)
12 | }
13 |
--------------------------------------------------------------------------------
/gradm-api/test/src/main/kotlin/me/omico/gradm/test/Test.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.test
17 |
18 | import java.nio.file.Path
19 | import kotlin.io.path.toPath
20 |
21 | inline fun T.resources(path: String): Path =
22 | T::class.java.classLoader.getResource(path)!!.toURI().toPath()
23 |
--------------------------------------------------------------------------------
/gradm-codegen/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-codegen/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | id("gradm.publishing")
4 | }
5 |
6 | kotlin {
7 | jvmToolchain(11)
8 | }
9 |
10 | dependencies {
11 | compileOnly(gradleApi())
12 | compileOnly(projects.gradmRuntime)
13 | compileOnly(projects.gradmIntegration.gradmIntegrationRuntime)
14 | implementation(libs.elucidator)
15 | implementation(libs.kotlinpoet)
16 | }
17 |
--------------------------------------------------------------------------------
/gradm-codegen/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm codegen
2 | POM_NAME=Gradm codegen
3 |
--------------------------------------------------------------------------------
/gradm-codegen/src/main/kotlin/me/omico/gradm/internal/codegen/Repositories.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.codegen
17 |
18 | import com.squareup.kotlinpoet.MemberName
19 | import me.omico.elucidator.FunctionScope
20 | import me.omico.elucidator.KtFileScope
21 | import me.omico.elucidator.addFunction
22 | import me.omico.elucidator.addStatement
23 | import me.omico.elucidator.ktFile
24 | import me.omico.elucidator.receiver
25 | import me.omico.elucidator.returnStatement
26 | import me.omico.elucidator.writeTo
27 | import me.omico.gradm.GRADM_PACKAGE_NAME
28 | import me.omico.gradm.internal.YamlDocument
29 | import me.omico.gradm.internal.config.gradleBuildInRepositories
30 | import me.omico.gradm.internal.config.repositories
31 | import org.gradle.api.Project
32 | import org.gradle.api.artifacts.dsl.RepositoryHandler
33 | import org.gradle.api.initialization.Settings
34 |
35 | internal fun CodeGenerator.generateRepositoriesSourceFile() {
36 | ktFile(GRADM_PACKAGE_NAME, "Repositories") {
37 | addSuppressWarningTypes()
38 | addGradmComment()
39 | addAddDeclaredRepositoriesForRepositoryHandlerScope(gradmConfigurationDocument)
40 | addAddDeclaredRepositoriesForSettingsScope()
41 | addAddDeclaredRepositoriesForProjectScope()
42 | writeTo(generatedSourcesDirectory)
43 | }
44 | }
45 |
46 | internal fun KtFileScope.addAddDeclaredRepositoriesForRepositoryHandlerScope(document: YamlDocument): Unit =
47 | addDeclaredRepositoryStatements {
48 | addDeclaredRepositoryStatements(document)
49 | }
50 |
51 | private fun KtFileScope.addAddDeclaredRepositoriesForSettingsScope(): Unit =
52 | addDeclaredRepositoryStatements {
53 | returnStatement("pluginManagement.repositories.addDeclaredRepositories()")
54 | }
55 |
56 | private fun KtFileScope.addAddDeclaredRepositoriesForProjectScope(): Unit =
57 | addDeclaredRepositoryStatements {
58 | returnStatement("repositories.addDeclaredRepositories()")
59 | }
60 |
61 | private fun FunctionScope.addDeclaredRepositoryStatements(document: YamlDocument): Unit =
62 | document.repositories.forEach { repository ->
63 | when {
64 | repository in gradleBuildInRepositories -> addStatement("${repository.id}()")
65 | !repository.noUpdates -> addStatement("%M(url = %S)", mavenMemberName, repository.url)
66 | }
67 | }
68 |
69 | private inline fun KtFileScope.addDeclaredRepositoryStatements(crossinline block: FunctionScope.() -> Unit): Unit =
70 | addFunction("addDeclaredRepositories") {
71 | receiver()
72 | block()
73 | }
74 |
75 | private val mavenMemberName: MemberName = MemberName("org.gradle.kotlin.dsl", "maven")
76 |
--------------------------------------------------------------------------------
/gradm-codegen/src/main/kotlin/me/omico/gradm/internal/codegen/Self.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.codegen
17 |
18 | import me.omico.elucidator.addProperty
19 | import me.omico.elucidator.getter
20 | import me.omico.elucidator.ktFile
21 | import me.omico.elucidator.receiver
22 | import me.omico.elucidator.writeTo
23 | import me.omico.gradm.path.generatedJar
24 | import org.gradle.api.Project
25 | import org.gradle.api.file.ConfigurableFileCollection
26 | import kotlin.io.path.invariantSeparatorsPathString
27 |
28 | internal fun CodeGenerator.generateSelfSourceFile() {
29 | ktFile(fileName = "Self") {
30 | addSuppressWarningTypes()
31 | addGradmComment()
32 | addProperty("gradmGeneratedJar") {
33 | receiver()
34 | getter("files(\"${gradmProjectPaths.generatedJar.invariantSeparatorsPathString}\")")
35 | }
36 | writeTo(generatedSourcesDirectory)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-gradle-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | id("gradm.publishing")
4 | }
5 |
6 | kotlin {
7 | jvmToolchain(11)
8 | }
9 |
10 | gradlePlugin {
11 | plugins {
12 | register("gradm") {
13 | id = "me.omico.gradm"
14 | implementationClass = "me.omico.gradm.GradmPlugin"
15 | }
16 | }
17 | }
18 |
19 | dependencies {
20 | implementation(projects.gradmCodegen)
21 | implementation(projects.gradmIntegration.gradmIntegrationRuntime)
22 | implementation(projects.gradmRuntime)
23 | }
24 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradle plugin for Gradm.
2 | POM_NAME=Gradm Gradle Plugin
3 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/GradmExperimentalExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | interface GradmExperimentalExtension {
19 | /**
20 | * Enable experimental Kotlin Multiplatform support for Gradm.
21 | *
22 | * The default value is `false`.
23 | */
24 | var kotlinMultiplatformSupport: Boolean
25 |
26 | /**
27 | * Ignore register the specified extensions when using experimental Kotlin Multiplatform support for Gradm.
28 | *
29 | * The default value is `emptyList()`.
30 | */
31 | var kotlinMultiplatformIgnoredExtensions: List
32 | }
33 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/GradmFormatExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | interface GradmFormatExtension {
19 |
20 | /**
21 | * Enable or disable format for Gradm.
22 | *
23 | * The default value is `2`.
24 | */
25 | var enabled: Boolean
26 |
27 | /**
28 | * Format indent for Gradm config file.
29 | *
30 | * The default value is `2`.
31 | */
32 | var indent: Int
33 | }
34 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/internal/GradmExperimentalExtensionImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal
17 |
18 | import me.omico.gradm.GradmExperimentalConfiguration
19 | import me.omico.gradm.GradmExperimentalExtension
20 |
21 | internal abstract class GradmExperimentalExtensionImpl : GradmExperimentalExtension {
22 | override var kotlinMultiplatformSupport: Boolean by GradmExperimentalConfiguration::kotlinMultiplatformSupport
23 | override var kotlinMultiplatformIgnoredExtensions: List by GradmExperimentalConfiguration::kotlinMultiplatformIgnoredExtensions
24 | }
25 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/internal/GradmExtensionImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal
17 |
18 | import me.omico.gradm.GradmConfiguration
19 | import me.omico.gradm.GradmExtension
20 | import me.omico.gradm.GradmGeneratedPluginType
21 | import me.omico.gradm.createGradmGeneratedPluginDeclaration
22 | import org.gradle.api.Project
23 | import org.gradle.kotlin.dsl.getByType
24 | import org.gradle.plugin.devel.GradlePluginDevelopmentExtension
25 | import org.gradle.plugin.devel.PluginDeclaration
26 | import javax.inject.Inject
27 |
28 | internal abstract class GradmExtensionImpl @Inject constructor(
29 | private val project: Project,
30 | ) : GradmExtension {
31 | private val pluginDevelopmentExtension: GradlePluginDevelopmentExtension = project.extensions.getByType()
32 |
33 | private val pluginDeclaration: PluginDeclaration =
34 | pluginDevelopmentExtension.createGradmGeneratedPluginDeclaration(GradmGeneratedPluginType.General)
35 |
36 | override val projectName: String
37 | get() = project.name
38 |
39 | override var pluginId: String by pluginDeclaration::id
40 |
41 | override var configurationFilePath: String = "gradm.yml"
42 | set(value) {
43 | val file = project.file(value)
44 | require(file.exists()) { "Gradm configuration file does not exist in ${file.absolutePath}." }
45 | require(file.isFile) { "Gradm configuration file must be a file." }
46 | field = value
47 | }
48 |
49 | override var debug: Boolean by GradmConfiguration::debug
50 | }
51 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/internal/GradmFormatExtensionImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal
17 |
18 | import me.omico.gradm.GradmFormatConfiguration
19 | import me.omico.gradm.GradmFormatExtension
20 |
21 | internal abstract class GradmFormatExtensionImpl : GradmFormatExtension {
22 | override var enabled: Boolean by GradmFormatConfiguration::enabled
23 | override var indent: Int by GradmFormatConfiguration::indent
24 | }
25 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/task/GradmDependenciesTask.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.task
17 |
18 | import me.omico.gradm.GradmExtension
19 | import me.omico.gradm.service.GradmWorkerService
20 | import org.gradle.api.Project
21 | import org.gradle.api.artifacts.dsl.DependencyHandler
22 | import org.gradle.api.provider.Provider
23 | import javax.inject.Inject
24 |
25 | abstract class GradmDependenciesTask : GradmTask() {
26 | @get:Inject
27 | abstract val dependencies: DependencyHandler
28 |
29 | init {
30 | notCompatibleWithConfigurationCache()
31 | }
32 |
33 | override fun execute() {
34 | super.execute()
35 | workerService.update(
36 | dependencies = dependencies,
37 | )
38 | }
39 |
40 | internal fun Project.setupGradmDependenciesTask(
41 | gradmExtension: GradmExtension,
42 | gradmWorkerServiceProvider: Provider,
43 | ) {
44 | dependsOn(GradmInitialization.TASK_NAME)
45 | setupGradmTask(gradmExtension, gradmWorkerServiceProvider)
46 | }
47 |
48 | private fun notCompatibleWithConfigurationCache() =
49 | notCompatibleWithConfigurationCache(
50 | "[Gradm] This task is not compatible with the Gradle configuration cache.\n" +
51 | "Waiting for https://github.com/gradle/gradle/issues/13506 to be fixed.",
52 | )
53 | }
54 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/task/GradmDependencyUpdates.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.task
17 |
18 | import org.gradle.api.file.RegularFileProperty
19 | import org.gradle.api.tasks.OutputFile
20 | import org.gradle.api.tasks.UntrackedTask
21 |
22 | @UntrackedTask(because = "Gradm dependency updates.")
23 | abstract class GradmDependencyUpdates : GradmDependenciesTask() {
24 | @get:OutputFile
25 | abstract val availableUpdatesFileProperty: RegularFileProperty
26 |
27 | override fun execute() {
28 | super.execute()
29 | workerService.refresh()
30 | }
31 |
32 | companion object {
33 | const val TASK_NAME = "gradmDependencyUpdates"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/task/GradmInitialization.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.task
17 |
18 | import org.gradle.api.artifacts.dsl.RepositoryHandler
19 | import org.gradle.api.tasks.UntrackedTask
20 | import javax.inject.Inject
21 |
22 | @UntrackedTask(because = "Initialize Gradm.")
23 | abstract class GradmInitialization : GradmTask() {
24 | @get:Inject
25 | abstract val repositories: RepositoryHandler
26 |
27 | override fun execute() {
28 | super.execute()
29 | workerService.initialize(
30 | repositories = repositories,
31 | gradmProjectPaths = gradmProjectPaths,
32 | )
33 | }
34 |
35 | companion object {
36 | const val TASK_NAME = "initializeGradm"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/gradm-gradle-plugin/src/main/kotlin/me/omico/gradm/task/GradmSourcesGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.task
17 |
18 | import org.gradle.api.file.ConfigurableFileCollection
19 | import org.gradle.api.file.DirectoryProperty
20 | import org.gradle.api.tasks.CacheableTask
21 | import org.gradle.api.tasks.InputFiles
22 | import org.gradle.api.tasks.OutputDirectory
23 | import org.gradle.api.tasks.PathSensitive
24 | import org.gradle.api.tasks.PathSensitivity
25 |
26 | @CacheableTask
27 | abstract class GradmSourcesGenerator : GradmDependenciesTask() {
28 | @get:[
29 | InputFiles
30 | PathSensitive(PathSensitivity.ABSOLUTE)
31 | ]
32 | abstract val inputFiles: ConfigurableFileCollection
33 |
34 | @get:OutputDirectory
35 | abstract val gradmGeneratedSourcesDirectoryProperty: DirectoryProperty
36 |
37 | override fun execute() {
38 | super.execute()
39 | workerService.generate(
40 | outputDirectory = gradmGeneratedSourcesDirectoryProperty.asFile.get().toPath(),
41 | )
42 | }
43 |
44 | companion object {
45 | const val TASK_NAME = "generateGradmSources"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/gradm-integration/api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-integration/api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | id("gradm.publishing")
4 | }
5 |
6 | kotlin {
7 | jvmToolchain(11)
8 | }
9 |
10 | dependencies {
11 | api(projects.gradmRuntime)
12 | }
13 |
--------------------------------------------------------------------------------
/gradm-integration/api/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm integration API.
2 | POM_NAME=Gradm integration API
3 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | interface GradmIntegration {
19 | /**
20 | * The id of this integration.
21 | */
22 | val id: String
23 |
24 | /**
25 | * This function will be called execute `generateGradmSources` task.
26 | */
27 | fun GradmIntegrationHolder.onGenerate(): Unit = Unit
28 |
29 | /**
30 | * This function will be called execute `gradmDependencyUpdates` task.
31 | */
32 | fun GradmIntegrationHolder.onRefresh(): Unit = Unit
33 | }
34 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | /**
19 | * The extension that holds all integrations.
20 | *
21 | * Recommend not implementing this interface directly.
22 | * @see [GradmIntegrationExtensionImpl]
23 | */
24 | interface GradmIntegrationExtension {
25 | /**
26 | * The id of this integration.
27 | */
28 | val id: String
29 |
30 | /**
31 | * The attributes of this integration.
32 | */
33 | val attributes: Map
34 |
35 | /**
36 | * Whether this integration is enabled.
37 | */
38 | var enabled: Boolean
39 |
40 | /**
41 | * The path of the configuration file for this integration.
42 | */
43 | var configurationFilePath: String
44 | }
45 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationExtensionImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | /**
19 | * The implementation of [GradmIntegrationExtension].
20 | *
21 | * Recommend implementing this class instead of [GradmIntegrationExtension].
22 | */
23 | abstract class GradmIntegrationExtensionImpl(
24 | /**
25 | * The id of this integration.
26 | */
27 | override val id: String,
28 | ) : GradmIntegrationExtension {
29 | /**
30 | * The attributes of this integration.
31 | */
32 | final override val attributes: MutableMap = mutableMapOf()
33 |
34 | /**
35 | * Whether this integration is enabled.
36 | *
37 | * Defaults to `true`.
38 | */
39 | override var enabled: Boolean by attributes.withDefault { true }
40 |
41 | /**
42 | * The path of the configuration file for this integration.
43 | *
44 | * Defaults to `gradm.integration..yml`.
45 | */
46 | override var configurationFilePath: String by attributes.withDefault { "gradm.integration.$id.yml" }
47 | }
48 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationHolder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | import me.omico.gradm.internal.YamlDocument
19 | import me.omico.gradm.internal.config.MutableFlatVersions
20 | import me.omico.gradm.path.GradmProjectPaths
21 | import java.nio.file.Path
22 |
23 | interface GradmIntegrationHolder {
24 | /**
25 | * The id of this integration.
26 | */
27 | val id: String
28 |
29 | /**
30 | * The attributes of this integration.
31 | */
32 | val attributes: Map
33 |
34 | /**
35 | * Resolved configuration of this integration.
36 | */
37 | val integrationConfiguration: YamlDocument
38 |
39 | /**
40 | * Resolved instance of GradmProjectPaths.
41 | */
42 | val gradmProjectPaths: GradmProjectPaths
43 |
44 | /**
45 | * The versions that will be used for dependencies.
46 | * This is a mutable object, so it can be modified by the integration.
47 | * Which also means integrations are applied sequentially.
48 | */
49 | val versions: MutableFlatVersions
50 |
51 | /**
52 | * Get input file/directory that is registered by [GradmIntegrationOwner.registerInput].
53 | */
54 | fun input(path: String): Path
55 |
56 | /**
57 | * Get output file that is registered by [GradmIntegrationOwner.registerOutput].
58 | */
59 | fun outputFile(path: String): Path
60 |
61 | /**
62 | * Get output directory that is registered by [GradmIntegrationOwner.registerOutput].
63 | */
64 | fun outputDirectory(path: String): Path
65 | }
66 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationOwner.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | import java.nio.file.Path
19 |
20 | interface GradmIntegrationOwner {
21 | /**
22 | * Register a [GradmIntegration] to this owner.
23 | * @param integration the integration to register
24 | * @param extension the extension of the integration
25 | * @throws IllegalArgumentException if the integration is already registered
26 | *
27 | * Internal use only. Do not call this method directly.
28 | * Use [GradmProjectWithIntegration.registerExtension] instead.
29 | */
30 | fun register(integration: GradmIntegration, extension: GradmIntegrationExtension)
31 |
32 | /**
33 | * Register an input path to this owner.
34 | * @param id the id of the input path
35 | * @param path the input path to register
36 | *
37 | * Internal use only. Do not call this method directly.
38 | * Use [GradmProjectWithIntegration.registerInput] instead.
39 | */
40 | fun registerInput(id: String, path: Path)
41 |
42 | /**
43 | * Register an output path to this owner.
44 | * @param id the id of the output path
45 | * @param path the output path to register
46 | *
47 | * Internal use only. Do not call this method directly.
48 | * Use [GradmProjectWithIntegration.registerOutput] instead.
49 | */
50 | fun registerOutput(id: String, path: Path)
51 | }
52 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationPlugin.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | import me.omico.gradm.GRADM_PLUGIN_ID
19 | import me.omico.gradm.integration.internal.GradmProjectWithIntegrationImpl
20 | import org.gradle.api.Plugin
21 | import org.gradle.api.Project
22 |
23 | abstract class GradmIntegrationPlugin : Plugin, GradmIntegration {
24 | /**
25 | * This method is called when the plugin is applied.
26 | * @see [Plugin.apply]
27 | */
28 | open fun GradmProjectWithIntegration.onApply() {}
29 |
30 | final override fun apply(target: Project): Unit =
31 | target.plugins.withId(GRADM_PLUGIN_ID) {
32 | GradmProjectWithIntegrationImpl(plugin = this, project = target).onApply()
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmIntegrationsExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | import org.gradle.api.plugins.ExtensionAware
19 |
20 | /**
21 | * The extension that holds all integrations.
22 | *
23 | * Do not implement this interface directly.
24 | */
25 | interface GradmIntegrationsExtension : ExtensionAware
26 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/GradmProjectWithIntegration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration
17 |
18 | import me.omico.gradm.GradmExtension
19 | import org.gradle.api.Project
20 | import kotlin.reflect.KClass
21 |
22 | interface GradmProjectWithIntegration : Project {
23 | /**
24 | * The [GradmExtension] of this project.
25 | */
26 | val gradmExtension: GradmExtension
27 |
28 | /**
29 | * The [GradmIntegrationsExtension] of this project.
30 | */
31 | val gradmIntegrationsExtension: GradmIntegrationsExtension
32 |
33 | /**
34 | * Create an extension for this integration.
35 | * @param extension The extension class.
36 | * @param extensionImpl The extension implementation class.
37 | * @return The [extension] instance.
38 | */
39 | fun createExtension(
40 | extension: KClass,
41 | extensionImpl: KClass,
42 | ): Extension
43 |
44 | /**
45 | * Register an extension for this integration.
46 | * @param extension The extension instance.
47 | */
48 | fun registerExtension(extension: Extension)
49 |
50 | /**
51 | * Register an input file/directory for this integration.
52 | * @param path The path of the input file/directory.
53 | */
54 | fun registerInput(path: String)
55 |
56 | /**
57 | * Register an output file/directory for this integration.
58 | * @param path The path of the output file/directory.
59 | */
60 | fun registerOutput(path: String)
61 | }
62 |
63 | inline fun <
64 | reified Extension : GradmIntegrationExtension,
65 | reified ExtensionImpl : Extension,
66 | > GradmProjectWithIntegration.createExtension(): Extension =
67 | createExtension(
68 | extension = Extension::class,
69 | extensionImpl = ExtensionImpl::class,
70 | )
71 |
--------------------------------------------------------------------------------
/gradm-integration/api/src/main/kotlin/me/omico/gradm/integration/internal/GradmProjectWithIntegrationImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.internal
17 |
18 | import me.omico.gradm.GradmExtension
19 | import me.omico.gradm.integration.GradmIntegrationExtension
20 | import me.omico.gradm.integration.GradmIntegrationOwner
21 | import me.omico.gradm.integration.GradmIntegrationPlugin
22 | import me.omico.gradm.integration.GradmIntegrationsExtension
23 | import me.omico.gradm.integration.GradmProjectWithIntegration
24 | import me.omico.gradm.service.GradmBuildService
25 | import org.gradle.api.Project
26 | import org.gradle.kotlin.dsl.create
27 | import org.gradle.kotlin.dsl.getByType
28 | import java.nio.file.Path
29 | import kotlin.io.path.absolutePathString
30 | import kotlin.reflect.KClass
31 |
32 | internal class GradmProjectWithIntegrationImpl(
33 | private val plugin: GradmIntegrationPlugin,
34 | private val project: Project,
35 | ) : GradmProjectWithIntegration,
36 | Project by project {
37 | private val id: String = plugin.id
38 |
39 | private val integrationDirectory: Path =
40 | project.layout.buildDirectory.dir("gradm/integration/$id").get().asFile.toPath()
41 |
42 | private val owner: GradmIntegrationOwner = requireOwner()
43 |
44 | override val gradmExtension: GradmExtension = extensions.getByType()
45 |
46 | override val gradmIntegrationsExtension: GradmIntegrationsExtension = gradmExtension.extensions.getByType()
47 |
48 | override fun createExtension(
49 | extension: KClass,
50 | extensionImpl: KClass,
51 | ): Extension =
52 | gradmIntegrationsExtension.extensions.create(
53 | publicType = extension,
54 | name = id,
55 | instanceType = extensionImpl,
56 | )
57 |
58 | override fun registerExtension(extension: Extension): Unit = owner.register(plugin, extension)
59 |
60 | override fun registerInput(path: String): Unit = owner.registerInput(id, integrationDirectory.resolve(path))
61 |
62 | override fun registerOutput(path: String) {
63 | val output = integrationDirectory.resolve(path)
64 | require(integrationDirectory.absolutePathString() in output.absolutePathString()) {
65 | "Output must be located in integration's directory."
66 | }
67 | owner.registerOutput(id, output)
68 | }
69 |
70 | private fun requireOwner(): GradmIntegrationOwner {
71 | val registration = gradle.sharedServices.registrations
72 | .firstOrNull { it.name == GradmBuildService.NAME } ?: error("${GradmBuildService.NAME} not found.")
73 | return registration.service.get() as GradmIntegrationOwner
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/gradm-integration/github/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-integration/github/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `kotlin-dsl`
3 | kotlin("plugin.serialization")
4 | id("gradm.publishing")
5 | }
6 |
7 | kotlin {
8 | jvmToolchain(11)
9 | }
10 |
11 | gradlePlugin {
12 | plugins {
13 | register("gradmIntegrationGithub") {
14 | id = "me.omico.gradm.integration.github"
15 | implementationClass = "me.omico.gradm.integration.github.GradmGitHubIntegrationPlugin"
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | compileOnly(projects.gradmIntegration.gradmIntegrationApi)
22 | implementation(libs.kotlinx.serialization.json)
23 | }
24 |
--------------------------------------------------------------------------------
/gradm-integration/github/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm integration for GitHub.
2 | POM_NAME=Gradm GitHub integration
3 |
--------------------------------------------------------------------------------
/gradm-integration/github/src/main/kotlin/me/omico/gradm/integration/github/GradmGitHubIntegrationExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.github
17 |
18 | import me.omico.gradm.integration.GradmIntegrationExtension
19 |
20 | interface GradmGitHubIntegrationExtension : GradmIntegrationExtension
21 |
--------------------------------------------------------------------------------
/gradm-integration/github/src/main/kotlin/me/omico/gradm/integration/github/internal/GithubFetcher.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.github.internal
17 |
18 | import java.net.HttpURLConnection
19 | import java.net.URL
20 |
21 | fun fetchLatestReleaseTag(repository: String): String {
22 | val connection = URL("https://github.com/$repository/releases/latest").openConnection() as HttpURLConnection
23 | connection.instanceFollowRedirects = false
24 | connection.connect()
25 | return connection.getHeaderField("Location").split("/").last()
26 | }
27 |
--------------------------------------------------------------------------------
/gradm-integration/github/src/main/kotlin/me/omico/gradm/integration/github/internal/GithubVersionConfiguration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.github.internal
17 |
18 | import me.omico.gradm.debug
19 | import me.omico.gradm.info
20 | import me.omico.gradm.internal.config.FlatVersions
21 | import me.omico.gradm.internal.find
22 |
23 | internal data class GithubVersionConfiguration(
24 | val repository: String,
25 | val alias: String,
26 | val regex: Regex,
27 | val group: Int,
28 | val matchType: MatchType,
29 | ) {
30 | enum class MatchType {
31 | EXACT,
32 | PARTIAL,
33 | }
34 | }
35 |
36 | internal fun GithubVersionConfiguration(version: GithubVersion): GithubVersionConfiguration =
37 | GithubVersionConfiguration(
38 | repository = version.repository,
39 | alias = version.alias ?: version.repository.substringAfter("/"),
40 | regex = version.regex?.toRegex() ?: defaultSemverRegex,
41 | group = version.group,
42 | matchType = version.findMatchType(),
43 | )
44 |
45 | internal fun GithubVersionConfiguration.versionPair(versions: FlatVersions): Pair? {
46 | debug { "Fetching latest release tag for [$repository]" }
47 | val tag = fetchLatestReleaseTag(repository)
48 | val result = when (matchType) {
49 | GithubVersionConfiguration.MatchType.EXACT -> regex.matchEntire(tag)
50 | GithubVersionConfiguration.MatchType.PARTIAL -> regex.find(tag)
51 | }
52 | if (result == null) {
53 | info { "For [$repository], unable to match regex \"${regex}\" with tag \"$tag\"" }
54 | return null
55 | }
56 | val key = "versions.$alias"
57 | if (key in versions) {
58 | info { "Duplicate with $key in [$repository], skipping." }
59 | return null
60 | }
61 | runCatching { result.groupValues[group] }
62 | .onSuccess { return key to it }
63 | .onFailure {
64 | info { "Unable to parse the version for [$repository] via regex \"${regex}\" with tag \"$tag\" in group values ${result.groupValues}." }
65 | }
66 | return null
67 | }
68 |
69 | private fun GithubVersion.findMatchType(): GithubVersionConfiguration.MatchType =
70 | find("matchType", "exact")
71 | .let(String::uppercase)
72 | .let(GithubVersionConfiguration.MatchType::valueOf)
73 |
74 | private val defaultSemverRegex: Regex =
75 | "(^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][\\da-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][\\da-zA-Z-]*))*))?(?:\\+([\\da-zA-Z-]+(?:\\.[\\da-zA-Z-]+)*))?\$)".toRegex()
76 |
--------------------------------------------------------------------------------
/gradm-integration/github/src/main/kotlin/me/omico/gradm/integration/github/internal/GradmGitHubIntegrationExtensionImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.github.internal
17 |
18 | import me.omico.gradm.integration.GradmIntegrationExtensionImpl
19 | import me.omico.gradm.integration.github.GradmGitHubIntegrationExtension
20 |
21 | internal abstract class GradmGitHubIntegrationExtensionImpl : GradmGitHubIntegrationExtension,
22 | GradmIntegrationExtensionImpl("github")
23 |
--------------------------------------------------------------------------------
/gradm-integration/github/src/main/kotlin/me/omico/gradm/integration/github/internal/GradmGithubIntegrationConfiguration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.github.internal
17 |
18 | import me.omico.gradm.internal.YamlArray
19 | import me.omico.gradm.internal.YamlDocument
20 | import me.omico.gradm.internal.YamlObject
21 | import me.omico.gradm.internal.find
22 | import me.omico.gradm.internal.require
23 |
24 | internal typealias Github = YamlObject
25 | internal typealias GithubVersions = YamlArray
26 | internal typealias GithubVersion = YamlObject
27 |
28 | internal inline val YamlDocument.github: Github?
29 | get() = find("github")
30 |
31 | internal inline val Github.versions: GithubVersions
32 | get() = require("versions")
33 |
34 | internal inline val GithubVersion.repository: String
35 | get() = require("repository")
36 |
37 | internal inline val GithubVersion.alias: String?
38 | get() = find("alias")
39 |
40 | internal inline val GithubVersion.regex: String?
41 | get() = find("regex")
42 |
43 | internal inline val GithubVersion.group: Int
44 | get() = find("group", 1)
45 |
--------------------------------------------------------------------------------
/gradm-integration/runtime/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-integration/runtime/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | id("gradm.publishing")
4 | }
5 |
6 | kotlin {
7 | jvmToolchain(11)
8 | }
9 |
10 | dependencies {
11 | api(projects.gradmIntegration.gradmIntegrationApi)
12 | }
13 |
--------------------------------------------------------------------------------
/gradm-integration/runtime/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm integration runtime.
2 | POM_NAME=Gradm integration runtime
3 |
--------------------------------------------------------------------------------
/gradm-integration/runtime/src/main/kotlin/me/omico/gradm/integration/internal/GradmIntegrationConfiguration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.internal
17 |
18 | import me.omico.gradm.integration.GradmIntegration
19 | import me.omico.gradm.integration.GradmIntegrationExtension
20 |
21 | internal data class GradmIntegrationConfiguration(
22 | val id: String,
23 | val integration: GradmIntegration,
24 | val attributes: Map,
25 | val configurationFilePath: String,
26 | )
27 |
28 | internal fun GradmIntegrationConfiguration(
29 | integration: GradmIntegration,
30 | extension: GradmIntegrationExtension,
31 | ): GradmIntegrationConfiguration =
32 | GradmIntegrationConfiguration(
33 | id = integration.id,
34 | integration = integration,
35 | attributes = extension.attributes,
36 | configurationFilePath = extension.configurationFilePath,
37 | )
38 |
--------------------------------------------------------------------------------
/gradm-integration/runtime/src/main/kotlin/me/omico/gradm/integration/internal/GradmIntegrationHolderImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.integration.internal
17 |
18 | import me.omico.gradm.integration.GradmIntegration
19 | import me.omico.gradm.integration.GradmIntegrationHolder
20 | import me.omico.gradm.internal.YamlDocument
21 | import me.omico.gradm.internal.asYamlDocument
22 | import me.omico.gradm.internal.config.MutableFlatVersions
23 | import me.omico.gradm.path.GradmProjectPaths
24 | import me.omico.gradm.path.integrationRootDirectory
25 | import java.nio.file.Path
26 | import kotlin.io.path.createDirectories
27 | import kotlin.io.path.createFile
28 | import kotlin.io.path.exists
29 | import kotlin.io.path.notExists
30 |
31 | internal class GradmIntegrationHolderImpl(
32 | override val id: String,
33 | override val attributes: Map,
34 | configurationFilePath: String,
35 | private val integration: GradmIntegration,
36 | private val inputPaths: Set,
37 | private val outputPaths: Set,
38 | override val gradmProjectPaths: GradmProjectPaths,
39 | override val versions: MutableFlatVersions,
40 | ) : GradmIntegrationHolder {
41 | private val integrationDirectory: Path =
42 | gradmProjectPaths.integrationRootDirectory.resolve(id).createDirectories()
43 |
44 | override val integrationConfiguration: YamlDocument =
45 | gradmProjectPaths.path.resolve(configurationFilePath).takeIf(Path::exists)?.asYamlDocument()
46 | ?: error("Integration configuration file [$configurationFilePath] for [$id] does not exist.")
47 |
48 | override fun input(path: String): Path {
49 | val input = integrationDirectory.resolve(path)
50 | require(input in inputPaths) {
51 | "[$path] is not registered as an input.\n" +
52 | "\tUse registerInput(path) in your GradmIntegrationPlugin.onApply() function."
53 | }
54 | return input
55 | }
56 |
57 | override fun outputFile(path: String): Path {
58 | val file = output(path)
59 | file.parent.createDirectories()
60 | if (file.notExists()) file.createFile()
61 | return file
62 | }
63 |
64 | override fun outputDirectory(path: String): Path = output(path).createDirectories()
65 |
66 | fun generate(): Unit = with(integration) { onGenerate() }
67 |
68 | fun refresh(): Unit = with(integration) { onRefresh() }
69 |
70 | private fun output(path: String): Path {
71 | val output = integrationDirectory.resolve(path)
72 | require(output in outputPaths) {
73 | "[$path] is not registered as an output.\n" +
74 | "\tUse registerOutput(path) in your GradmIntegrationPlugin.onApply() function."
75 | }
76 | return output
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/gradm-runtime/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/gradm-runtime/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | id("gradm.publishing")
4 | }
5 |
6 | kotlin {
7 | jvmToolchain(11)
8 | sourceSets {
9 | main {
10 | kotlin.srcDir(layout.buildDirectory.dir("generated/sources/kotlinTemplates"))
11 | }
12 | }
13 | }
14 |
15 | dependencies {
16 | api(gradleApi())
17 | api(gradleKotlinDsl())
18 | implementation(libs.snakeyaml)
19 | implementation(libs.kotlinx.coroutines)
20 | }
21 |
22 | dependencies {
23 | api("me.omico.gradm:gradm-api-datastore:$version")
24 | }
25 |
26 | dependencies {
27 | testImplementation("me.omico.gradm:gradm-api-test:$version")
28 | }
29 |
30 | tasks.test {
31 | useJUnitPlatform()
32 | }
33 |
34 | val copyKotlinTemplates by tasks.registering(Copy::class) {
35 | from("src/main/kotlinTemplates")
36 | into(layout.buildDirectory.dir("generated/sources/kotlinTemplates"))
37 | expand("version" to version)
38 | filteringCharset = Charsets.UTF_8.toString()
39 | duplicatesStrategy = DuplicatesStrategy.INCLUDE
40 | }
41 |
42 | tasks.compileKotlin {
43 | dependsOn(copyKotlinTemplates)
44 | }
45 |
46 | val sourcesJar by tasks.named("sourcesJar") {
47 | dependsOn(copyKotlinTemplates)
48 | }
49 |
--------------------------------------------------------------------------------
/gradm-runtime/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_DESCRIPTION=Gradm runtime
2 | POM_NAME=Gradm runtime
3 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/Gradm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | const val GRADM_PACKAGE_NAME = "me.omico.gradm"
19 | const val GRADM_DEPENDENCY_PACKAGE_NAME = "$GRADM_PACKAGE_NAME.dependency"
20 |
21 | const val GRADM_PLUGIN_ID = "me.omico.gradm"
22 |
23 | fun info(message: () -> String) {
24 | println("[Gradm] ${message()}")
25 | }
26 |
27 | fun debug(message: () -> String) {
28 | if (GradmConfiguration.debug) info(message)
29 | }
30 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/GradmConfiguration.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | object GradmConfiguration {
19 | var debug: Boolean = false
20 | var offline: Boolean = false
21 | var requireRefresh: Boolean = false
22 | }
23 |
24 | object GradmFormatConfiguration {
25 | var enabled: Boolean = true
26 | var indent: Int = 2
27 | }
28 |
29 | object GradmExperimentalConfiguration {
30 | var kotlinMultiplatformSupport: Boolean = false
31 | var kotlinMultiplatformIgnoredExtensions: List = emptyList()
32 | }
33 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/GradmExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import org.gradle.api.plugins.ExtensionAware
19 |
20 | interface GradmExtension : ExtensionAware {
21 | /**
22 | * The name of the project to which this plugin is applied.
23 | */
24 | val projectName: String
25 |
26 | /**
27 | * The plugin id of the Gradm plugin.
28 | *
29 | * The default value is `me.omico.gradm.generated`.
30 | */
31 | var pluginId: String
32 |
33 | /**
34 | * The Gradm configuration file path.
35 | *
36 | * The default value is `./gradm.yml`.
37 | */
38 | var configurationFilePath: String
39 |
40 | /**
41 | * Enable debug mode for Gradm.
42 | *
43 | * The default value is `false`.
44 | */
45 | var debug: Boolean
46 | }
47 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/GradmGeneratedPlugin.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import org.gradle.plugin.devel.GradlePluginDevelopmentExtension
19 | import org.gradle.plugin.devel.PluginDeclaration
20 |
21 | sealed class GradmGeneratedPluginType(
22 | val name: String,
23 | val pluginId: String,
24 | val packageName: String,
25 | val className: String,
26 | ) {
27 | val implementationClass: String by lazy { "$packageName.$className" }
28 |
29 | object General : GradmGeneratedPluginType(
30 | name = "gradmGenerated",
31 | pluginId = "me.omico.gradm.generated",
32 | packageName = "me.omico.gradm.generated",
33 | className = "GradmPlugin",
34 | )
35 | }
36 |
37 | fun GradlePluginDevelopmentExtension.createGradmGeneratedPluginDeclaration(type: GradmGeneratedPluginType): PluginDeclaration =
38 | plugins.create(type.name) { declaration ->
39 | declaration.id = type.pluginId
40 | declaration.implementationClass = type.implementationClass
41 | }
42 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/VersionsMeta.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import java.nio.file.Path
19 | import kotlin.io.path.exists
20 | import kotlin.io.path.readLines
21 | import kotlin.io.path.writeText
22 |
23 | typealias VersionsMeta = Map
24 |
25 | fun VersionsMeta.store(versionsMeta: Path) {
26 | versionsMeta.writeText(versionsMetaContent)
27 | }
28 |
29 | fun Path.asVersionsMeta(): VersionsMeta? =
30 | takeIf(Path::exists)?.readLines()
31 | ?.associate {
32 | val strings = it.split("=")
33 | strings.first() to strings.last()
34 | }
35 |
36 | private val VersionsMeta.versionsMetaContent: String
37 | get() = buildString { toSortedMap().forEach { (key, value) -> appendLine("$key=$value") } }
38 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/Hash.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal
17 |
18 | import java.nio.file.Files
19 | import java.nio.file.Path
20 | import java.security.MessageDigest
21 | import java.util.stream.Stream
22 | import kotlin.io.path.isDirectory
23 | import kotlin.io.path.isRegularFile
24 | import kotlin.io.path.readBytes
25 |
26 | fun Path.hash(algorithm: String): String =
27 | when {
28 | isRegularFile() -> readBytes().hash(algorithm)
29 | isDirectory() -> Files.walk(this).filter(Path::isRegularFile).map(Path::readBytes).hash(algorithm)
30 | else -> error("$this is not a file or directory")
31 | }
32 |
33 | fun hash(algorithm: String, block: MessageDigest.() -> Unit): String =
34 | MessageDigest.getInstance(algorithm).apply(block).digest().hex()
35 |
36 | fun ByteArray.hash(algorithm: String): String = let { hash(algorithm) { update(it) } }
37 |
38 | fun Stream.hash(algorithm: String): String = hash(algorithm) { forEach(::update) }
39 |
40 | fun Iterable.hash(algorithm: String): String = hash(algorithm) { forEach(::update) }
41 |
42 | fun ByteArray.hex(): String = fold("") { str, byte -> str + "%02x".format(byte) }
43 |
44 | fun Path.sha1(): String = hash("SHA-1")
45 |
46 | fun Iterable.sha1(): String = hash("SHA-1")
47 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/Yaml.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal
17 |
18 | import org.snakeyaml.engine.v2.api.Load
19 | import org.snakeyaml.engine.v2.api.LoadSettings
20 | import org.snakeyaml.engine.v2.api.LoadSettingsBuilder
21 | import java.nio.file.Path
22 | import kotlin.io.path.isRegularFile
23 | import kotlin.io.path.readText
24 |
25 | typealias YamlObject = Map
26 | typealias YamlArray = List
27 | typealias YamlDocument = YamlObject
28 |
29 | fun Path.asYamlDocument(builder: LoadSettingsBuilder.() -> Unit = {}): YamlDocument =
30 | run {
31 | require(isRegularFile()) { "Path must be a regular file." }
32 | loadDocument(readText(), builder)
33 | }
34 |
35 | inline fun YamlObject.find(key: String): T? = this[key] as? T
36 |
37 | inline fun YamlObject.find(key: String, defaultValue: T): T = find(key) ?: defaultValue
38 |
39 | inline fun YamlObject.find(key: String, orElse: () -> T): T = find(key) ?: orElse()
40 |
41 | inline fun YamlObject.require(key: String): T = find(key) ?: error("$key not found.")
42 |
43 | private inline fun loadDocument(
44 | content: String,
45 | builder: LoadSettingsBuilder.() -> Unit = {},
46 | ): T = load(builder).loadFromString(content) as T
47 |
48 | private inline fun load(builder: LoadSettingsBuilder.() -> Unit = {}): Load =
49 | LoadSettings.builder().apply(builder).build().let(::Load)
50 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/Dependencies.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config
17 |
18 | import me.omico.gradm.internal.YamlDocument
19 | import me.omico.gradm.internal.YamlObject
20 | import me.omico.gradm.internal.find
21 | import me.omico.gradm.internal.require
22 | import java.net.URL
23 |
24 | val YamlDocument.dependencies: List
25 | @Suppress("UNCHECKED_CAST")
26 | get() = run {
27 | val repositories = repositories
28 | val versions = versions.toFlatVersions()
29 | find("dependencies", emptyMap())
30 | .flatMap { (repositoryId, groups) ->
31 | val repository = repositories.requireRepository(repositoryId)
32 | (groups as YamlObject).flatMap { (group, artifacts) ->
33 | (artifacts as YamlObject).map { (artifact, attributes) ->
34 | attributes as YamlObject
35 | val noSpecificVersion = attributes.find("noSpecificVersion", false)
36 | val version = when {
37 | noSpecificVersion -> null
38 | else -> attributes.find("version").let(versions::resolveVariable)
39 | }
40 | val bom = attributes.find("bom", false)
41 | if (bom && !repository.noUpdates) {
42 | requireNotNull(version) { "BOM dependency must have a version." }
43 | }
44 | Dependency(
45 | repository = repository.url,
46 | noUpdates = repository.noUpdates,
47 | noSpecificVersion = noSpecificVersion,
48 | bom = bom,
49 | group = group,
50 | artifact = artifact,
51 | alias = attributes.require("alias"),
52 | version = version,
53 | )
54 | }
55 | }
56 | }
57 | }
58 |
59 | data class Dependency(
60 | val repository: String,
61 | val noUpdates: Boolean,
62 | val noSpecificVersion: Boolean,
63 | val bom: Boolean,
64 | val group: String,
65 | val artifact: String,
66 | val alias: String,
67 | val version: String?,
68 | ) {
69 | val module: String by lazy(LazyThreadSafetyMode.NONE) { "$group:$artifact" }
70 | val metadataUrl: URL by lazy(LazyThreadSafetyMode.NONE) {
71 | URL("$repository/${group.replace(".", "/")}/$artifact/maven-metadata.xml")
72 | }
73 | }
74 |
75 | fun YamlDocument.collectAllDependencies(): List =
76 | ArrayList()
77 | .apply { addAll(plugins.map(Plugin::toDependency)) }
78 | .apply { addAll(dependencies) }
79 |
80 | fun YamlDocument.collectAllUpdatableDependencies(): List =
81 | collectAllDependencies()
82 | .filterNot(Dependency::noUpdates)
83 | .filterNot(Dependency::noSpecificVersion)
84 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/Plugins.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config
17 |
18 | import me.omico.gradm.internal.YamlDocument
19 | import me.omico.gradm.internal.YamlObject
20 | import me.omico.gradm.internal.find
21 |
22 | val YamlDocument.plugins: List
23 | @Suppress("UNCHECKED_CAST")
24 | get() = run {
25 | val repositories = repositories
26 | val versions = versions.toFlatVersions()
27 | find("plugins", emptyMap())
28 | .flatMap { (repositoryId, plugin) ->
29 | val repository = repositories.requireRepository(repositoryId)
30 | (plugin as YamlObject).map { (id, version) ->
31 | version as String
32 | Plugin(
33 | repository = repository.url,
34 | noUpdates = repository.noUpdates,
35 | id = id,
36 | version = version.let(versions::resolveVariable),
37 | )
38 | }
39 | }
40 | }
41 |
42 | data class Plugin(
43 | val repository: String,
44 | val noUpdates: Boolean,
45 | val id: String,
46 | val version: String?,
47 | ) {
48 | val group: String by lazy { id }
49 | val artifact: String by lazy { "$id.gradle.plugin" }
50 | val module: String by lazy { "$group:$artifact" }
51 | }
52 |
53 | internal fun Plugin.toDependency(): Dependency =
54 | Dependency(
55 | repository = repository,
56 | noUpdates = noUpdates,
57 | noSpecificVersion = false,
58 | bom = false,
59 | group = group,
60 | artifact = artifact,
61 | alias = id,
62 | version = version,
63 | )
64 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/Repositories.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config
17 |
18 | import me.omico.gradm.internal.YamlDocument
19 | import me.omico.gradm.internal.YamlObject
20 | import me.omico.gradm.internal.find
21 |
22 | val YamlDocument.repositories: List
23 | get() = find("repositories", emptyMap())
24 | .map { (id, attributes) -> buildInRepositories.find { it.id == id } ?: repository(id, attributes) }
25 |
26 | data class Repository(
27 | val id: String,
28 | val url: String,
29 | val noUpdates: Boolean,
30 | val buildIn: Boolean,
31 | )
32 |
33 | val gradleBuildInRepositories: List =
34 | listOf(
35 | buildInRepository(id = "gradlePluginPortal", url = "https://plugins.gradle.org/m2"),
36 | buildInRepository(id = "mavenCentral", url = "https://repo1.maven.org/maven2"),
37 | buildInRepository(id = "mavenLocal", noUpdates = true),
38 | buildInRepository(id = "google", url = "https://maven.google.com"),
39 | )
40 |
41 | val buildInRepositories: List =
42 | gradleBuildInRepositories + listOf(
43 | buildInRepository(id = "noUpdates", noUpdates = true),
44 | buildInRepository(id = "omico", url = "https://maven.omico.me"),
45 | )
46 |
47 | internal fun String.fixedUrl(): String =
48 | when {
49 | endsWith("/") -> removeSuffix("/")
50 | else -> this
51 | }
52 |
53 | internal fun List.requireRepository(id: String): Repository =
54 | requireNotNull(find { it.id == id }) { "Repository $id not found." }
55 |
56 | @Suppress("UNCHECKED_CAST")
57 | private fun repository(id: String, attributes: Any?): Repository =
58 | run {
59 | attributes as? YamlObject ?: error("Repository $id attributes is missing.")
60 | Repository(
61 | id = id,
62 | url = attributes.find("url")?.fixedUrl() ?: "",
63 | noUpdates = attributes.find("noUpdates", false),
64 | buildIn = false,
65 | )
66 | }
67 |
68 | private fun buildInRepository(id: String, url: String = "", noUpdates: Boolean = false): Repository =
69 | Repository(
70 | id = id,
71 | url = url,
72 | noUpdates = noUpdates,
73 | buildIn = true,
74 | )
75 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Builder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format
17 |
18 | interface Builder {
19 | fun build(): T
20 | }
21 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Comment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format
17 |
18 | data class Comment(
19 | val block: List = emptyList(),
20 | val inline: String = "",
21 | )
22 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/ScalarStyle.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format
17 |
18 | sealed interface ScalarStyle {
19 | object Plain : ScalarStyle
20 | object SingleQuoted : ScalarStyle
21 | object DoubleQuoted : ScalarStyle
22 | }
23 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/Yaml.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format
17 |
18 | import me.omico.gradm.internal.config.format.node.MappingNodeScope
19 | import me.omico.gradm.internal.config.format.node.Node
20 |
21 | interface YamlScope : MappingNodeScope {
22 | fun newline()
23 | fun comment(comment: String)
24 | }
25 |
26 | class YamlBuilder(
27 | private val formatterScope: FormatterScope = FormatterScope(),
28 | ) : YamlScope, FormatterScope by formatterScope, Builder {
29 |
30 | private val stringBuilder = StringBuilder()
31 |
32 | override fun newline() {
33 | stringBuilder.appendLine()
34 | }
35 |
36 | override fun comment(comment: String) {
37 | stringBuilder.appendComment(comment)
38 | }
39 |
40 | override fun put(key: String, node: Node) {
41 | stringBuilder.appendNode(key, node)
42 | }
43 |
44 | override fun build(): String = stringBuilder.toString()
45 | }
46 |
47 | fun YamlBuilder.comments(vararg comments: String) = comments.forEach { comment(it) }
48 | fun YamlBuilder.comments(comments: List) = comments.forEach { comment(it) }
49 |
50 | fun yaml(
51 | formatterScope: FormatterScope = FormatterScope(),
52 | block: YamlBuilder.() -> Unit,
53 | ): String = YamlBuilder(formatterScope).apply(block).build()
54 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/node/CollectionNode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format.node
17 |
18 | interface CollectionNode : Node {
19 | val items: T
20 | }
21 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/node/MappingNode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format.node
17 |
18 | import me.omico.gradm.internal.config.format.Builder
19 | import me.omico.gradm.internal.config.format.Comment
20 | import me.omico.gradm.internal.config.format.ScalarStyle
21 |
22 | typealias YamlMapping = Map
23 |
24 | data class MappingNode(
25 | override val items: YamlMapping,
26 | override val comment: Comment = Comment(),
27 | ) : CollectionNode, YamlMapping by items
28 |
29 | interface MappingNodeScope {
30 | fun put(key: String, node: Node)
31 | }
32 |
33 | fun MappingNodeScope.scalar(
34 | key: String,
35 | value: T,
36 | style: ScalarStyle = ScalarStyle.Plain,
37 | comment: Comment = Comment(),
38 | ) = put(key, ScalarNode(value, style, comment))
39 |
40 | fun MappingNodeScope.sequence(
41 | key: String,
42 | values: YamlSequence,
43 | comment: Comment = Comment(),
44 | ) = put(key, SequenceNode(values, comment))
45 |
46 | fun MappingNodeScope.sequence(
47 | key: String,
48 | comment: Comment = Comment(),
49 | block: YamlSequenceBuilder.() -> Unit,
50 | ) = sequence(key, sequence(block), comment)
51 |
52 | fun MappingNodeScope.mapping(
53 | key: String,
54 | values: YamlMapping,
55 | comment: Comment = Comment(),
56 | ) = put(key, MappingNode(values, comment))
57 |
58 | fun MappingNodeScope.mapping(
59 | key: String,
60 | comment: Comment = Comment(),
61 | block: YamlMappingBuilder.() -> Unit = {},
62 | ) = mapping(key, mapping(block), comment)
63 |
64 | class YamlMappingBuilder : MappingNodeScope, Builder {
65 |
66 | private val mapping = LinkedHashMap()
67 |
68 | override fun put(key: String, node: Node) {
69 | require(!mapping.containsKey(key)) { "Duplicate key: $key" }
70 | mapping[key] = node
71 | }
72 |
73 | override fun build(): YamlMapping = mapping
74 | }
75 |
76 | fun mapping(block: YamlMappingBuilder.() -> Unit): YamlMapping = YamlMappingBuilder().apply(block).build()
77 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/node/Node.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format.node
17 |
18 | import me.omico.gradm.internal.config.format.Comment
19 |
20 | interface Node {
21 | val comment: Comment
22 | }
23 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/node/ScalarNode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format.node
17 |
18 | import me.omico.gradm.internal.config.format.Comment
19 | import me.omico.gradm.internal.config.format.ScalarStyle
20 |
21 | data class ScalarNode(
22 | val value: Any,
23 | val style: ScalarStyle,
24 | override val comment: Comment = Comment(),
25 | ) : Node
26 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/config/format/node/SequenceNode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format.node
17 |
18 | import me.omico.gradm.internal.config.format.Builder
19 | import me.omico.gradm.internal.config.format.Comment
20 | import me.omico.gradm.internal.config.format.ScalarStyle
21 |
22 | typealias YamlSequence = List
23 |
24 | data class SequenceNode(
25 | override val items: YamlSequence,
26 | override val comment: Comment = Comment(),
27 | ) : CollectionNode, YamlSequence by items
28 |
29 | interface SequenceNodeScope {
30 | fun add(node: Node)
31 | }
32 |
33 | fun SequenceNodeScope.scalar(
34 | value: T,
35 | scalarStyle: ScalarStyle = ScalarStyle.Plain,
36 | comment: Comment = Comment(),
37 | ) = add(ScalarNode(value, scalarStyle, comment))
38 |
39 | fun SequenceNodeScope.mapping(
40 | values: YamlMapping,
41 | comment: Comment = Comment(),
42 | ) = add(MappingNode(values, comment))
43 |
44 | fun SequenceNodeScope.mapping(
45 | comment: Comment = Comment(),
46 | block: YamlMappingBuilder.() -> Unit,
47 | ) = mapping(mapping(block), comment)
48 |
49 | class YamlSequenceBuilder : SequenceNodeScope, Builder {
50 |
51 | private val sequence = mutableListOf()
52 |
53 | override fun add(node: Node) {
54 | sequence.add(node)
55 | }
56 |
57 | override fun build(): YamlSequence = sequence
58 | }
59 |
60 | fun sequence(block: YamlSequenceBuilder.() -> Unit): YamlSequence = YamlSequenceBuilder().apply(block).build()
61 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/maven/Version.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.maven
17 |
18 | data class Version(
19 | val major: Int,
20 | val minor: Int,
21 | val patch: Int,
22 | val qualifier: String?,
23 | val value: String,
24 | ) : Comparable {
25 | override fun compareTo(other: Version): Int {
26 | var result = compareValuesBy(this, other, Version::major, Version::minor, Version::patch)
27 | if (result != 0) return result
28 | val otherQualifier = other.qualifier
29 | if (qualifier == otherQualifier) return 0
30 | if (qualifier == null) return 1
31 | if (otherQualifier == null) return -1
32 | val thisQualifierResult = QualifierRegex.matchEntire(qualifier.lowercase())
33 | val otherQualifierResult = QualifierRegex.matchEntire(otherQualifier.lowercase())
34 | if (thisQualifierResult?.value == otherQualifierResult?.value) return 0
35 | if (thisQualifierResult == null) return 1
36 | if (otherQualifierResult == null) return -1
37 | result = compareValuesBy(thisQualifierResult.groupValues[1], otherQualifierResult.groupValues[1]) {
38 | QUALIFIERS.getOrDefault(it, 0)
39 | }
40 | if (result != 0) return result
41 | result = compareValues(
42 | a = thisQualifierResult.groupValues[2].toInt(),
43 | b = otherQualifierResult.groupValues[2].toInt(),
44 | )
45 | return result
46 | }
47 |
48 | override fun toString(): String = value
49 |
50 | companion object {
51 | fun parse(version: String): Version = run {
52 | val versionSplit = version.split("-", limit = 2)
53 | val versionNumbers = versionSplit.first().split(".").mapNotNull(String::toIntOrNull)
54 | Version(
55 | major = versionNumbers.getOrElse(0) { 0 },
56 | minor = versionNumbers.getOrElse(1) { 0 },
57 | patch = versionNumbers.getOrElse(2) { 0 },
58 | qualifier = versionSplit.getOrNull(1),
59 | value = version,
60 | )
61 | }
62 | }
63 | }
64 |
65 | private val QualifierRegex: Regex = Regex("(alpha|beta|milestone|rc|snapshot)([0-9]{2})?")
66 |
67 | private val QUALIFIERS: Map =
68 | mapOf(
69 | "snapshot" to -5,
70 | "alpha" to -4,
71 | "beta" to -3,
72 | "milestone" to -2,
73 | "rc" to -1,
74 | "" to 0,
75 | )
76 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/maven/Xml.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.maven
17 |
18 | import org.w3c.dom.Node
19 | import org.w3c.dom.NodeList
20 | import javax.xml.parsers.DocumentBuilder
21 | import javax.xml.parsers.DocumentBuilderFactory
22 |
23 | internal val documentBuilder: DocumentBuilder by lazy { DocumentBuilderFactory.newInstance().newDocumentBuilder() }
24 |
25 | internal fun NodeList.map(transform: (Node) -> T): List =
26 | (0 until length).map { index -> transform(item(index)) }
27 |
28 | internal fun NodeList.mapNotNull(transform: (Node) -> T?): List =
29 | (0 until length).mapNotNull { index -> transform(item(index)) }
30 |
31 | internal fun NodeList.forEach(transform: (Node) -> Unit): Unit =
32 | (0 until length).forEach { index -> transform(item(index)) }
33 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/maven/bom/MavenBomPom.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.maven.bom
17 |
18 | import me.omico.gradm.internal.maven.documentBuilder
19 | import me.omico.gradm.internal.maven.forEach
20 | import me.omico.gradm.internal.maven.map
21 | import org.w3c.dom.Document
22 | import org.w3c.dom.Node
23 | import java.nio.file.Path
24 | import kotlin.io.path.absolutePathString
25 |
26 | data class MavenBomPom(
27 | val group: String,
28 | val artifact: String,
29 | val version: String,
30 | val dependencies: List,
31 | ) {
32 | val module: String by lazy { "$group:$artifact" }
33 | }
34 |
35 | data class MavenBomDependency(
36 | val group: String,
37 | val artifact: String,
38 | val version: String,
39 | ) {
40 | val module: String by lazy { "$group:$artifact" }
41 | }
42 |
43 | internal fun MavenBomPom(path: Path): MavenBomPom =
44 | documentBuilder.parse(path.absolutePathString()).let(Document::MavenBomPom)
45 |
46 | private fun Document.MavenBomPom(): MavenBomPom =
47 | MavenBomPom(
48 | group = getElementsByTagName("groupId").item(0).textContent,
49 | artifact = getElementsByTagName("artifactId").item(0).textContent,
50 | version = getElementsByTagName("version").item(0).textContent,
51 | dependencies = getElementsByTagName("dependency").map(Node::MavenBomDependency),
52 | )
53 |
54 | private fun Node.MavenBomDependency(): MavenBomDependency = run {
55 | var group: String? = null
56 | var artifact: String? = null
57 | var version: String? = null
58 | childNodes.forEach {
59 | when (it.nodeName) {
60 | "groupId" -> group = it.textContent
61 | "artifactId" -> artifact = it.textContent
62 | "version" -> version = it.textContent
63 | }
64 | }
65 | MavenBomDependency(
66 | group = group!!,
67 | artifact = artifact!!,
68 | version = version!!,
69 | )
70 | }
71 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/internal/maven/bom/MavenPomPomResolver.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.maven.bom
17 |
18 | import me.omico.gradm.VersionsMeta
19 | import me.omico.gradm.internal.YamlDocument
20 | import me.omico.gradm.internal.config.Dependency
21 | import me.omico.gradm.internal.config.dependencies
22 | import org.gradle.api.artifacts.dsl.DependencyHandler
23 | import org.gradle.api.artifacts.result.ResolvedArtifactResult
24 | import org.gradle.maven.MavenModule
25 | import org.gradle.maven.MavenPomArtifact
26 |
27 | internal fun DependencyHandler.resolveBomVersionsMeta(document: YamlDocument): VersionsMeta =
28 | document
29 | .dependencies
30 | .filter(Dependency::bom)
31 | .map(::MavenBomPom)
32 | .flatMap(MavenBomPom::dependencies)
33 | .associate { it.module to it.version }
34 |
35 | private fun DependencyHandler.MavenBomPom(dependency: Dependency): MavenBomPom =
36 | createArtifactResolutionQuery()
37 | .forModule(dependency.group, dependency.artifact, dependency.version!!)
38 | .withArtifacts(MavenModule::class.java, MavenPomArtifact::class.java)
39 | .execute()
40 | .resolvedComponents
41 | .flatMap { component ->
42 | component.getArtifacts(MavenPomArtifact::class.java)
43 | .filterIsInstance()
44 | .map(ResolvedArtifactResult::getFile)
45 | }
46 | .first()
47 | .toPath()
48 | .let(::MavenBomPom)
49 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/path/GradmProjectPaths.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.path
17 |
18 | import org.gradle.api.Project
19 | import org.gradle.api.file.Directory
20 | import org.gradle.api.file.ProjectLayout
21 | import org.gradle.api.file.RegularFile
22 | import org.gradle.api.provider.Provider
23 | import java.nio.file.Path
24 | import kotlin.io.path.Path
25 | import kotlin.io.path.div
26 |
27 | data class GradmProjectPaths(
28 | val path: Path,
29 | val configurationFile: Path,
30 | val projectName: String,
31 | )
32 |
33 | fun ProjectLayout.gradmConfigurationFile(path: String): RegularFile = projectDirectory.file(path)
34 |
35 | inline val Project.gradmAvailableUpdatesFile: Provider
36 | get() = layout.buildDirectory.file("gradm/updates/available.yml")
37 |
38 | inline val Project.gradmGeneratedSourcesDirectory: Provider
39 | get() = layout.buildDirectory.dir("generated/sources/gradm/kotlin/main")
40 |
41 | inline val GradmProjectPaths.buildDirectory: Path
42 | get() = path / "build"
43 |
44 | inline val GradmProjectPaths.gradmBuildDirectory: Path
45 | get() = buildDirectory / "gradm"
46 |
47 | inline val GradmProjectPaths.gradmLocalConfigurationFile: Path
48 | get() = gradmBuildDirectory / ".gradm"
49 |
50 | inline val GradmProjectPaths.integrationRootDirectory: Path
51 | get() = gradmBuildDirectory / "integration"
52 |
53 | inline val GradmProjectPaths.updatesDirectory: Path
54 | get() = gradmBuildDirectory / "updates"
55 |
56 | inline val GradmProjectPaths.updatesAvailableFile: Path
57 | get() = updatesDirectory / "available.yml"
58 |
59 | inline val GradmProjectPaths.generatedJar: Path
60 | get() = (buildDirectory / "libs" / "$projectName.jar").normalize()
61 |
62 | val userHomeDirectory: Path = Path(System.getProperty("user.home"))
63 | val gradmUserHomeDirectory: Path = userHomeDirectory / ".gradm"
64 | val gradmMetadataFile: Path = gradmUserHomeDirectory / ".metadata"
65 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/service/GradmBuildService.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.service
17 |
18 | import org.gradle.api.services.BuildService
19 | import org.gradle.api.services.BuildServiceParameters
20 |
21 | interface GradmBuildService : BuildService, AutoCloseable {
22 | companion object {
23 | const val NAME = "GradmBuildService"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlin/me/omico/gradm/utility/Path.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.utility
17 |
18 | import java.nio.file.Files
19 | import java.nio.file.Path
20 | import kotlin.io.path.createDirectories
21 | import kotlin.io.path.exists
22 | import kotlin.io.path.isDirectory
23 |
24 | fun Path.deleteDirectory() {
25 | if (exists() && isDirectory()) Files.walk(this).sorted(Comparator.reverseOrder()).forEach(Files::delete)
26 | }
27 |
28 | fun Path.clearDirectory() {
29 | deleteDirectory()
30 | createDirectories()
31 | }
32 |
--------------------------------------------------------------------------------
/gradm-runtime/src/main/kotlinTemplates/me/omico/gradm/GradmVersion.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | const val GRADM_VERSION = "$version"
19 |
--------------------------------------------------------------------------------
/gradm-runtime/src/test/kotlin/me/omico/gradm/internal/config/format/FormatterTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.config.format
17 |
18 | import me.omico.gradm.internal.config.format.node.mapping
19 | import me.omico.gradm.internal.config.format.node.scalar
20 | import me.omico.gradm.internal.config.format.node.sequence
21 | import me.omico.gradm.test.resources
22 | import org.junit.jupiter.api.Test
23 | import kotlin.io.path.readText
24 |
25 | class FormatterTest {
26 | @Test
27 | fun `test YAML DSL builder`() {
28 | val content = yaml {
29 | comment("Top comment")
30 | newline()
31 | scalar("test1", "normal")
32 | scalar("test2", "with quotes", ScalarStyle.DoubleQuoted)
33 | comments("comment1", "comment2")
34 | mapping("test3") {
35 | scalar("one", 1)
36 | mapping("two") {
37 | scalar("three", 3)
38 | mapping("two") {
39 | scalar("three", 3)
40 | }
41 | }
42 | sequence("four") {
43 | scalar("aaaa")
44 | mapping {
45 | scalar("xxx", "xx")
46 | scalar("yyy", "yy")
47 | }
48 | mapping {
49 | scalar(
50 | key = "xxx",
51 | value = "xx",
52 | comment = Comment(
53 | block = listOf("comment"),
54 | inline = "comment",
55 | ),
56 | )
57 | scalar("yyy", "yy")
58 | scalar("aa", "yy")
59 | }
60 | }
61 | }
62 | comment("End comment")
63 | }
64 | assert(content == resources("format-test.yml").readText())
65 | }
66 |
67 | @Test
68 | fun `test format Gradm configuration`() {
69 | val unformattedConfigurationFile = resources("gradm.unformatted.yml")
70 | val formattedConfigurationFile = resources("gradm.formatted.yml")
71 | assert(unformattedConfigurationFile.createFormattedGradmConfigurationContent() == formattedConfigurationFile.readText())
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/gradm-runtime/src/test/kotlin/me/omico/gradm/internal/maven/VersionTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.internal.maven
17 |
18 | import org.junit.jupiter.api.Test
19 |
20 | class VersionTest {
21 | @Test
22 | fun `1_2_0-alpha01 same as 1_2_0-alpha01`() {
23 | assert(Version.parse("1.2.0-alpha01") == Version.parse("1.2.0-alpha01"))
24 | }
25 |
26 | @Test
27 | fun `1_2_0-alpha01 older than 1_2_0-alpha02`() {
28 | assert(Version.parse("1.2.0-alpha01") < Version.parse("1.2.0-alpha02"))
29 | }
30 |
31 | @Test
32 | fun `1_2_0-rc01 newer than 1_2_0-alpha02`() {
33 | assert(Version.parse("1.2.0-rc01") > Version.parse("1.2.0-alpha02"))
34 | }
35 |
36 | @Test
37 | fun `1_2_0-SNAPSHOT older than 1_2_0-rc02`() {
38 | assert(Version.parse("1.2.0-SNAPSHOT") < Version.parse("1.2.0-rc02"))
39 | }
40 |
41 | @Test
42 | fun `1_2_0 newer than 1_2_0-SNAPSHOT`() {
43 | assert(Version.parse("1.2.0") > Version.parse("1.2.0-SNAPSHOT"))
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/gradm-runtime/src/test/resources/format-test.yml:
--------------------------------------------------------------------------------
1 | # Top comment
2 |
3 | test1: normal
4 | test2: "with quotes"
5 | # comment1
6 | # comment2
7 | test3:
8 | one: 1
9 | two:
10 | three: 3
11 | two:
12 | three: 3
13 | four:
14 | - aaaa
15 | - xxx: xx
16 | yyy: yy
17 | - # comment
18 | xxx: xx # comment
19 | yyy: yy
20 | aa: yy
21 | # End comment
22 |
--------------------------------------------------------------------------------
/integration-testing/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/integration-testing/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | kotlin("jvm")
3 | }
4 |
5 | kotlin {
6 | jvmToolchain(11)
7 | }
8 |
9 | dependencies {
10 | testImplementation(gradleTestKit())
11 | testImplementation(platform(libs.junit.bom))
12 | testImplementation(libs.junit.jupiter)
13 | }
14 |
15 | tasks.test {
16 | val requiredTasks = listOf("test", "publishToMavenLocal")
17 | rootProject.allprojects {
18 | requiredTasks.forEach {
19 | val task = tasks.findByName(it) ?: return@forEach
20 | if (task == this@test) return@forEach
21 | this@test.dependsOn(task)
22 | }
23 | }
24 | inputs.dir("../examples")
25 | useJUnitPlatform()
26 | }
27 |
--------------------------------------------------------------------------------
/integration-testing/src/test/kotlin/me/omico/gradm/GettingStartedTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import me.omico.gradm.utility.assertGradleBuildSuccess
19 | import org.gradle.testkit.runner.GradleRunner
20 | import org.junit.jupiter.api.Test
21 | import java.io.File
22 |
23 | class GettingStartedTest {
24 | @Test
25 | fun `test gradm-getting-started`() {
26 | GradleRunner.create()
27 | .withProjectDir(File("../examples/gradm-getting-started"))
28 | .withArguments(
29 | "clean",
30 | ":gradm:gradmDependencyUpdates",
31 | "build",
32 | "--stacktrace",
33 | )
34 | .forwardOutput()
35 | .build()
36 | .let(::assertGradleBuildSuccess)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/integration-testing/src/test/kotlin/me/omico/gradm/WithCompositeBuildTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import me.omico.gradm.utility.assertGradleBuildSuccess
19 | import org.gradle.testkit.runner.GradleRunner
20 | import org.junit.jupiter.api.Test
21 | import java.io.File
22 |
23 | class WithCompositeBuildTest {
24 | @Test
25 | fun `test gradm-with-composite-build`() {
26 | GradleRunner.create()
27 | .withProjectDir(File("../examples/gradm-with-composite-build"))
28 | .withArguments(
29 | "spotlessApply",
30 | "clean",
31 | ":gradm:gradmDependencyUpdates",
32 | "build",
33 | "--stacktrace",
34 | )
35 | .forwardOutput()
36 | .build()
37 | .let(::assertGradleBuildSuccess)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/integration-testing/src/test/kotlin/me/omico/gradm/WithKotlinMultiplatformTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm
17 |
18 | import me.omico.gradm.utility.assertGradleBuildSuccess
19 | import org.gradle.testkit.runner.GradleRunner
20 | import org.junit.jupiter.api.Test
21 | import java.io.File
22 |
23 | class WithKotlinMultiplatformTest {
24 | @Test
25 | fun `test gradm-with-kotlin-multiplatform`() {
26 | GradleRunner.create()
27 | .withProjectDir(File("../examples/gradm-with-kotlin-multiplatform"))
28 | .withArguments(
29 | "clean",
30 | ":gradm:gradmDependencyUpdates",
31 | "build",
32 | "--stacktrace",
33 | )
34 | .forwardOutput()
35 | .build()
36 | .let(::assertGradleBuildSuccess)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/integration-testing/src/test/kotlin/me/omico/gradm/utility/Gradle.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022-2023 Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.omico.gradm.utility
17 |
18 | import org.gradle.testkit.runner.BuildResult
19 |
20 | fun assertGradleBuildSuccess(result: BuildResult): Unit = assert(result.output.contains("BUILD SUCCESSFUL"))
21 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "gradm-root"
2 |
3 | pluginManagement {
4 | includeBuild("build-logic/initialization")
5 | }
6 |
7 | plugins {
8 | id("gradm")
9 | }
10 |
--------------------------------------------------------------------------------
/spotless/copyright.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright $YEAR Omico
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
--------------------------------------------------------------------------------