giter8
giter8 copied to clipboard
'project' directory does not get generated
using the g8 command (0.10.0 version) on a template with a project directory generates all the files and directories except the project directory.
Renaming the directory to f.e. projectt works, and using the sbt new command instead also works.
this seems to be related to the .gitignore file I have in my template under /src/main/g8/. I have the following entries in it:
project/activator-sbt* - result: 'project'-directory does not get generated - looks to be #382
data/* - result: 'data'-directory does not get generated
.env - result: '.env'-file does not get generated
Somehow the /src/main/g8/.gitignore seems to be taken into account during generation using the g8 command. This is not what I expected, additionally the sbt new command behaves differently.
Solved for now by adding some exclusion rules in a .g8ignore file in the project root.
@Philippus does the .g8ignore file take precedence over the .gitignore when present?
yes, I found this out reading the test cases: https://github.com/foundweekends/giter8/blob/7be0a57af0b1f9d6dd4f43258b66fd4ea0af32fd/library/src/test/scala/giter8/IntegrationTest.scala#L148
Workaround
For posterity, here is an example on how to add a file ignored by .gitignore to the giter8 template.
Suppose this is you project structure:
.
├── build.sbt
└── src
└── main
└── g8
├── credentials.secrets
└── .gitignore
and your .gitignore contains the following:
credentials.secrets
When using sbt new, the generated project will be:
.
└── .gitignore
Without containing the credentials.secrets.
Now, if you want the credentials.secrets to be present in the generated directory, while still being ignored in the .gitignore, you need to add a .g8ignore to the root of the g8 project that explicitly "not ignore" credentials.secrets. Such as you will end up with the following:
.
├── build.sbt
├── .g8ignore
└── src
└── main
└── g8
├── credentials.secrets
└── .gitignore
Where .g8ignore contrains (in our case:)
!credentials.secrets
Now the generated project structure should be:
.
├── credentials.secrets
└── .gitignore
@nicopap your comment should be treated as documentation
This is unnecessarily complex to be honest. It took a while to figure this out and this is barely documented.