Skip to content

Commit ee84b48

Browse files
authored
Merge pull request #1 from EranBoudjnah/version_2.0
2 parents c5db0d0 + 5d58369 commit ee84b48

File tree

142 files changed

+4000
-3154
lines changed

Some content is hidden

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

142 files changed

+4000
-3154
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
end_of_line = lf
5+
ij_kotlin_allow_trailing_comma = false
6+
ij_kotlin_allow_trailing_comma_on_call_site = false
7+
ij_kotlin_imports_layout = *
8+
ij_kotlin_packages_to_use_import_on_demand = java.util.*, kotlinx.android.synthetic.**
9+
indent_size = 4
10+
indent_style = space
11+
insert_final_newline = true
12+
ktlint_code_style = android_studio
13+
ktlint_function_naming_ignore_when_annotated_with=Composable
14+
ktlint_function_signature_body_expression_wrapping = default
15+
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
16+
ktlint_ignore_back_ticked_identifier = false
17+
max_line_length = 100
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Cache Build'
2+
description: 'Cache build paths'
3+
inputs:
4+
key:
5+
description: 'Cache key'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Cache build artifacts
11+
uses: actions/cache@v3
12+
with:
13+
path: |
14+
example/build
15+
randomgenkt/build
16+
randomgenkt.datasource/build
17+
key: ${{ inputs.key }}
18+
restore-keys: |
19+
${{ inputs.key }}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Android CI
2+
3+
env:
4+
cache-name: android-gradle
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
jobs:
13+
setup:
14+
runs-on: macos-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: set up JDK 17
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: '17'
24+
distribution: 'adopt'
25+
cache: gradle
26+
27+
- name: Cache build artifacts
28+
uses: ./.github/actions/cache-build-paths
29+
with:
30+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
31+
32+
- name: Grant execute permission for gradlew
33+
run: chmod +x gradlew
34+
35+
- name: Assemble with Gradle
36+
run: ./gradlew jar --no-daemon
37+
38+
unit-tests:
39+
needs: setup
40+
41+
runs-on: macos-latest
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: set up JDK 17
48+
uses: actions/setup-java@v3
49+
with:
50+
java-version: '17'
51+
distribution: 'adopt'
52+
cache: gradle
53+
54+
- name: Cache build artifacts
55+
uses: ./.github/actions/cache-build-paths
56+
with:
57+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
58+
59+
- name: Grant execute permission for gradlew
60+
run: chmod +x gradlew
61+
62+
- name: Assemble
63+
run: ./gradlew randomgenkt:assemble randomgenkt.datasource:assemble
64+
65+
- name: Publish to local maven
66+
run: ./gradlew randomgenkt:publishToMavenLocal randomgenkt.datasource:publishToMavenLocal
67+
68+
- name: Run unit tests
69+
run: ./gradlew test
70+
71+
lint:
72+
needs: setup
73+
74+
runs-on: macos-latest
75+
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: set up JDK 17
81+
uses: actions/setup-java@v3
82+
with:
83+
java-version: '17'
84+
distribution: 'adopt'
85+
cache: gradle
86+
87+
- name: Cache build artifacts
88+
uses: ./.github/actions/cache-build-paths
89+
with:
90+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
91+
92+
- name: Grant execute permission for gradlew
93+
run: chmod +x gradlew
94+
95+
- name: Assemble
96+
run: ./gradlew randomgenkt:assemble randomgenkt.datasource:assemble
97+
98+
- name: Publish to local maven
99+
run: ./gradlew randomgenkt:publishToMavenLocal randomgenkt.datasource:publishToMavenLocal
100+
101+
- name: Run lint
102+
run: ./gradlew lint --no-daemon

.github/workflows/ktlint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Kotlin-Linter
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
ktlint:
8+
runs-on: macos-latest
9+
steps:
10+
- name: Get changed files
11+
id: changes
12+
run: |
13+
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
14+
RESPONSE=$(curl -s -X GET -G $URL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
15+
CHANGED_KOTLIN_FILES=$(echo $RESPONSE | jq -r '.[] | .filename' | grep -E "\.kt$" | tr \'\\n\' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')
16+
echo "Changed Kotlin files: ${CHANGED_KOTLIN_FILES}"
17+
echo "changed_kotlin_files=${CHANGED_KOTLIN_FILES}" >> $GITHUB_ENV
18+
19+
- name: "checkout"
20+
if: env.changed_kotlin_files != ''
21+
uses: actions/checkout@v4
22+
23+
- name: Install ktlint
24+
if: env.changed_kotlin_files != ''
25+
run: |
26+
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.0.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
27+
28+
- name: run ktlint
29+
if: env.changed_kotlin_files != ''
30+
run: |
31+
ktlint . '!**/build/**'

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
[![Version - RandomGenKt](https://img.shields.io/maven-central/v/com.mitteloupe.randomgenkt/randomgenkt?label=RandomGenKt+|+MavenCentral)](https://mvnrepository.com/artifact/com.mitteloupe.randomgenkt/randomgenkt)
77
[![Version - DataSource](https://img.shields.io/maven-central/v/com.mitteloupe.randomgenkt/randomgenkt.datasource?label=datasource+|+MavenCentral)](https://mvnrepository.com/artifact/com.mitteloupe.randomgenkt/randomgenkt.datasource)
8-
[![Build Status](https://travis-ci.com/EranBoudjnah/RandomGenKt.svg?branch=master)](https://travis-ci.com/EranBoudjnah/RandomGenKt)
8+
![Build Status](https://img.shields.io/github/actions/workflow/status/EranBoudjnah/RandomGenKt/gradle-checks.yml)
99
[![License](https://img.shields.io/github/license/EranBoudjnah/RandomGenKt)](https://github.com/EranBoudjnah/RandomGenKt/blob/master/LICENSE)
1010

1111
![Example](https://github.com/EranBoudjnah/RandomGenKt/raw/master/example/videocap.gif)
@@ -20,14 +20,14 @@ In your `build.gradle`, add the following:
2020

2121
```groovy
2222
dependencies {
23-
implementation("com.mitteloupe.randomgenkt:randomgenkt:1.0.1")
23+
implementation("com.mitteloupe.randomgenkt:randomgenkt:2.0.0")
2424
}
2525
```
2626

2727
To include the default data generators, also include
2828
```groovy
2929
dependencies {
30-
implementation("com.mitteloupe.randomgenkt:randomgenkt.datasource:1.0.1")
30+
implementation("com.mitteloupe.randomgenkt:randomgenkt.datasource:2.0.0")
3131
}
3232
```
3333

@@ -36,7 +36,7 @@ dependencies {
3636
### Kotlin
3737
```kotlin
3838
val randomGen = RandomGen.Builder<ObjectClass>()
39-
.ofClass<ObjectClass>()
39+
.ofKotlinClass<ObjectClass>()
4040
.withField("id")
4141
.returningSequentialInteger()
4242
.withField("uuid")
@@ -47,7 +47,7 @@ val randomGen = RandomGen.Builder<ObjectClass>()
4747
### Java
4848
```java
4949
RandomGen<ObjectClass> randomGen = new RandomGen.Builder<ObjectClass>()
50-
.ofClass(ObjectClass.class)
50+
.ofJavaClass(ObjectClass.class)
5151
.withField("id")
5252
.returningSequentialInteger()
5353
.withField("uuid")
@@ -61,16 +61,22 @@ To use the newly generated `RandomGen`, simply call:
6161

6262
### Kotlin
6363
```kotlin
64-
val instance = randomGen.generate()
64+
val instance = randomGen()
6565
```
6666

6767
### Java
6868
```java
69-
ObjectClass instance = randomGen.generate();
69+
ObjectClass instance = randomGen.invoke();
7070
```
7171

7272
### What's New?
7373

74+
Version 2.0
75+
76+
This is an overhaul of RandomGenKt. It has been dusted, polished and refactored to align with modern conventions.
77+
78+
--
79+
7480
The Kotlin version adds the following:
7581

7682
* Support for fields with lazy init

build.gradle.kts

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,21 @@
1-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent
23

34
plugins {
4-
kotlin("jvm") version "1.3.21"
5-
id("com.github.ben-manes.versions") version "0.38.0"
5+
id("com.android.application") version "8.1.2" apply false
6+
kotlin("android") version "1.9.0" apply false
67
id("io.codearte.nexus-staging") version "0.30.0"
8+
id("com.google.dagger.hilt.android") version "2.48.1" apply false
79
}
810

9-
buildscript {
10-
repositories {
11-
google()
12-
jcenter()
13-
mavenCentral()
14-
maven(url = "https://plugins.gradle.org/m2/")
11+
tasks.withType(Test::class) {
12+
testLogging {
13+
exceptionFormat = TestExceptionFormat.FULL
14+
events = setOf(
15+
TestLogEvent.SKIPPED,
16+
TestLogEvent.PASSED,
17+
TestLogEvent.FAILED
18+
)
19+
showStandardStreams = true
1520
}
16-
dependencies {
17-
classpath("com.android.tools.build:gradle:4.1.3")
18-
classpath(kotlin("gradle-plugin", version = "1.3.61"))
19-
classpath("com.github.ben-manes:gradle-versions-plugin:0.38.0")
20-
classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0")
21-
classpath("com.google.dagger:hilt-android-gradle-plugin:2.34-beta")
22-
}
23-
}
24-
25-
allprojects {
26-
repositories {
27-
google()
28-
jcenter()
29-
mavenCentral()
30-
}
31-
}
32-
33-
dependencies {
34-
implementation(kotlin("stdlib-jdk8"))
35-
}
36-
37-
val compileKotlin: KotlinCompile by tasks
38-
compileKotlin.kotlinOptions {
39-
jvmTarget = "1.6"
40-
}
41-
42-
val compileTestKotlin: KotlinCompile by tasks
43-
compileTestKotlin.kotlinOptions {
44-
jvmTarget = "1.6"
4521
}
46-
47-
val ktlintVerify: JavaExec by tasks.creating(JavaExec::class)
48-
49-
val ktlintFormat: JavaExec by tasks.creating(JavaExec::class)
50-
51-

0 commit comments

Comments
 (0)