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

feat(scala): add some missing highlights #6622

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

ribru17
Copy link
Collaborator

@ribru17 ribru17 commented May 13, 2024

Reference file:

/*
 * Copyright (C) 2009-2023 Lightbend Inc. <https://www.lightbend.com>
 */

package akka

import sbt._
import sbt.Keys._
import java.io.File
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.*

import com.lightbend.sbt.publishrsync.PublishRsyncPlugin.autoImport.publishRsyncHost
import sbt.Def
import com.geirsson.CiReleasePlugin
import com.jsuereth.sbtpgp.PgpKeys.publishSigned

object Publish extends AutoPlugin {

  val defaultPublishTo = settingKey[File]("Default publish directory")

  override def trigger = allRequirements

  lazy val beforePublishTask = taskKey[Unit]("setup before publish")

  lazy val beforePublishDone = new AtomicBoolean(false)

  def beforePublish(snapshot: Boolean) = {
    if (beforePublishDone.compareAndSet(false, true)) {
      CiReleasePlugin.setupGpg()
      if (!snapshot)
        cloudsmithCredentials(validate = true)
    }
  }

  override lazy val projectSettings = Seq(
      publishRsyncHost := "akkarepo@gustav.akka.io",
      organizationName := "Lightbend Inc.",
      organizationHomepage := Some(url("https://www.lightbend.com")),
      startYear := Some(2009),
      developers := List(
          Developer(
            "akka-contributors",
            "Akka Contributors",
            "akka.official@gmail.com",
            url("https://github.com/akka/akka/graphs/contributors"))),
      publishMavenStyle := true,
      pomIncludeRepository := { x =>
        false
      },
      defaultPublishTo := target.value / "repository") ++ publishingSettings

  private lazy val publishingSettings: Seq[Def.Setting[_]] = {
    Def.settings(
      beforePublishTask := beforePublish(isSnapshot.value),
      publishSigned := publishSigned.dependsOn(beforePublishTask).value,
      publishTo := (if (isSnapshot.value)
                      Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka-snapshots/"))
                    else
                      Some("Cloudsmith API".at("https://maven.cloudsmith.io/lightbend/akka/"))),
      credentials ++= cloudsmithCredentials(validate = false))
  }

  def cloudsmithCredentials(validate: Boolean): Seq[Credentials] = {
    (sys.env.get("PUBLISH_USER"), sys.env.get("PUBLISH_PASSWORD")) match {
      case (Some(user), Some(password)) =>
        Seq(Credentials("Cloudsmith API", "maven.cloudsmith.io", user, password))
      case _ =>
        if (validate)
          throw new Exception("Publishing credentials expected in `PUBLISH_USER` and `PUBLISH_PASSWORD`.")
        else
          Nil
    }
  }
}

/**
 * For projects that are not to be published.
 */
object NoPublish extends AutoPlugin {
  override def requires = plugins.JvmPlugin

  override def projectSettings =
    Seq(publish / skip := true, Compile / doc / sources := Seq.empty)
}

@amaanq amaanq merged commit c911f19 into nvim-treesitter:master Jun 15, 2024
9 checks passed
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.

None yet

2 participants