Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Find what sbt builds in a Scala project

Țugui Dragoș16543d088a2e
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 04d05917..7114e1ce 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -243,6 +243,14 @@ public enum ProjectArtifacts {
name: "target", markers: ["pom.xml"], tool: "Maven", isGeneric: true,
source: "https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html"
),
+ Definition(
+ name: "target", markers: ["build.sbt"], tool: "sbt", isGeneric: true,
+ source: "https://www.scala-sbt.org/1.x/docs/Directories.html"
+ ),
+ Definition(
+ name: "project/target", markers: ["build.sbt"], tool: "sbt", isGeneric: true,
+ source: "https://www.scala-sbt.org/1.x/docs/Directories.html"
+ ),
Definition(
name: "build", markers: gradleFiles, tool: "Gradle", isGeneric: true,
source: "https://docs.gradle.org/current/userguide/directory_layout.html"
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index b7003f05..19d61bdf 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -273,6 +273,24 @@ struct ProjectArtifactsTests {
#expect(found.allSatisfy { $0.tool == "CLion" && $0.isRecommended })
}
+ @Test func findsWhatSbtBuildsBesideItsBuildFileAndInItsProjectFolder() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("service/build.sbt", bytes: 16)
+ try directory.file("service/src/main/scala/Main.scala", bytes: 16)
+ try directory.file("service/target/scala-3.7.3/classes/Main.class", bytes: 400_000)
+ try directory.file("service/project/build.properties", bytes: 16)
+ try directory.file("service/project/target/config-classes/Build.class", bytes: 400_000)
+ try directory.file("notes/target/report.txt", bytes: 400_000)
+ try age(directory.url, days: 60)
+
+ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts
+
+ #expect(Set(found.map { "\($0.project.lastPathComponent)/\($0.name)" }) == [
+ "service/target", "service/project/target",
+ ])
+ #expect(found.allSatisfy { $0.tool == "sbt" })
+ }
+
@Test func findsRailsCacheInsideItsTemporaryFolderAndOnlyThere() async throws {
let directory = try TemporaryDirectory()
try directory.file("shop/config/application.rb", bytes: 16)