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

change file name format #27

Merged
merged 4 commits into from Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -12,6 +12,7 @@ private[sourcedist] object SourceDistGenerate {
version: String,
targetDir: String,
suffix: String,
incubating: Boolean,
logger: ManagedLogger
): Unit = {
val baseDir = new File(homeDir)
Expand All @@ -26,7 +27,8 @@ private[sourcedist] object SourceDistGenerate {
ignoreList.addPatterns(customIgnorePatterns)
val files = getIncludedFiles(baseDir, ignoreList)

val baseFileName = s"$prefix-src-$version"
val versionString = if (incubating) s"$version-incubating" else version
Copy link
Collaborator

Choose a reason for hiding this comment

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

Extremely minor nit, but the variable name versionString here is slightly misleading because it also contains incubating (which has nothing to do with version).

val baseFileName = s"$prefix-$versionString-src"
val suffixedName = if (suffix.nonEmpty) s"$baseFileName-$suffix" else baseFileName
val targetDirFile = new File(targetDir)
if (!targetDirFile.exists())
Expand Down
Expand Up @@ -13,6 +13,9 @@ trait SourceDistKeys {
lazy val sourceDistName: SettingKey[String] = settingKey[String](
"The name to be used as the prefix in the output archive file names, defaults to root projects name"
)
lazy val sourceDistIncubating: SettingKey[Boolean] = settingKey[Boolean](
"Should 'incubating' appear in the output archive file names (required by Apache Incubator podlings)"
)
lazy val sourceDistSuffix: TaskKey[String] = taskKey[String](
"The suffix to be used in the output archive file names, defaults to today's date in YYMMDD format"
)
Expand Down
Expand Up @@ -13,17 +13,19 @@ object SourceDistPlugin extends AutoPlugin {
import autoImport._

private[sourcedist] lazy val sourceDistSettings: Seq[Setting[_]] = Seq(
LocalRootProject / sourceDistHomeDir := (LocalRootProject / baseDirectory).value,
LocalRootProject / sourceDistTargetDir := (LocalRootProject / target).value / "dist",
LocalRootProject / sourceDistVersion := (LocalRootProject / version).value,
LocalRootProject / sourceDistName := (LocalRootProject / name).value,
LocalRootProject / sourceDistSuffix := LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE),
LocalRootProject / sourceDistHomeDir := (LocalRootProject / baseDirectory).value,
LocalRootProject / sourceDistTargetDir := (LocalRootProject / target).value / "dist",
LocalRootProject / sourceDistVersion := (LocalRootProject / version).value,
LocalRootProject / sourceDistName := (LocalRootProject / name).value,
LocalRootProject / sourceDistSuffix := LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE),
LocalRootProject / sourceDistIncubating := false,
LocalRootProject / sourceDistGenerate := SourceDistGenerate.generateSourceDists(
homeDir = (LocalRootProject / sourceDistHomeDir).value.getAbsolutePath,
prefix = (LocalRootProject / sourceDistName).value,
version = (LocalRootProject / sourceDistVersion).value,
suffix = (LocalRootProject / sourceDistSuffix).value,
targetDir = (LocalRootProject / sourceDistTargetDir).value.getAbsolutePath,
incubating = (LocalRootProject / sourceDistIncubating).value,
logger = streams.value.log
)
)
Expand Down
5 changes: 5 additions & 0 deletions src/sbt-test/sbt-source-dist/incubating/build.sbt
@@ -0,0 +1,5 @@
scalaVersion := "2.13.10"
version := "0.1.9"
sourceDistName := "apache-pekko"
sourceDistIncubating := true
sourceDistSuffix := "20230331"
5 changes: 5 additions & 0 deletions src/sbt-test/sbt-source-dist/incubating/project/plugins.sbt
@@ -0,0 +1,5 @@
sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
@@ -0,0 +1,3 @@
object Main extends App {
println("hello")
}
5 changes: 5 additions & 0 deletions src/sbt-test/sbt-source-dist/incubating/test
@@ -0,0 +1,5 @@
> sourceDistGenerate
$ exists target/dist/apache-pekko-0.1.9-incubating-src-20230331.zip
$ exists target/dist/apache-pekko-0.1.9-incubating-src-20230331.zip.sha512
$ exists target/dist/apache-pekko-0.1.9-incubating-src-20230331.tgz
$ exists target/dist/apache-pekko-0.1.9-incubating-src-20230331.tgz.sha512
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-source-dist/multi-project/build.sbt
@@ -1,7 +1,7 @@
name := "project"
scalaVersion := "2.13.10"
version := "0.1.9"
sourceDistName := "incubator-pekko"
sourceDistName := "apache-pekko"
sourceDistSuffix := "20230331"

lazy val subOne = Project(id = "sub", file("sub")).settings(
Expand Down
16 changes: 8 additions & 8 deletions src/sbt-test/sbt-source-dist/multi-project/test
@@ -1,10 +1,10 @@
> sourceDistGenerate
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip.sha512
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz.sha512

$ absent target/dist/project-src-0.1.9-20230331.zip
$ absent target/dist/project-src-0.1.9-20230331.zip.sha512
$ absent target/dist/project-src-0.1.9-20230331.tgz
$ absent target/dist/project-src-0.1.9-20230331.tgz.sha512
$ absent target/dist/project-0.1.9-src-20230331.zip
$ absent target/dist/project-0.1.9-src-20230331.zip.sha512
$ absent target/dist/project-0.1.9-src-20230331.tgz
$ absent target/dist/project-0.1.9-src-20230331.tgz.sha512
@@ -1,6 +1,6 @@
val root = Project(id = "root", base = file(".")).settings(
scalaVersion := "2.13.10",
version := "0.1.9",
sourceDistName := "incubator-pekko",
sourceDistName := "apache-pekko",
sourceDistSuffix := "20230331"
)
@@ -1,5 +1,5 @@
> sourceDistGenerate
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip.sha512
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz.sha512
@@ -1,4 +1,4 @@
scalaVersion := "2.13.10"
version := "0.1.9"
name := "incubator-pekko"
name := "apache-pekko"
sourceDistSuffix := "20230331"
8 changes: 4 additions & 4 deletions src/sbt-test/sbt-source-dist/simple-implicit-name/test
@@ -1,5 +1,5 @@
> sourceDistGenerate
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip.sha512
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz.sha512
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-source-dist/simple/build.sbt
@@ -1,4 +1,4 @@
scalaVersion := "2.13.10"
version := "0.1.9"
sourceDistName := "incubator-pekko"
sourceDistName := "apache-pekko"
sourceDistSuffix := "20230331"
8 changes: 4 additions & 4 deletions src/sbt-test/sbt-source-dist/simple/test
@@ -1,5 +1,5 @@
> sourceDistGenerate
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.zip.sha512
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz
$ exists target/dist/incubator-pekko-src-0.1.9-20230331.tgz.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip
$ exists target/dist/apache-pekko-0.1.9-src-20230331.zip.sha512
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz
$ exists target/dist/apache-pekko-0.1.9-src-20230331.tgz.sha512