Code Monkey home page Code Monkey logo

Comments (7)

matthewfarwell avatar matthewfarwell commented on June 22, 2024

I'm reluctant to start adding authentication to the scalastyle plugin. Apart from it being a lot of new options (username/password, basic/digest, should we ignore certificate problems, etc. etc.), I don't think it fits. You can always make the scalastyle task dependent upon another task - this would probably give you what you need.

from scalastyle-sbt-plugin.

le-doude avatar le-doude commented on June 22, 2024

That is what I am doing

lazy val updateScalaStyle = taskKey[Unit]("updateScalaStyle")

lazy val refreshConfFile: Long = 24 * 60 * 60 * 1000

updateScalaStyle := {
  val conf = file("scalastyle-config.xml")
  if (!conf.exists() || (new Date().getTime - conf.lastModified()) > refreshConfFile){
    val oauthToken = "<MYTOKEN>"
    val configFileUrl = "https://raw.githubusercontent.com/user/repo/branch/path/scalastyle-config.xml"
    val result: Int = s"curl -u $oauthToken:x-oauth-basic $configFileUrl -O" !
  }else{
    println("No need to update")
  }
}

(scalastyle in Compile) <<= (scalastyle in Compile) dependsOn updateScalaStyle

(scalastyle in Test) <<= (scalastyle in Test) dependsOn updateScalaStyle

I plan on adding a call to the github api to check if it has been updated instead of the 24 hours expiry. But the gist of it is here.

from scalastyle-sbt-plugin.

matthewfarwell avatar matthewfarwell commented on June 22, 2024

Could you perhaps raise a PR to add this to the docs? If not, I will do it

https://github.com/scalastyle/scalastyle.github.com/blob/master/sbt.markdown

from scalastyle-sbt-plugin.

2rs2ts avatar 2rs2ts commented on June 22, 2024

@le-doude Are you using personal access tokens for your solution? It'd be nice to have something that "just works" with enterprise github too.

from scalastyle-sbt-plugin.

le-doude avatar le-doude commented on June 22, 2024

@2rs2ts
Here is the final version I am using to get file from a github private repo. It works fine and the speed is quite fast in the scalastyle conf case. I tried comparing sha using github API v3 but it was slower (it became 2 calls on update needed) or same speed (when non need to update) at most so I just update the file every single time.
BTW I .gitignore the file so that everybody in the project is up to date all the time on the scalastyle rules.

https://gist.github.com/8d17f8355138bea4d7a5.git

@matthewfarwell sure

from scalastyle-sbt-plugin.

2rs2ts avatar 2rs2ts commented on June 22, 2024

@le-doude Using .gitignore works but if you use the current download option the file gets downloaded to target/scalastyle-config.xml and the plugin uses that file instead. When you go to issue a PR for this feature you can have the plugin continue to take advantage of that. Then you will also be able to use the scalastyleConfigRefreshHours setting, which I admit isn't as nice as using the github API, but it will work for non-github users!

from scalastyle-sbt-plugin.

matthewfarwell avatar matthewfarwell commented on June 22, 2024

Tidying the issues list, closing this issue. If this is still a problem, please reopen or raise another issue.

from scalastyle-sbt-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.