-
Notifications
You must be signed in to change notification settings - Fork 60
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
Giter8 plugin #548
Open
darthorimar
wants to merge
9
commits into
cvogt:master
Choose a base branch
from
darthorimar:giter8-plugin
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Giter8 plugin #548
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3fbbc9b
Basic template generation
darthorimar 5019c28
Basic arguments parsing
darthorimar d65fa46
Add arguments parsing
darthorimar 63f4c8f
Add g8 alias
darthorimar ccb3e02
Get rid of implicit
darthorimar aa7a74b
Tests is good
darthorimar e39192f
Throw an exception on not success
darthorimar b7cc345
Fix test
darthorimar 22e7337
Remove not existing plugin defenition
darthorimar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package cbt | ||
|
||
import java.io.File | ||
import java.util.concurrent.ConcurrentHashMap | ||
import java.{lang, util} | ||
|
||
class FakeContext(stage2Args: Stage2Args) extends Context { | ||
override def cbtRootHome(): File = stage2Args.cbtHome | ||
|
||
override def projectDirectory(): File = stage2Args.cbtHome | ||
|
||
override def permanentKeys(): ConcurrentHashMap[String, AnyRef] = new ConcurrentHashMap | ||
|
||
override def parentBuildOrNull(): BuildInterface = null | ||
|
||
override def cbtLastModified(): Long = stage2Args.stage2LastModified | ||
|
||
override def persistentCache(): util.Map[AnyRef, AnyRef] = stage2Args.persistentCache | ||
|
||
override def start(): Long = 0 | ||
|
||
override def transientCache(): util.Map[AnyRef, AnyRef] = stage2Args.transientCache | ||
|
||
override def argsArray(): Array[String] = Array.empty | ||
|
||
override def cache(): File = stage2Args.cache | ||
|
||
override def compatibilityTarget(): File = stage2Args.compatibilityTarget | ||
|
||
override def startCompat(): lang.Long = new lang.Long(0) | ||
|
||
override def enabledLoggersArray(): Array[String] = Array.empty | ||
|
||
override def cbtHasChangedCompat(): lang.Boolean = false | ||
|
||
override def cwd(): File = stage2Args.cwd | ||
|
||
override def permanentClassLoaders(): ConcurrentHashMap[AnyRef, ClassLoader] = new ConcurrentHashMap() | ||
|
||
override def scalaVersionOrNull(): String = null | ||
|
||
override def cbtHome(): File = stage2Args.cbtHome | ||
} | ||
|
||
object FakeContext { | ||
def apply(stage2Args: Stage2Args): FakeContext = new FakeContext(stage2Args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import java.io.File | ||
|
||
import cbt._ | ||
import giter8._ | ||
import scala.util._ | ||
|
||
class Build(val context: Context) extends BaseBuild { | ||
def createTemplate = { | ||
val helper = new JgitHelper(new Git(new JGitInteractor), G8TemplateRenderer) | ||
(context.args.toList match { | ||
case t :: Nil => Right(t, context.cwd, Seq.empty) | ||
case t :: x :: Nil if x.startsWith("--") => Right(t, context.cwd, Seq(x)) | ||
case t :: x :: xs => Right(t, new File(x), xs) | ||
case Nil => Left("Please, specify a template name") | ||
}) | ||
.right.flatMap { case (template, dir, args) => | ||
Either.cond(args.forall(validateArgument), | ||
(template, dir, args), | ||
"""Incorrect arguments, it should be --<name>=<value> | ||
|Example --name=my_cool_project | ||
""".stripMargin) | ||
} | ||
.right.flatMap { case (template, dir, args) => | ||
val config = Config(template) | ||
helper.run(config, args, dir) | ||
} | ||
.fold(f => Failure(new Exception(f)), s => Success(s)) | ||
.get | ||
} | ||
|
||
private def validateArgument(arg: String) = | ||
arg.matches("""--[\w]+=[\w]+""") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import cbt._ | ||
|
||
class Build(val context: Context) extends BuildBuild { | ||
override def dependencies: Seq[Dependency] = | ||
super.dependencies ++ | ||
Resolver(mavenCentral).bind( | ||
ScalaDependency("org.foundweekends.giter8", "giter8-lib", "0.9.0") | ||
) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't look like the plugin exists, no?