DiUS / java-faker

Brings the popular ruby faker gem to Java
http://dius.github.io/java-faker
Other
4.69k stars 842 forks source link

org.yaml:snakeyaml dependency is giving an error because 'android' classifier #327

Open yolave opened 5 years ago

yolave commented 5 years ago

In the pom.xml file, the declared dependency for org.yaml:snakeyaml has the 'android' classifier so, when a project compiles, it gets an error because the name of the library who is tried to be downloaded (from jcenter: https://jcenter.bintray.com/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar, from maven central: https://repo1.maven.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar). My project is a normal java one (not android) and i'm using Gradle instead Maven.

Thank you!

Outpox commented 5 years ago

Same issue here :-/

vijayanandnandam commented 5 years ago

I have also encountered this issue. please fix. I am using this library in a spring boot project

Task :compileTestJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find snakeyaml-android.jar (org.yaml:snakeyaml:1.17).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17-android.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
yolave commented 5 years ago

For all those reporting the same issue, i did configure my project to avoid this problem. Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' } implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

codingricky commented 5 years ago

Which version of java-faker are you using? The latest version uses snake-yaml 1.20 which is resolvable.

yolave commented 5 years ago

In my case, i'm using the version 0.14. The POM file for this release has the snake-yaml 1.19 with the classifier "android", so Gradle or Maven can't find the library in any remote repository.

Here's an extract from the POM file for the release version 0.14 of Java-Faker:

<dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>1.19</version> <classifier>android</classifier> </dependency>

vijayanandnandam commented 5 years ago

For all those reporting the same issue, i did configure my project to avoid this problem. Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' } implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

This works..

codingricky commented 5 years ago

@yolave could you use the latest version 0.16 and see if you've get the same error?

Thanks

yolave commented 5 years ago

OK @codingricky , i've performed some tests over my project changing the library version. What i've found is there are two problems with the mentioned library above.

The first problem is with the org.yaml:snakeyaml:1.17 library. This library is used in other projects like Spring Boot (1.5.9-RELEASE) and Google Cloud Appengine Plugin (0.3.9) and they eventually replace the version defined by java-faker when build. When i run the gradle --dependencies command, i get this:

default - Configuration for default artifacts. +--- com.github.javafaker:javafaker:0.16 | +--- org.apache.commons:commons-lang3:3.5 -> 3.7 | +--- org.yaml:snakeyaml:1.20 -> 1.17 | \--- com.github.mifmif:generex:1.0.2 | \--- dk.brics.automaton:automaton:1.11-8 \--- project :reelder-dom \--- project :reelder-utils \--- org.apache.commons:commons-lang3:3.7

Another library is overwriting the default version of the dependency used by java-faker (1.20 -> 1.17). I've tried to force to use the defined version of the library in java-faker's pom but with no success. Suggestions will be accepted to try to fix this.

The second problem is related to the library itself. where the classifier is defined in the project's pom file. As i posted above, the pom.xml for the java-faker project has the <classifier>android</classifier> tag, so, even if the first problem described above is fixed, when a project will compile, gradle would try to use/download the library snakeyaml-1.20-android.jar, which does not exist in any remote repository.

If you need any other test, drop me a comment and I'll try to help out.

yolave commented 5 years ago

UPDATE

I perform a new test and i found what is going on. My project is a spring boot type one, so i have in the root build.gradle file, the option to apply the spring boot plugin (apply plugin: 'org.springframework.boot') to all the subprojects. With this, if any sub project is using a specific library version used by others libraries, they will be overwritten by the defined by the spring boot plugin. This would be fixed forcing to use the defined version in the transient libraries, however, i have not had any luck with this. By the way, the snakeyaml added the android classifier library to jcenter since the version 1.18, so any reference to a lower version will fail when try to download it. That's the reason why my project is trying to download the snakeyaml-1.17-android.jar and fails.

dimalusa commented 5 years ago

Same issue ! :'(

ArtRoman commented 4 years ago

For all those reporting the same issue, i did configure my project to avoid this problem. Simply, go to your build.gradle file, exclude the problematic dependency and then add it again:

implementation ('com.github.javafaker:javafaker:0.14') { exclude module: 'org.yaml' } implementation group: 'org.yaml', name: 'snakeyaml', version: '1.17'

You should exclude library by artifact, not by group. In my case correct line is { exclude module: 'snakeyaml' }

Samyssmile commented 4 years ago

This solved it for me

implementation ('com.github.javafaker:javafaker:1.0.2') { exclude module: 'org.yaml' } implementation group: 'org.yaml', name: 'snakeyaml', version: '1.26'

But dirty workaround anyway.

RockyMM commented 4 years ago

@Samyssmile what you did should be solved with #470

SonaliSammy commented 3 years ago

This issue is fixed with version 0.18 of Javafaker

vinz486 commented 3 years ago

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

SonaliSammy commented 3 years ago

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

i checked with Javafaker 1.0.2 version after your message. I don't get issue in that version even. i was facing issue with javafaker 0.14. with Upgrade my problem got resolved. Javafaker 1.0.2 they use both snakyaml 1.2.3 and snakeyaml 1.2.3-android.

vinz486 commented 3 years ago

Hi, try to include javafaker as lib in another lib. Then try to use that lib in a project referencing it by maveLocal.

Gradle complains about missing snakeyaml android: probably the fix is not working using Gradle on maven local.

Bye.

Il giorno mar 24 nov 2020 alle ore 01:36 Sonali Das < notifications@github.com> ha scritto:

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

i checked with Javafaker 1.0.2 version after your message. I don't get issue in that version even. i was facing issue with javafaker 0.14. with Upgrade my problem got resolved. Javafaker 1.0.2 they use both snakyaml 1.2.3 and snakeyaml 1.2.3-android.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DiUS/java-faker/issues/327#issuecomment-732507453, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATA4NI6HKQAGLVSF7LSXXDSRL5ZXANCNFSM4GAJ7FZQ .

--

Mentire al software non è mai una buona idea.

RockyMM commented 3 years ago

@vinz486 , please make a sample project where your problem could be reproduced.

saphemmy commented 3 years ago

This issue is fixed with version 0.18 of Javafaker

I'm still having this issue with javafaker 1.0.2

i checked with Javafaker 1.0.2 version after your message. I don't get issue in that version even. i was facing issue with javafaker 0.14. with Upgrade my problem got resolved. Javafaker 1.0.2 they use both snakyaml 1.2.3 and snakeyaml 1.2.3-android.

0.18 works Using maven

Mahoney commented 2 years ago

I've suddenly got this issue because a different dependency brought in org.yaml:snakeyaml:1.30 transitively, and gradle's dependency resolution combines that with java-faker's android classifier to produce a dependency on org.yaml:snakeyaml:1.30-android - which doesn't exist:

> Could not find snakeyaml-1.30-android.jar (org.yaml:snakeyaml:1.30).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.30/snakeyaml-1.30-android.jar

I checked out this project and it builds fine if I remove <classifier>android</classifier> from the snakeyaml dependency.

bodiam commented 2 years ago

@Mahoney'm this has been fixed in Datafaker, an active clone of this repo with most of not all issues fixed.

Mahoney commented 2 years ago

@bodiam thanks - I'll consider migrating to datafaker. net.datafaker:datafaker, presumably?

In the meantime, this works as a way to strip the android classifier:

configurations.all {
  resolutionStrategy.eachDependency { details ->
    if (details.requested.module.toString() == 'org.yaml:snakeyaml') {
      details.artifactSelection {
        it.selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
      }
    }
  }
}
debop commented 2 years ago

@Mahoney Thanks your suggestion. it works.

this is kotlin-dsl port

    configurations.all {
        resolutionStrategy.eachDependency {
            if(requested.module.toString() == "org.yaml:snakeyaml") {
                artifactSelection {
                    selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
                }
            }
        }
    }
RyoSaeba06 commented 2 years ago

Hi there, I got the issue Could not find snakeyaml-1.30-android.jar (org.yaml:snakeyaml:1.30). Searched in the following locations: https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.30/snakeyaml-1.30-android.jar with spring boot 2.7.1 but working well with spring boot 2.6.2

bodiam commented 2 years ago

@RyoSaeba06 this if a known issue. The recommendation is to use Datafaker.net, a maintained fork of this library

pathiec92 commented 7 months ago

If you are using gradle-kotlin, use the below code to resolve this issue.

implementation("com.github.javafaker:javafaker:1.0.2"){ exclude ( "org.yaml") } implementation (group= "org.yaml", name= "snakeyaml", version= "2.0")

phuongnq commented 1 week ago

I'm using gradle-groovy and the following work for me:

implementation ('com.github.javafaker:javafaker:1.0.2') {
    exclude group: 'org.yaml', module: 'snakeyaml'
  }