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

Generate the cli as a stand alone executable #2607

Merged
merged 2 commits into from
Apr 18, 2020
Merged

Generate the cli as a stand alone executable #2607

merged 2 commits into from
Apr 18, 2020

Conversation

BraisGabin
Copy link
Member

Fixes #2605

Now if we run ./gradlew shadowJarExecutable we can execute detekt like this: ./detekt-cli/build/run/detek. So, if we publish this file in each new release, we can help the users how to install/update detekt.

Problem: I think that this only work on UNIX. I didn't update the documentation for this reason. I don't know how many people uses windows CMD now a days... ktlint ignores this fact completely as you can check here: https://ktlint.github.io/ should we do it too? Or we can say somthing like:

Unix: ./detekt
Windows: java -jar detekt

What do you think?

@codecov-io
Copy link

codecov-io commented Apr 14, 2020

Codecov Report

Merging #2607 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2607      +/-   ##
============================================
- Coverage     25.29%   25.28%   -0.01%     
  Complexity      396      396              
============================================
  Files           379      379              
  Lines          7437     7438       +1     
  Branches       1225     1225              
============================================
  Hits           1881     1881              
- Misses         5427     5428       +1     
  Partials        129      129              
Impacted Files Coverage Δ Complexity Δ
...n/kotlin/io/gitlab/arturbosch/detekt/api/Entity.kt 62.50% <0.00%> (-4.17%) 0.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dba20e7...6d6f24f. Read the comment docs.

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

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

I'm okay with it. Let's wait for Artur's review and for potential 3rd party comments.

@cortinico
Copy link
Member

So, if we publish this file in each new release, we can help the users how to install/update detekt.

Would it be useful to expose the .jar as an artifact of the Github Action run?

@BraisGabin
Copy link
Member Author

Would it be useful to expose the .jar as an artifact of the Github Action run?

I don't know exctly how the github releases work. Or what "expose the .jar" means exactly. But I think that we should post this executable for each release at github. And expose all the jars of a PR and master/snapshots would be great for the early adaopters.

@cortinico
Copy link
Member

I don't know exctly how the github releases work. Or what "expose the .jar" means exactly.

Github Actions allows to "attach" one or more artifact for every build.
Example here https://github.com/cortinico/kscript-template/actions/runs/74006424 this run has a binary artifact.

More context here https://github.com/marketplace/actions/upload-artifact

@arturbosch
Copy link
Member

arturbosch commented Apr 16, 2020

Isn't this the same thing the application plugin builds us? A zip containing all jars and executables for windows and unix?
Run gradle shadowJar and then see detekt/detekt-cli/build/distributions/detekt-cli-1.7.4.zip.

Our installation instruction could look like:

curl detekt-cli.zip
unzip detekt-cli.zip
alias detekt = <path>/detekt-cli/bin/detekt.[sh|bat]

@BraisGabin
Copy link
Member Author

Oh! i didn't know about that zip. Yeah. This PR do something similar but not the same. That zip contains an "installation": the binaries and the libs. With this we have a stand alone executable.

I wanted to merge this to make it easy to add detekt to homebrew. If we have that file I don't care that much about this. But anyway I think that for a user that just want to download detekt and use it the stand-alone executable is more handy.

My ultimate idea is to have something like this:

How to install detekt:

  • brew (MacOS):
    brew install detekt
    detekt
  • chocolatey (Windows):
    I have no idea how you install things in chocolatey but some command here
    detekt
  • Unix:
    curl url/version/detekt && chmod +x detekt
    ./detekt
  • Other option
    curl url/version/detekt.zip && unzip detekt.zip
    ./bin/detekt

This PR will help with the "Unix" part. But we don't really need that one if you don't like it.

group = "Distribution"

inputs.files(tasks.named("shadowJar"))
outputs.file("$buildDir/run/detekt")
Copy link
Member

Choose a reason for hiding this comment

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

Please add this path to the githubRelease part so we upload this immediately in the next release :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I'll create another PR updating the documentation.

Copy link
Member

@arturbosch arturbosch left a comment

Choose a reason for hiding this comment

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

Ah, sorry for the wait. Now I understood what it really does xD

@arturbosch arturbosch added this to the 1.8.0 milestone Apr 18, 2020
@arturbosch arturbosch merged commit 35068c1 into detekt:master Apr 18, 2020
@ZacSweers
Copy link
Contributor

favor to ask - for github releases, the last few have not had consistent naming, which prevents users from reliable downloading. Could you commit to using a standard naming scheme?

@arturbosch
Copy link
Member

@ZacSweers you mean the v in front of the version?
We began using the github release plugin which has this pattern by default.
I will leave it that way.

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.

Distribute cli as an executable file
6 participants