Skip to content

Commit

Permalink
fork init
Browse files Browse the repository at this point in the history
 Author:    梦境迷离 <[email protected]>
 Date:      Sat Oct 7 10:45:58 2023 +0800
  • Loading branch information
李国斌 authored and jxnu-liguobin committed Oct 7, 2023
1 parent 53916e2 commit 8bd3657
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 251 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/ScalaCI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches:
- master
tags: [ "*" ]
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 11 ]
steps:
- uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- name: Cache scala dependencies
uses: coursier/cache-action@v6

- name: Checking Code style
run: sbt check

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Run Test
if: success() || failure()
run: sbt coverage test

- name: Aggregate coverage report
run: sbt coverageAggregate

- name: Upload test coverage report
run: bash <(curl -s https://codecov.io/bash)

publish:
runs-on: ubuntu-latest
needs: [ check ]
if: github.event_name != 'pull_request'
steps:
- name: Checkout current branch
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Release artifacts
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

ci:
runs-on: ubuntu-latest
needs: [ check, test ]
steps:
- name: Aggregate outcomes
run: echo "build succeeded"
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version = "3.7.13"
runner.dialect = scala3
maxColumn = 120
align.preset = more
lineEndings = preserve
align.stripMargin = false
docstrings.style = AsteriskSpace
docstrings.oneline = keep
continuationIndent.defnSite = 2
danglingParentheses.preset = true
spaces.inImportCurlyBraces = true
indentOperator.exemptScope = aloneArgOrBody
includeCurlyBraceInSelectChains = false
align.openParenDefnSite = false
optIn.annotationNewlines = true
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
rewrite.rules = [Imports]
rewrite.imports.sort = scalastyle
rewrite.imports.groups = [
["java\\..*", "javax\\..*"],
["scala\\..*"]
["bitlap\\..*"],
["org\\..*"],
["com\\..*"],
]
rewrite.imports.contiguousGroups = no
newlines.topLevelStatementBlankLines = [
{
blanks {before = 1}
}
]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# sbt-kotlin-plugin

[![Build Status](https://travis-ci.org/pfn/sbt-kotlin-plugin.svg?branch=master)](https://travis-ci.org/pfn/sbt-kotlin-plugin)
[![Build Status](https://github.com/bitlap/kotlin-plugin/actions/workflows/ScalaCI.yml/badge.svg)]

Build kotlin code using sbt

Current version 2.0.0
Current version 4.0.0

## Install
```
addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % "3.0.1")
addSbtPlugin("org.bitlap" % "sbt-kotlin-plugin" % "4.0.0")
```

## Usage
Expand Down
64 changes: 40 additions & 24 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
name := "sbt-kotlin-plugin"

organization := "community.flock.sbt"

version := "3.0.1"

scalacOptions ++= Seq("-deprecation","-Xlint","-feature")

libraryDependencies ++= Seq(
"io.argonaut" %% "argonaut" % "6.2",
"org.scalaz" %% "scalaz-core" % "7.2.28"
addCommandAlias("fmt", "scalafmt")
addCommandAlias("check", "scalafmtCheckAll")

inThisBuild(
List(
organization := "org.bitlap",
organizationName := "sbt-kotlin-plugin",
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
homepage := Some(url("https://github.com/bitlap/kotlin-plugin")),
licenses := List(
"MIT" -> url("https://opensource.org/licenses/MIT")
),
developers := List(
Developer(
id = "jxnu-liguobin",
name = "梦境迷离",
email = "[email protected]",
url = url("https://blog.dreamylost.cn")
)
)
)
)

sbtPlugin := true

// build info plugin

enablePlugins(BuildInfoPlugin, SbtPlugin)

buildInfoPackage := "kotlin"

// scripted
scriptedLaunchOpts ++= Seq(
"-Xmx1024m",
"-Dplugin.version=" + version.value
)
lazy val `sbt-kotlin-plugin` = (project in file("."))
.settings(
name := "sbt-kotlin-plugin",
organization := "org.bitlap",
scalacOptions ++= Seq("-deprecation", "-Xlint", "-feature"),
libraryDependencies ++= Seq(
"io.argonaut" %% "argonaut" % "6.2",
"org.scalaz" %% "scalaz-core" % "7.2.28"
),
sbtPlugin := true,
buildInfoPackage := "kotlin",
// scripted
scriptedLaunchOpts ++= Seq(
"-Xmx1024m",
"-Dplugin.version=" + version.value
)
)
.enablePlugins(BuildInfoPlugin, SbtPlugin)
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
34 changes: 0 additions & 34 deletions publish.sbt

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/scala/Keys.scala

This file was deleted.

35 changes: 21 additions & 14 deletions src/main/scala/KotlinTest.scala
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
package sbt

import sbt.Keys.*
import sbt.internal.inc.*
import sbt.internal.inc.classfile.JavaAnalyze
import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.inc.*
import xsbti.{VirtualFile, VirtualFileRef}
import xsbti.{ VirtualFile, VirtualFileRef }
import xsbti.compile.*

object KotlinTest {

private object EmptyLookup extends Lookup {
def changedClasspathHash: Option[Vector[FileHash]] = None

def analyses: Vector[CompileAnalysis] = Vector.empty
def lookupOnClasspath(binaryClassName: String): Option[VirtualFileRef] = None
def lookupAnalysis(binaryClassName: String): Option[CompileAnalysis] = None
def analyses: Vector[CompileAnalysis] = Vector.empty
def lookupOnClasspath(binaryClassName: String): Option[VirtualFileRef] = None
def lookupAnalysis(binaryClassName: String): Option[CompileAnalysis] = None
def changedBinaries(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[VirtualFileRef]] = None
def changedSources(previousAnalysis: xsbti.compile.CompileAnalysis): Option[xsbti.compile.Changes[VirtualFileRef]] = None

def changedSources(previousAnalysis: xsbti.compile.CompileAnalysis): Option[xsbti.compile.Changes[VirtualFileRef]] =
None
def removedProducts(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[VirtualFileRef]] = None
def shouldDoIncrementalCompilation(changedClasses: Set[String],analysis: xsbti.compile.CompileAnalysis): Boolean = true
override def hashClasspath(classpath: Array[VirtualFile]): java.util.Optional[Array[FileHash]] = java.util.Optional.empty()

def shouldDoIncrementalCompilation(changedClasses: Set[String], analysis: xsbti.compile.CompileAnalysis): Boolean =
true

override def hashClasspath(classpath: Array[VirtualFile]): java.util.Optional[Array[FileHash]] =
java.util.Optional.empty()
}

val kotlinTests = Def.task {
val out = ((Test / target).value ** "scala-*").get.head / "test-classes"
val out = ((Test / target).value ** "scala-*").get.head / "test-classes"
val srcs = ((Test / sourceDirectory).value ** "*.kt").get.map(f => PlainVirtualFile(f.toPath())).toList
val xs = (out ** "*.class").get.toList
val xs = (out ** "*.class").get.toList

val loader = ClasspathUtil.toLoader((Test / fullClasspath).value map {
_.data
Expand All @@ -37,7 +44,7 @@ object KotlinTest {

val so = (Test / scalacOptions).value
val jo = (Test / javacOptions).value
val c = (Test / compile).value
val c = (Test / compile).value

val incremental = Incremental(
srcs.toSet,
Expand All @@ -59,14 +66,14 @@ object KotlinTest {
None,
None,
None,
log,
log
)((_, _, callback, _) => {
def readAPI(source: VirtualFileRef, classes: Seq[Class[_]]): Set[(String, String)] = {
val (apis, mainClasses, inherits) = ClassToAPI.process(classes)
apis.foreach(callback.api(source, _))
mainClasses.foreach(callback.mainClass(source, _))
inherits.map {
case (from, to) => (from.getName, to.getName)
inherits.map { case (from, to) =>
(from.getName, to.getName)
}
}
JavaAnalyze(
Expand Down
Loading

0 comments on commit 8bd3657

Please sign in to comment.