Skip to content
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

Add Rule Logger #1040

Merged
merged 32 commits into from
Nov 19, 2019
Merged

Conversation

ddcruver
Copy link
Contributor

@ddcruver ddcruver commented Nov 5, 2019

No description provided.

…nd assign them to the RuleFactory through the Jsonschema2Pojo#generate method.
…e all together. Now it adds the correct classpathPrefix to import all libraries from a subdirectory lib which is where copy-dependencies puts them and in general that is good practice if you were to distribute this tool.
@ddcruver ddcruver changed the title Feature/add rule logger Add Rule Logger Nov 5, 2019
@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 5, 2019

Opps .. tests need logger now... actually it looks like the test itself maybe failed. Added some mocking to RuleFactory in a few tests. But problem may be elsewhere.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 5, 2019

@joelittlejohn
It looks like the Gradle version (1.6) it builds the code does not match the version (2.3) that is run on the build server. Which version of Gradle should we target? Both versions are ancient.

jsonschema2pojo-cli/pom.xml Outdated Show resolved Hide resolved
jsonschema2pojo-cli/pom.xml Show resolved Hide resolved
jsonschema2pojo-cli/pom.xml Outdated Show resolved Hide resolved
jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bash Outdated Show resolved Hide resolved
jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat Outdated Show resolved Hide resolved
jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.sh Outdated Show resolved Hide resolved
@joelittlejohn
Copy link
Owner

joelittlejohn commented Nov 5, 2019

Strange, I have no idea why it says that this zip file was empty:

org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-2.3-bin.zip'.

When I download this using the same link I don't get an empty file.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

I think the stack trace above it gives more hint at what is going on but still not sure how to fix it.

Are you open to updating the groovy, Gradle, groovy maven plugin to resolve this issue? Or I could just not support logging under the Gradle plugin.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

The gradle plugin project failing is a weird problem because it fails only on the Travis CI server and not a local maven execution of it.

script:
- rm -rf ~/.gradle/wrapper/dists/gradle-2.3-bin
- mvn clean install -DskipTests
- mvn verify
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for install then verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to resolve the build issues and found this commit (81adfe7) and it mentioned that CI tests might be broken unless do a build then do a test build.

@ben-manes Is this unnecessary now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be necessary with the eclipse-groovy-compiler. I will try removing it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That commit comment wrt CI failure was a one-time breakage and no longer relevant. Just required a clean if I recall correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelittlejohn I have already removed the extra build and haven't notice any problems.
@ben-manes Thanks for your input.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think all the changes in this file can be reverted, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the hacky gradle bin and double building stuff from Travis CI configuration but left in the caching.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

@joelittlejohn Since #1041 is also failing I believe this failure is not a result of my changes. Something is broken with the build.

This is a far reach but @ben-manes do you have any insight into this problem?

@ben-manes
Copy link
Collaborator

I believe it is due to not following a redirect. They enforce HTTPS now and their http client probably doesn't have redirect enabled. So maybe a 1 character fix! 😄

$ curl -I http://services.gradle.org/distributions/gradle-2.3-bin.zip
HTTP/1.1 301 Moved Permanently
Date: Wed, 06 Nov 2019 18:58:00 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Wed, 06 Nov 2019 19:58:00 GMT
Location: http://downloads.gradle-dn.com/distributions/gradle-2.3-bin.zip
Server: cloudflare
CF-RAY: 53194be1fed592c8-SJC

ben: lucene-solr $ wget -v http://services.gradle.org/distributions/gradle-2.3-bin.zip
--2019-11-06 10:58:10--  http://services.gradle.org/distributions/gradle-2.3-bin.zip
Resolving services.gradle.org (services.gradle.org)... 104.18.190.9, 104.18.191.9
Connecting to services.gradle.org (services.gradle.org)|104.18.190.9|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://downloads.gradle-dn.com/distributions/gradle-2.3-bin.zip [following]
--2019-11-06 10:58:10--  http://downloads.gradle-dn.com/distributions/gradle-2.3-bin.zip
Resolving downloads.gradle-dn.com (downloads.gradle-dn.com)... 104.17.160.20, 104.17.159.20
Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.17.160.20|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://downloads.gradle-dn.com/distributions/gradle-2.3-bin.zip [following]
--2019-11-06 10:58:10--  https://downloads.gradle-dn.com/distributions/gradle-2.3-bin.zip
Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.17.160.20|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42475057 (41M) [application/zip]
Saving to: ‘gradle-2.3-bin.zip’

gradle-2.3-bin.zip                       100%[==================================================================================>]  40.51M  20.2MB/s    in 2.0s

2019-11-06 10:58:12 (20.2 MB/s) - ‘gradle-2.3-bin.zip’ saved [42475057/42475057]

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

I literally asked you then thought to do that myself. Lets see if it works.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

@ben-manes I also switch back to the groovy-eclipse-compiler, these days which groovy plugin should you use?

I have read lots of write-ups on "which maven plugin/compiler for groovy should I use" but not being a groovy developer I am still not sure what this project should be using. I changed it because I thought it might fix my build/execution issues but it seems like it might of been unrelated now.

@ben-manes
Copy link
Collaborator

I can't answer at that detail. I simply hacked together a few plugins for my needs and contributed them upstream (flyway, js2p, jooq, dependencyUpdates). I learned enough Groovy to write simple build scripts and plugins, but this was Gradle 1.x world (2012). I don't use Groovy otherwise and tried to handoff the plugins since this isn't my area of expertise. I'm happy to be a sounding board but my knowledge is fairly limited and outdated.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

I read that the gmaven(plus) plugins had more features and may support more things but I believe thease are things we don't require, so since the eclipse plugin is an official plugin we should use it instead.

I believe there is other improvements to the jsonschema2pojo-gradle-plugin and maybe it should actually be build with gradle (embedded in our maven) instead but that is out of scope with something I am willing to do right now.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

@joelittlejohn I believe I have responded and/or addressed all your comments and the build looks good now.

@joelittlejohn
Copy link
Owner

Great, thanks for looking at the Gradle build issues. I think we still have a few changes we need to make here, in particular any change that removes ../lib from CLI scripts needs to be reverted. I've added some follow-up comments and unresolved a few conversations.

Also, is there any reason the CLI logger needs to use SLF4J rather than just System.out and System.err? This will never be part of a wider system with its own logging configuration.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 6, 2019

Also, is there any reason the CLI logger needs to use SLF4J rather than just System.out and System.err? This will never be part of a wider system with its own logging configuration.

I guess if this was jsonschema2-pojo-embedded (a fictional module) that would be integrated in another application/system then it should use SLF4J but I agree. Although there would be no way to turn off loggers for CLI if people started using info/debug/trace and it could get quit noisy.

UPDATE: I updated CLI to support command line provided log level.

@REM

@echo off
java -jar "%~dp0/../lib/${project.build.finalName}.jar" %*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your branch is still showing a change in this file from CRLF line endings to LF. Could you maybe git checkout origin/master jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat and commit that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it was CRLF on my machine and source tree wasn't showing any changes. I had to manually remove the file and check it out like you suggested then add it via command line git commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added .bat to the .gitattributes file and renormlized that bat file. It may still show changes because it was original in the git repo as LF.

https://stackoverflow.com/a/47580886/45708

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dan. Everything looks good but this is the last problem in the PR. In master this file uses CRLF (Windows) line endings not LF:

$ file jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat
jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat: DOS batch file, UTF-8 Unicode text, with CRLF line terminators

You can also try vim -b jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat to see the ^M characters.

In your branch (this PR) changes the line endings in this file to LF.

I've actually changed my mind about this .gitattributes file, it's adding more confusion and I don't want git doing anything to change the files under version control. Please remove .gitattributes and also remove your changes to this file (git checkout origin/master jsonschema2pojo-cli/src/main/scripts/jsonschema2pojo.bat). Then we're good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ddcruver
Copy link
Contributor Author

ddcruver commented Nov 7, 2019

@joelittlejohn I am ready for you to take another pass of seeing if this pull request is ready to merge.

@ddcruver
Copy link
Contributor Author

@joelittlejohn I would like to wrap up this pull request and possibly #1041. I would like to write a RuleFactory with a custom EnumRule for my project that has the name fallback resolution as described in #999 and I want it to extend EnumRule instead of re-implementing it.

@joelittlejohn joelittlejohn merged commit 4fa79b5 into joelittlejohn:master Nov 19, 2019
@ddcruver ddcruver deleted the feature/add-rule-logger branch November 19, 2019 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants