From d797f5a9c3b8767c23bca47dbd3d72cd297de4ca Mon Sep 17 00:00:00 2001 From: Jason Steenstra-Pickens Date: Wed, 31 May 2017 18:58:51 +1200 Subject: [PATCH 1/2] Add test to reproduce issue with meta-projects that do not have the plugin enabled. Issue: albuch/sbt-dependency-check#14 --- .../sbt-dependency-check/aggregateMetaProject/build.sbt | 5 +++++ .../aggregateMetaProject/project/plugins.sbt | 5 +++++ src/sbt-test/sbt-dependency-check/aggregateMetaProject/test | 1 + 3 files changed, 11 insertions(+) create mode 100644 src/sbt-test/sbt-dependency-check/aggregateMetaProject/build.sbt create mode 100644 src/sbt-test/sbt-dependency-check/aggregateMetaProject/project/plugins.sbt create mode 100644 src/sbt-test/sbt-dependency-check/aggregateMetaProject/test diff --git a/src/sbt-test/sbt-dependency-check/aggregateMetaProject/build.sbt b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/build.sbt new file mode 100644 index 0000000..ac30573 --- /dev/null +++ b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/build.sbt @@ -0,0 +1,5 @@ +lazy val root = (project in file(".")) + .aggregate(meta) + +lazy val meta = project + .disablePlugins(DependencyCheckPlugin) diff --git a/src/sbt-test/sbt-dependency-check/aggregateMetaProject/project/plugins.sbt b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/project/plugins.sbt new file mode 100644 index 0000000..c939695 --- /dev/null +++ b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/project/plugins.sbt @@ -0,0 +1,5 @@ +sys.props.get("plugin.version") match { + case Some(x) => addSbtPlugin("net.vonbuchholtz" % "sbt-dependency-check" % x) + case _ => sys.error("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) +} \ No newline at end of file diff --git a/src/sbt-test/sbt-dependency-check/aggregateMetaProject/test b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/test new file mode 100644 index 0000000..555bb7d --- /dev/null +++ b/src/sbt-test/sbt-dependency-check/aggregateMetaProject/test @@ -0,0 +1 @@ +> reload \ No newline at end of file From e6b2650de9e7cba69deffb74a72667525c99c9b8 Mon Sep 17 00:00:00 2001 From: Jason Steenstra-Pickens Date: Wed, 31 May 2017 21:17:48 +1200 Subject: [PATCH 2/2] Add default values for potentially undefined settings. --- .../sbt/dependencycheck/DependencyCheckPlugin.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/net/vonbuchholtz/sbt/dependencycheck/DependencyCheckPlugin.scala b/src/main/scala/net/vonbuchholtz/sbt/dependencycheck/DependencyCheckPlugin.scala index 05f821d..7d7bd1b 100644 --- a/src/main/scala/net/vonbuchholtz/sbt/dependencycheck/DependencyCheckPlugin.scala +++ b/src/main/scala/net/vonbuchholtz/sbt/dependencycheck/DependencyCheckPlugin.scala @@ -261,19 +261,19 @@ object DependencyCheckPlugin extends sbt.AutoPlugin { lazy val aggregateProvidedFilter = ScopeFilter(inAnyProject, inConfigurations(Provided)) lazy val aggregateOptionalFilter = ScopeFilter(inAnyProject, inConfigurations(Optional)) lazy val aggregateCompileTask: Def.Initialize[Task[(ProjectRef, Configuration, Seq[Attributed[File]])]] = Def.task { - (thisProjectRef.value, configuration.value, if (dependencyCheckSkip.value) Seq.empty else (dependencyClasspath in configuration).value) + (thisProjectRef.value, configuration.value, if ((dependencyCheckSkip ?? false).value) Seq.empty else (dependencyClasspath in configuration).value) } lazy val aggregateRuntimeTask: Def.Initialize[Task[(ProjectRef, Configuration, Seq[Attributed[File]])]] = Def.task { - (thisProjectRef.value, configuration.value, if (dependencyCheckSkip.value || dependencyCheckSkipRuntimeScope.value) Seq.empty else (dependencyClasspath in configuration).value) + (thisProjectRef.value, configuration.value, if ((dependencyCheckSkip ?? false).value || (dependencyCheckSkipRuntimeScope ?? false).value) Seq.empty else (dependencyClasspath in configuration).value) } lazy val aggregateTestTask: Def.Initialize[Task[(ProjectRef, Configuration, Seq[Attributed[File]])]] = Def.task { - (thisProjectRef.value, configuration.value, if (dependencyCheckSkip.value || dependencyCheckSkipTestScope.value) Seq.empty else (dependencyClasspath in configuration).value) + (thisProjectRef.value, configuration.value, if ((dependencyCheckSkip ?? false).value || (dependencyCheckSkipTestScope ?? true).value) Seq.empty else (dependencyClasspath in configuration).value) } lazy val aggregateProvidedTask: Def.Initialize[Task[(ProjectRef, Configuration, Seq[Attributed[File]])]] = Def.task { - (thisProjectRef.value, configuration.value, if (dependencyCheckSkip.value || !dependencyCheckSkipProvidedScope.value) Seq.empty else Classpaths.managedJars(configuration.value, classpathTypes.value, update.value)) + (thisProjectRef.value, configuration.value, if ((dependencyCheckSkip ?? false).value || !(dependencyCheckSkipProvidedScope ?? false).value) Seq.empty else Classpaths.managedJars(configuration.value, classpathTypes.value, update.value)) } lazy val aggregateOptionalTask: Def.Initialize[Task[(ProjectRef, Configuration, Seq[Attributed[File]])]] = Def.task { - (thisProjectRef.value, configuration.value, if (dependencyCheckSkip.value || !dependencyCheckSkipOptionalScope.value) Seq.empty else Classpaths.managedJars(configuration.value, classpathTypes.value, update.value)) + (thisProjectRef.value, configuration.value, if ((dependencyCheckSkip ?? false).value || !(dependencyCheckSkipOptionalScope ?? false).value) Seq.empty else Classpaths.managedJars(configuration.value, classpathTypes.value, update.value)) } def addClasspathDependencies(classpathToAdd: Seq[(ProjectRef, Configuration, Seq[Attributed[File]])], checkClasspath: Set[Attributed[File]], log: Logger): Set[Attributed[File]] = {