Skip to content

Commit

Permalink
Merge pull request #250 from mkurz/refactor_disableExportedProducts
Browse files Browse the repository at this point in the history
Rename `disableExportAssets` to `disableExportedProducts` + refactor
  • Loading branch information
mkurz authored Jun 16, 2024
2 parents ab07634 + 408bf92 commit acb3121
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/main/scala/com/typesafe/sbt/web/SbtWeb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ object Import {
)
val stagingDirectory = SettingKey[File]("web-staging-directory", "Directory where we stage distributions/releases.")

val disableExportAssets = AttributeKey[Boolean](
"disableExportAssets",
"If added to the state and set to true, the assets will not be exported"
val disableExportedProducts = AttributeKey[Boolean](
"disableExportedProducts",
"If added to the state and set to true, assets will not be exported via exportedProducts"
)
}

Expand Down Expand Up @@ -334,13 +334,9 @@ object SbtWeb extends AutoPlugin {
exportedAssets := syncExportedAssets(TrackLevel.TrackAlways).value,
exportedAssetsIfMissing := syncExportedAssets(TrackLevel.TrackIfMissing).value,
exportedAssetsNoTracking := syncExportedAssets(TrackLevel.NoTracking).value,
exportedProducts := Seq(Attributed.blank(exportedAssets.value).put(webModulesLib.key, moduleName.value)),
exportedProductsIfMissing := Seq(
Attributed.blank(exportedAssetsIfMissing.value).put(webModulesLib.key, moduleName.value)
),
exportedProductsNoTracking := Seq(
Attributed.blank(exportedAssetsNoTracking.value).put(webModulesLib.key, moduleName.value)
)
exportedProducts := exportProducts(exportedAssets).value,
exportedProductsIfMissing := exportProducts(exportedAssetsIfMissing).value,
exportedProductsNoTracking := exportProducts(exportedAssetsNoTracking).value
)

val nodeModulesSettings = Seq(
Expand Down Expand Up @@ -412,7 +408,7 @@ object SbtWeb extends AutoPlugin {
exportConf: Configuration,
track: TrackLevel
): Def.Initialize[Task[Classpath]] = Def.taskDyn {
if ((exportConf / exportJars).value || state.value.get(disableExportAssets).getOrElse(false)) Def.task {
if ((exportConf / exportJars).value) Def.task {
Seq.empty
}
else {
Expand All @@ -427,6 +423,14 @@ object SbtWeb extends AutoPlugin {
}
}

def exportProducts(exportTask: TaskKey[File]): Def.Initialize[Task[Classpath]] = Def.task {
if (state.value.get(disableExportedProducts).getOrElse(false)) {
Seq.empty
} else {
Seq(Attributed.blank(exportTask.value).put(webModulesLib.key, moduleName.value))
}
}

def packageSettings: Seq[Setting[_]] = inConfig(Assets)(
Defaults.packageTaskSettings(packageBin, packageAssetsMappings) ++ Seq(
packagePrefix := "",
Expand Down

0 comments on commit acb3121

Please sign in to comment.