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

Refactoring + Issue #56 GitHub default branch #263

Merged
merged 5 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/src/main/scala/giter8.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package giter8

import java.io.File

class Giter8 extends xsbti.AppMain {
java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.SEVERE)

Expand All @@ -26,16 +28,17 @@ class Giter8 extends xsbti.AppMain {

/** Runner shared my main-class runner */
def run(args: Array[String]): Int = {
val helper = new JgitHelper(new Git(new JGitInteractor), G8TemplateRenderer)
val result = (args.partition { s =>
G8.Param.pattern.matcher(s).matches
} match {
case (params, options) =>
parser.parse(options, Config()).map { config =>
JgitHelper.run(config, params)
parser.parse(options, Config("")).map { config =>
helper.run(config, params, new File("."))
}.getOrElse(Left(""))
case _ => Left(parser.usage)
})
JgitHelper.cleanup()
helper.cleanup()
result.fold ({ (error: String) =>
System.err.println(s"\n$error\n")
1
Expand Down
49 changes: 44 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import Dependencies._
import de.heikoseeberger.sbtheader.HeaderPattern

val g8version = "0.7.3-SNAPSHOT"

lazy val headerSettings = headers := Map(
"scala" -> (
HeaderPattern.cStyleBlockComment,
"""|/*
| * Original implementation (C) 2010-2015 Nathan Hamblen and contributors
| * Adapted and extended in 2016 by foundweekends project
| *
| * Licensed under the Apache License, Version 2.0 (the "License");
| * you may not use this file except in compliance with the License.
| * You may obtain a copy of the License at
| *
| * http://www.apache.org/licenses/LICENSE-2.0
| *
| * Unless required by applicable law or agreed to in writing, software
| * distributed under the License is distributed on an "AS IS" BASIS,
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| * See the License for the specific language governing permissions and
| * limitations under the License.
| */
|
|""".stripMargin
)
)

// posterous title needs to be giter8, so both app and root are named giter8
lazy val root = (project in file(".")).
enablePlugins(TravisSitePlugin, NoPublish).
Expand Down Expand Up @@ -37,6 +62,7 @@ lazy val root = (project in file(".")).

lazy val app = (project in file("app")).
disablePlugins(BintrayPlugin).
enablePlugins(AutomateHeaderPlugin).
enablePlugins(ConscriptPlugin, BuildInfoPlugin, SonatypePublish).
dependsOn(lib).
settings(
Expand All @@ -46,11 +72,13 @@ lazy val app = (project in file("app")).
sourceDirectory in csRun := { (baseDirectory).value.getParentFile / "src" / "main" / "conscript" },
libraryDependencies ++= Seq(scopt, logback),
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion),
buildInfoPackage := "giter8"
buildInfoPackage := "giter8",
headerSettings
)

lazy val scaffold = (project in file("scaffold")).
enablePlugins(BintrayPublish).
enablePlugins(AutomateHeaderPlugin).
dependsOn(lib).
settings(
name := "sbt-giter8-scaffold",
Expand All @@ -66,11 +94,14 @@ lazy val scaffold = (project in file("scaffold")).
scripted := ScriptedPlugin.scripted.dependsOn(publishLocal in lib).evaluated,
test in Test := {
scripted.toTask("").value
}
},
headerSettings,
excludes := Seq("src/main/scala/ScafoldPlugin.scala")
)

lazy val plugin = (project in file("plugin")).
enablePlugins(BintrayPublish).
enablePlugins(AutomateHeaderPlugin).
dependsOn(lib).
settings(
name := "sbt-giter8",
Expand All @@ -88,25 +119,33 @@ lazy val plugin = (project in file("plugin")).
libraryDependencies += ("org.scala-sbt" % "scripted-plugin" % sbtVersion.value),
test in Test := {
scripted.toTask("").value
}
},
headerSettings,
excludes := Seq("src/main/scala/gio.scala")
)

lazy val lib = (project in file("library")).
disablePlugins(BintrayPlugin).
enablePlugins(AutomateHeaderPlugin).
enablePlugins(SonatypePublish).
settings(
name := "giter8-lib",
description := "shared library for app and plugin",
crossScalaVersions := List(scala210, scala211, scala212),
libraryDependencies ++= Seq(
scalasti, jgit, commonsIo, plexusArchiver,
scalacheck % Test, sbtIo % Test, scalatest % Test
scalacheck % Test, sbtIo % Test, scalatest % Test,
scalamock % Test, "org.slf4j" % "slf4j-simple" % "1.7.12" % Test
) ++
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
Seq(scalaXml, parserCombinator)
case _ => Nil
})
}),
headerSettings,
excludes := Seq(
"src/main/scala/maven.scala",
"src/main/scala/ScalastiHelper.scala")
)

def customCommands: Seq[Setting[_]] = Seq(
Expand Down
215 changes: 0 additions & 215 deletions library/src/main/scala/JgitHelper.scala

This file was deleted.

7 changes: 0 additions & 7 deletions library/src/main/scala/g8.scala
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,6 @@ object G8 {
}
}

case class Config(
repo: String = "",
branch: Option[String] = None,
// tag: Option[String] = None,
forceOverwrite: Boolean = false
// search: Boolean = false
)
case class Path(paths: List[String]) {
def /(child: String): Path = copy(paths = paths ::: List(child))
}
Expand Down
Loading