diff --git a/.gitignore b/.gitignore index 2f7896d..ab056aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.bsp/ target/ diff --git a/build.sbt b/build.sbt index 44e73e1..759f204 100644 --- a/build.sbt +++ b/build.sbt @@ -1,11 +1,56 @@ -sbtPlugin := true +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -name := "sbt-antlr4" +ThisBuild / organization := "com.simplytyped" +ThisBuild / version := "0.8.3" -organization := "com.simplytyped" +lazy val root = (project in file(".")) + .enablePlugins(SbtPlugin) + .settings( + name := "sbt-antlr4", + pluginCrossBuild / sbtVersion := { + scalaBinaryVersion.value match { + case "2.12" => "1.1.6" + } + } + ) -version := "0.8.3" +ThisBuild / publishTo := { + val nexus = "https://s01.oss.sonatype.org/" + if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") + else Some("releases" at nexus + "service/local/staging/deploy/maven2") +} +ThisBuild / publishMavenStyle := true +ThisBuild / credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credentials") -bintrayOrganization := Some("simplytyped") - -licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")) +ThisBuild / developers := List( + Developer( + id = "ihji", + name = "Heejong Lee", + email = "@heejongl", + url = url("https://github.com/ihji") + ) +) +ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")) +ThisBuild / homepage := Some(url("https://github.com/ihji/sbt-antlr4")) +ThisBuild / scmInfo := Some( + ScmInfo( + url("https://github.com/ihji/sbt-antlr4"), + "scm:git@github.com:ihji/sbt-antlr4.git" + ) +) diff --git a/project/bintray.sbt b/project/bintray.sbt deleted file mode 100644 index 945dd61..0000000 --- a/project/bintray.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") diff --git a/project/build.properties b/project/build.properties index c0bab04..e67343a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.5.0 diff --git a/project/pgp.sbt b/project/pgp.sbt new file mode 100644 index 0000000..2a64bd2 --- /dev/null +++ b/project/pgp.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") diff --git a/src/main/scala/com/simplytyped/Antlr4Plugin.scala b/src/main/scala/com/simplytyped/Antlr4Plugin.scala index 3cdabd6..e602294 100644 --- a/src/main/scala/com/simplytyped/Antlr4Plugin.scala +++ b/src/main/scala/com/simplytyped/Antlr4Plugin.scala @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.simplytyped import sbt._ @@ -23,13 +41,13 @@ object Antlr4Plugin extends AutoPlugin { private val antlr4BuildDependency = settingKey[ModuleID]("Build dependency required for parsing grammars, scoped to plugin") def antlr4GeneratorTask : Def.Initialize[Task[Seq[File]]] = Def.task { - val targetBaseDir = (javaSource in Antlr4).value - val classpath = (managedClasspath in Antlr4).value.files + val targetBaseDir = (Antlr4 / javaSource).value + val classpath = (Antlr4 / managedClasspath).value.files val log = streams.value.log - val packageName = (antlr4PackageName in Antlr4).value - val listenerOpt = (antlr4GenListener in Antlr4).value - val visitorOpt = (antlr4GenVisitor in Antlr4).value - val warningsAsErrorOpt = (antlr4TreatWarningsAsErrors in Antlr4).value + val packageName = (Antlr4 / antlr4PackageName).value + val listenerOpt = (Antlr4 / antlr4GenListener).value + val visitorOpt = (Antlr4 / antlr4GenVisitor).value + val warningsAsErrorOpt = (Antlr4 / antlr4TreatWarningsAsErrors).value val cachedCompile = FileFunction.cached(streams.value.cacheDirectory / "antlr4", FilesInfo.lastModified, FilesInfo.exists) { in : Set[File] => runAntlr( @@ -43,7 +61,7 @@ object Antlr4Plugin extends AutoPlugin { warningsAsErrorOpt = warningsAsErrorOpt ) } - cachedCompile(((sourceDirectory in Antlr4).value ** "*.g4").get.toSet).toSeq + cachedCompile(((Antlr4 / sourceDirectory).value ** "*.g4").get.toSet).toSeq } def runAntlr( @@ -69,8 +87,8 @@ object Antlr4Plugin extends AutoPlugin { } override def projectSettings = inConfig(Antlr4)(Seq( - sourceDirectory := (sourceDirectory in Compile).value / "antlr4", - javaSource := (sourceManaged in Compile).value / "antlr4", + sourceDirectory := (Compile / sourceDirectory).value / "antlr4", + javaSource := (Compile / sourceManaged).value / "antlr4", managedClasspath := Classpaths.managedJars(configuration.value, classpathTypes.value, update.value), antlr4Version := "4.8-1", antlr4Generate := antlr4GeneratorTask.value, @@ -83,11 +101,11 @@ object Antlr4Plugin extends AutoPlugin { antlr4TreatWarningsAsErrors := false )) ++ Seq( ivyConfigurations += Antlr4, - managedSourceDirectories in Compile += (javaSource in Antlr4).value, - sourceGenerators in Compile += (antlr4Generate in Antlr4).taskValue, + Compile / managedSourceDirectories += (Antlr4 / javaSource).value, + Compile / sourceGenerators += (Antlr4 / antlr4Generate).taskValue, watchSources += new Source(sourceDirectory.value, "*.g4", HiddenFileFilter), - cleanFiles += (javaSource in Antlr4).value, - libraryDependencies += (antlr4BuildDependency in Antlr4).value, - libraryDependencies += (antlr4RuntimeDependency in Antlr4).value + cleanFiles += (Antlr4 / javaSource).value, + libraryDependencies += (Antlr4 / antlr4BuildDependency).value, + libraryDependencies += (Antlr4 / antlr4RuntimeDependency).value ) }