Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin-faker 2.0 - Breaking Changes #220

Closed
serpro69 opened this issue Feb 18, 2024 · 1 comment
Closed

kotlin-faker 2.0 - Breaking Changes #220

serpro69 opened this issue Feb 18, 2024 · 1 comment
Labels
docs 📃 Documentation-related issues
Milestone

Comments

@serpro69
Copy link
Owner

serpro69 commented Feb 18, 2024

This issue describes breaking changes that are coming in the next major version of kotlin-faker for easier migration.

Note that this issue serves for informational purposes only, and hence the conversation will be locked. If you've started using the new version of faker and face any problems or have any suggestions - please open a new issue.

Multi-Faker Implementation

Currently, the most notable change is described in #217 and implemented in #219 , which can break compilation for many calls to Faker.

In short, if you've been using a lot of different data providers from Faker, it is likely that some of them won't be there anymore in the "core faker" implementation. This includes data providers in the domains like books, tv shows, movies, music, sports and many others.

To keep using those, you will need to add one or more extra fakers via new dependencies and fix the imports and add new faker objects to access those providers.

Below is the list of all available fakers' dependencies (note that the default faker is needed for others to work as they won't pull it as a transitive dependency):

    implementation("io.github.serpro69:kotlin-faker:2.0.0-rc.1") // NB! this is always needed
    implementation("io.github.serpro69:kotlin-faker-books:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-commerce:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-creatures:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-edu:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-games:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-humor:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-japmedia:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-lorem:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-misc:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-movies:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-music:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-sports:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-tech:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-travel:2.0.0-rc.1")
    implementation("io.github.serpro69:kotlin-faker-tvshows:2.0.0-rc.1")

If you have been using faker {} dsl function to create instances of Faker, each faker implementation also has such a function with the same name. Mind the package names though if using multiple ones in the same file.

Below is a simple example of using all the available fakers:

import io.github.serpro69.kfaker.faker
import io.github.serpro69.kfaker.books.faker as books
import io.github.serpro69.kfaker.commerce.faker as commerce
import io.github.serpro69.kfaker.creatures.faker as creatures
import io.github.serpro69.kfaker.edu.faker as edu
import io.github.serpro69.kfaker.games.faker as games
import io.github.serpro69.kfaker.humor.faker as humor
import io.github.serpro69.kfaker.japmedia.faker as japmedia
import io.github.serpro69.kfaker.lorem.faker as lorem
import io.github.serpro69.kfaker.misc.faker as misc
import io.github.serpro69.kfaker.movies.faker as movies
import io.github.serpro69.kfaker.music.faker as music
import io.github.serpro69.kfaker.sports.faker as sports
import io.github.serpro69.kfaker.tech.faker as tech
import io.github.serpro69.kfaker.travel.faker as travel
import io.github.serpro69.kfaker.tv.faker as tv

fun main() {
    val f = faker {}
    val books = books { }
    val commerce = commerce { }
    val creatures = creatures { }
    val edu = edu { }
    val games = games { }
    val humor = humor { }
    val japmedia = japmedia { }
    val lorem = lorem { }
    val misc = misc { }
    val movies = movies { }
    val music = music { }
    val sports = sports { }
    val tech = tech { }
    val travel = travel { }
    val tv = tv { }

    repeat(100) {
        println(f.name.name())
        println(books.book.author())
        println(commerce.commerce.vendor())
        println(creatures.cat.name())
        println(edu.job.field())
        println(games.game.title())
        println(humor.funnyName.name())
        println(japmedia.naruto.eyes())
        println(lorem.lorem.words())
        println(misc.artist.names())
        println(movies.movie.title())
        println(music.music.albums())
        println(sports.eSport.games())
        println(tech.app.name())
        println(travel.nation.language())
        println(tv.archer.quotes())
    }
}

Note

More details on the new Data Providers structure can be found in the docs

@serpro69 serpro69 added the docs 📃 Documentation-related issues label Feb 18, 2024
@serpro69 serpro69 added this to the 2.0.0 milestone Feb 18, 2024
@serpro69 serpro69 pinned this issue Feb 18, 2024
Repository owner locked as off-topic and limited conversation to collaborators Feb 19, 2024
@serpro69
Copy link
Owner Author

serpro69 commented Mar 23, 2024

Versioning Changes

From 637498b (release v2.0.0-rc.2 onwards), each kotlin-faker-* module is versioned separately (ref: #225), and released only when the corresponding submodule has changes between last version and next release. This means that at a given time kotlin-faker-books:2.1.0 and kotlin-faker-tvshows:2.3.0 might be latest versions, respectively, while koltin-faker could also be a different version (minor and patch only!)

  • After initial release 2.0.0, all the submodules should compatible with the same major version of "core" kotlin-faker library, meaning that e.g. it should be possible to use kotlin-faker:2.\d+.\d+ with kotlin-faker-tvshows:2.3.0 and kotlin-faker-books:2.1.0, and so on.
  • Add BOM to manage dependencies #224 should also help to keep versions in sync, once implemented.
  • All major version bumps are applied to modules according to semver rules, since it will contain breaking changes that will likely affect everything.

@serpro69 serpro69 converted this issue into discussion #236 May 11, 2024
@serpro69 serpro69 unpinned this issue May 11, 2024
@serpro69 serpro69 pinned this issue May 11, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
docs 📃 Documentation-related issues
Projects
None yet
Development

No branches or pull requests

1 participant