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

plugin enhancement #1

Merged
merged 12 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,51 @@ name: Publish

on:
workflow_dispatch:

# can maybe test via https://github.com/nektos/act
# act -s DOCKER_USERNAME=abc -s DOCKER_PASSWORD=xyz --container-architecture linux/arm64 -W .github/workflows/release.yml release
jobs:
release:
runs-on: ubuntu-20.04
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Configure git user to push
run: |
git config --global user.email "[email protected]"
git config --global user.name "sbt"

- name: Clone and checkout to current branch
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set up JDK 11 # it auto caches https://github.com/actions/setup-java#caching-packages-dependencies
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'temurin'
cache: 'sbt'

- name: Publish
run: ./scripts/github-actions/publish.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

# - name: notify build status
# if: always()
# uses: slackapi/[email protected]
# with:
# # Slack channel id, channel name, or user id to post message.
# # See also: https://api.slack.com/methods/chat.postMessage#channels
# # You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs.
# channel-id: ${{ github.event.repository.name }}-cicd
# # For posting a simple plain text message, no md just for link shortening
# slack-message: "${{ steps.build_info.outputs.tubi-project-name }}-v${{ steps.build_info.outputs.tubi-project-version }} release ${{ job.status }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# env:
# SLACK_BOT_TOKEN: ${{ secrets.BUILD_NOTIFY_SLACK_APP_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/project/project/
/project/target/
/target/
/.idea/
/.bsp/
11 changes: 11 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = "3.4.3"
runner.dialect = scala213
preset = IntelliJ
maxColumn = 120
docstrings.style = SpaceAsterisk
docstrings.wrap = "no"
newlines.beforeCurlyLambdaParams = multiline
rewrite.rules = [Imports]
rewrite.imports.sort = scalastyle
rewrite.imports.groups = [["sbt\\..*"], ["java\\..*", "javax\\..*"], ["scala\\..*"]]
rewrite.trailingCommas.style = keep
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/tototoshi/sbt-slick-codegen/actions/workflows/ci.yml/badge.svg)](https://github.com/tototoshi/sbt-slick-codegen/actions/workflows/ci.yml)

slick-codegen compile hook for sbt
slick-codegen plugin, forked from [sbt-slick-codegen](https://github.com/tototoshi/sbt-slick-codegen), which aims to generate code specially for Postgres

## Install

Expand Down
73 changes: 19 additions & 54 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,69 +1,34 @@
import scalariform.formatter.preferences._
import scala.collection.JavaConverters._
import java.lang.management.ManagementFactory

import scala.collection.JavaConverters.*
//import scalariform.formatter.preferences.*

enablePlugins(SbtPlugin)

scalariformPreferences := scalariformPreferences.value
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(DoubleIndentConstructorArguments, true)
.setPreference(DanglingCloseParenthesis, Preserve)
//scalariformPreferences := scalariformPreferences.value
// .setPreference(AlignSingleLineCaseStatements, true)
// .setPreference(DoubleIndentConstructorArguments, true)
// .setPreference(DanglingCloseParenthesis, Preserve)

sbtPlugin := true

name := """sbt-slick-codegen"""

organization := "com.github.tototoshi"

version := "2.0.0"

crossSbtVersions := Seq("1.8.0")

val slickVersion = SettingKey[String]("slickVersion")

slickVersion := "3.3.3"
organization := "com.tubitv"
version := "0.0.1-SNAPSHOT"

libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % slickVersion.value,
"com.typesafe.slick" %% "slick-codegen" % slickVersion.value
"com.typesafe.slick" %% "slick" % Versions.slick,
"com.typesafe.slick" %% "slick-codegen" % Versions.slick,
"org.postgresql" % "postgresql" % Versions.postgresql,
"com.github.docker-java" % "docker-java" % Versions.dockerJava,
)
addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % Versions.flywaySbt)

publishMavenStyle := true

publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

publishTo := Some(if (isSnapshot.value) Repo.Jfrog.Tubins.sbtDev else Repo.Jfrog.Tubins.sbtRelease)
ThisBuild / versionScheme := Some("early-semver")
Test / publishArtifact := false

pomExtra :=
<url>https://github.com/tototoshi/sbt-slick-codegen</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>[email protected]:tototoshi/sbt-slick-codegen</url>
<connection>scm:git:[email protected]:tototoshi/sbt-slick-codegen.git</connection>
</scm>
<developers>
<developer>
<id>tototoshi</id>
<name>Toshiyuki Takahashi</name>
<url>https://tototoshi.github.io</url>
</developer>
</developers>

scriptedBufferLog := false
scriptedLaunchOpts ++= ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList.filter(a =>
Seq("-Xmx", "-Xms", "-XX", "-Dsbt.log.noformat").exists(a.startsWith)
)
scriptedLaunchOpts ++= Seq(
"-Dplugin.version=" + version.value,
"-Dslick.version=" + slickVersion.value
scriptedLaunchOpts ++= ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList.filter(
a => Seq("-Xmx", "-Xms", "-XX", "-Dsbt.log.noformat").exists(a.startsWith)
)
scriptedLaunchOpts ++= Seq("-Dplugin.version=" + version.value, "-Dslick.version=" + Versions.slick)
22 changes: 22 additions & 0 deletions jd-gui.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" ?>
<configuration>
<gui>
<mainWindow>
<location x="213" y="158"></location>
<size w="1302" h="824"></size>
<maximize>true</maximize>
</mainWindow>
<lookAndFeel>com.apple.laf.AquaLookAndFeel</lookAndFeel>
</gui>
<recentFilePaths>
<filePath>/Users/chunsenwang/tubi/sbt-slick-codegen/target/scala-2.12/sbt-1.0/classes/com/github/tototoshi/sbt/slick/CodegenPlugin$.class</filePath>
</recentFilePaths>
<recentDirectories>
<loadPath>/Users/chunsenwang/tubi/sbt-slick-codegen/target/scala-2.12/sbt-1.0/classes/com/github/tototoshi/sbt/slick</loadPath>
<savePath>/Users/chunsenwang/tubi/sbt-slick-codegen</savePath>
</recentDirectories>
<preferences>
<JdGuiPreferences.errorBackgroundColor>0xFF6666</JdGuiPreferences.errorBackgroundColor>
<JdGuiPreferences.jdCoreVersion>1.1.3</JdGuiPreferences.jdCoreVersion>
</preferences>
</configuration>
22 changes: 22 additions & 0 deletions project/Repo.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sbt.*

object Repo {

object Jfrog {
private val domain = "tubins.jfrog.io"
private val jFrogRoot = s"https://$domain"

object Tubins {
private val pathPrefix = "tubins"

lazy val sbtDev: MavenRepository = "sbt-dev" at s"$jFrogRoot/$pathPrefix/sbt-dev"

lazy val sbtRelease: MavenRepository = "sbt-release" at s"$jFrogRoot/$pathPrefix/sbt-release"

lazy val jvmSnapshot: MavenRepository = "jvm-snapshot" at s"$jFrogRoot/$pathPrefix/jvm-snapshots"

lazy val jvm: MavenRepository = "jvm-release" at s"$jFrogRoot/$pathPrefix/jvm"
}
}

}
6 changes: 6 additions & 0 deletions project/Versions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Versions {
val slick = "3.4.0"
val postgresql = "42.6.0"
val dockerJava = "3.3.4"
val flywaySbt = "7.4.0"
}
23 changes: 23 additions & 0 deletions project/artifactory.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ThisBuild / credentials ++= {
val logger = streams.value.log
if (sys.env.contains("ARTIFACTORY_USERNAME")) {
logger.info("spotted credential in env, will add to credentials")
Some(
Credentials(
"Artifactory Realm",
"tubins.jfrog.io",
sys.env.getOrElse("ARTIFACTORY_USERNAME", ""),
sys.env.getOrElse("ARTIFACTORY_PASSWORD", "")
)
)
} else {
Credentials.loadCredentials(Path.userHome / ".artifactory" / "credentials") match {
case Right(credentials: DirectCredentials) =>
logger.info(s"Using credentials found in the home directory for host ${credentials.host}")
Some(credentials)
case Left(err: String) =>
logger.warn(s"Could not find artifactory credentials in home directory: $err")
None
}
}
}
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.18")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
//addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
//addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.18")
//addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
4 changes: 4 additions & 0 deletions scripts/github-actions/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

SBT_JVM_OPTS="-J-Xms4g -J-Xmx4g -J-Xss8m -J-XX:MaxMetaspaceSize=1024m -J-XX:+UseG1GC"
sbt $SBT_JVM_OPTS publish

Choose a reason for hiding this comment

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

u dont need this

Loading
Loading