package org.allenai.plugins

import sbt._
import sbt.Keys._

import scalariform.formatter.preferences.{ DoubleIndentClassDeclaration, FormattingPreferences }
import scalariform.sbt.ScalariformPlugin

object CoreSettingsPlugin extends AutoPlugin {

  // Automatically add the StylePlugin and VersionInjectorPlugin
  override def requires: Plugins = ScalariformPlugin && StylePlugin && VersionInjectorPlugin

  // Automatically enable the plugin (no need for projects to `enablePlugins(CoreSettingsPlugin)`)
  override def trigger: PluginTrigger = allRequirements

  object autoImport {
    val CoreResolvers = CoreRepositories.Resolvers
    val PublishTo = CoreRepositories.PublishTo
  }

  // These settings will be automatically applied to projects
  override def projectSettings: Seq[Setting[_]] =
    Seq(
      fork := true, // Forking for run, test is required sometimes, so fork always.
      scalaVersion := CoreDependencies.defaultScalaVersion,
      scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation", "-feature"),
      javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
      conflictManager := ConflictManager.strict,
      resolvers ++= CoreRepositories.Resolvers.defaults,
      dependencyOverrides ++= CoreDependencies.loggingDependencyOverrides,
      dependencyOverrides += "org.scala-lang" % "scala-library" % scalaVersion.value,
      // Override default scalariform settings.
      ScalariformPlugin.autoImport.scalariformPreferences := {
        FormattingPreferences().setPreference(DoubleIndentClassDeclaration, true)
      }
    )
}

package org.allenai.plugins

import sbt._
import sbt.Keys._

import scalariform.formatter.preferences.{ DoubleIndentClassDeclaration, FormattingPreferences }
import scalariform.sbt.ScalariformPlugin

object CoreSettingsPlugin extends AutoPlugin {

  // Automatically add the StylePlugin and VersionInjectorPlugin
  override def requires: Plugins = ScalariformPlugin && StylePlugin && VersionInjectorPlugin

  // Automatically enable the plugin (no need for projects to `enablePlugins(CoreSettingsPlugin)`)
  override def trigger: PluginTrigger = allRequirements

  object autoImport {
    val CoreResolvers = CoreRepositories.Resolvers
    val PublishTo = CoreRepositories.PublishTo
  }

  override val projectConfigurations = Seq(Configurations.IntegrationTest)

  // These settings will be automatically applied to projects
  override def projectSettings: Seq[Setting[_]] =
    Defaults.itSettings ++ Seq(
      fork := true, // Forking for run, test is required sometimes, so fork always.
      scalaVersion := CoreDependencies.defaultScalaVersion,
      scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation", "-feature"),
      javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
      resolvers ++= CoreRepositories.Resolvers.defaults,
      dependencyOverrides ++= CoreDependencies.loggingDependencyOverrides,
      dependencyOverrides += "org.scala-lang" % "scala-library" % scalaVersion.value,
      // Override default scalariform settings.
      ScalariformPlugin.autoImport.scalariformPreferences := {
        FormattingPreferences().setPreference(DoubleIndentClassDeclaration, true)
      }
    )
}

Use default ConflictManager instead of strict
Use default ConflictManager instead of strict

SBT will report when a dependency has been evicted that it suspects may
be binary incompatible. The default ConflictManager will choose the
latest version of the dependency. This may become an issue when we move
to semantic versioning.
