Create g8 Template From a Git Remote Project - scala

I have a sbt g8 template that I customized for my projects and this is located as one of the sub project in a multi module scala sbt project which is assigned to my organization. For example.,
main-project
- projec1
- sbt-template-project.g8
- some-other-project
The main-project is available in my git repo and I would like to know how I can create a project from the sbt-template-project? I tried the following, but it says "Template Not Found":
sbt new file:https://github.com/my-organization/main-project/tree/master/sbt-template-project.g8
I also tried:
sbt new file:https://github.com/my-organization/main-project/sbt-template-project.g8
I also tried:
sbt new https://github.com/my-organization/main-project/sbt-template-project.g8
What is the correct way to generate the project out of the template?
EDIT: I even tried the following:
sbt new my-organization/main-project -d sbt-template-project-g8
Even that is failing with the message "Template not found"

Your flow is basically not supported - see: http://www.foundweekends.org/giter8/template.html - Giter8 (and sbt new) support only GitHub repositories where the template in either in the root directory or in src/main/g8.
Your best option is to git clone it manually and then call sbt new passing path to the subdirectory:
git clone https://github.com/my-organization/main-project tmp-template-dir
sbt new file://tmp-template-dir/sbt-template-project.g8
rm -rf tmp-template-dir
It is important that the directory name end with .g8.

Related

Error: Unknown argument 'idea-shell'

I'm using Intellij Idea community edition. When I run
new https://github.com/sbt/scala-seed.g8
or
new PlayFramework/play-scala-seed.g8
from sbt shell it gives me following error :
Error: Unknown argument 'idea-shell' g8 0.7.2 Usage: giter8 [options] <template> <template> git or file URL, or github user/repo -b, --branch <value> Resolve a template within a given branch -f, --force Force overwrite of any existing files in output directory --version Display version number
--paramname=paramval Set given parameter value and bypass interaction EXAMPLES Apply a template from github
g8 foundweekends/giter8 Apply using the git URL for the same template
g8 git://github.com/foundweekends/giter8.git Apply template from a remote branch
g8 foundweekends/giter8 -b some-branch Apply template from a local repo
g8 file://path/to/the/repo Apply given name parameter and use defaults for all others.
g8 foundweekends/giter8 --name=template-test
This happens due to how the sbt shell is implemented in the IntelliJ Scala plugin. Also the new command isn't really meant to be run from a live shell session.
Run new from the terminal instead:
sbt new https://github.com/sbt/scala-seed.g8
You should use it from the terminal like:
sbt new scala/scala-seed.g8
If you still have problems:
Maybe you have to run it from a directory that is not a SBT project (no build.sbt)
Of course you need sbt installed.

camelot-test-maven-plugin: config not found! Paths=[]

I'm trying to execute camelot-test:run goal on Camelot-based multimodule project where one of the modules is using camelot-test-maven-plugin:
$ mvn clean compile camelot-test:run
.... (a lot of output)
org.springframework.beans.factory.BeanInitializationException: Cannot initialize plugins system: config not found! Paths=[]
at ru.yandex.qatools.camelot.core.impl.GenericPluginsEngine.loadConfigs(GenericPluginsEngine.java:391)[camelot-core-2.1.12.jar:]
at ru.yandex.qatools.camelot.core.impl.GenericPluginsEngine.getConfigs(GenericPluginsEngine.java:149)[camelot-core-2.1.12.jar:]
at ru.yandex.qatools.camelot.core.impl.GenericPluginsEngine.getPluginsMap(GenericPluginsEngine.java:231)[camelot-core-2.1.12.jar:]
at ru.yandex.qatools.camelot.core.impl.ProcessingEngineImpl$1.onCamelContextStarted(ProcessingEngineImpl.java:86)[camelot-core-2.1.12.jar:]
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1987)[camel-core-2.13.2.jar:2.13.2]
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1851)[camel-core-2.13.2.jar:2.13.2]
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683)[camel-core-2.13.2.jar:2.13.2]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[camel-core-2.13.2.jar:2.13.2]
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651)[camel-core-2.13.2.jar:2.13.2]
...and so on and so forth
How can I fix this issue?
You should launch camelot-test-maven-plugin directly from the submodule directory, containing camelot.xml. The fact is that you cannot use it from the root module directory. This behaviour is typical for the similar maven plugins (like jetty-maven-plugin).

In Play 2 Framework , how can I include git commit sha in sbt dist package name?

I have a Play 2.2.x project, for which I can create universal distribution zip archive:
$ sbt dist
This creates a file target/universal/project-name-1.0-SHAPSHOT.zip
I want to include a git commit sha such that the package generated looks like this:
target/universal/project-name-1.0-SHAPSHOT-0d6d7f4325de87df6a8f46bd635d14ba8892715a.zip
In Play 2 Framework , how can I include git commit sha in sbt dist package name?
Easiest way is:
version := "1.0-SNAPSHOT-" + "git rev-parse HEAD".!!.trim

How to add some local maven repo url to global sbt, and make them be tried first?

I want to add some fast local maven repository url to sbt, say:
http://maven.example.com/public
I want to add it to "global", so that I don't need to add them to each of sbt project. And also want to be tried first when sbt downloading some jars.
But I can't find useful information to do this, how to do it?
(My sbt version is 0.13.1)
With the help of a friend, finally I found the solution:
create a new file ~/.sbt/repositories
add content like this:
[repositories]
local
my-maven-repo: http://example.org/repo
my-ivy-repo: http://example.org/ivy-repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
See official doc: http://www.scala-sbt.org/0.13.2/docs/Detailed-Topics/Library-Management.html#override-all-resolvers-for-all-builds
Modify your global configuration file, which is normally located in ~/.sbt/0.13/global.sbt, if it's not there you can create it.
In the file add following line:
externalResolvers := { ("Fast Repo" at "http://maven.example.com/public") +: externalResolvers.value }
You can confirm it's working by executing show externalResolvers in any project to see the list of resolvers. Your newly added resolver should be first.

Custom deployment with sbt

I have a Scala application and i want to setup a deployment process result similar to one Akka sbt plugin gives, but i it requires project to be a microkernel. Sbt-assembly is a very cool plugin, but i want to have a free access to my config files, basically i want to have the following app structure:
/app/bin - start script bash file
/config - all my application .conf files
/deploy - my project .jar with classes
/lib - all my dependencies .jar files
/logs - log files
I we checked typesafe sbt-native-packager, it's better, but it could place my .conf file and logs out of jars. All those settings in SBT looks confusing to me, what can i do to with this?
Actually this is not hard to update akka-sbt-plugin to make it work in general, add this file to your project folder and somewhere in your build the following settings:
.settings(Distribution.distSettings: _*)
.settings(mappings in Compile in packageBin ~= { _.filter(!_._1.getName.endsWith(".conf")) })
The first line adds all dist settings to your project and the second one excludes all .conf files from your .jar and reads them from config folder.
Now you have to commands: dist - creates a folder with a structure you've discribed and zipDist which packs it all into .zip file, later you can add this to you publish setting:
addArtifact(Artifact(someName, "zip", "zip"), zipDist)