giter8 icon indicating copy to clipboard operation
giter8 copied to clipboard

'project' directory does not get generated

Open Philippus opened this issue 6 years ago • 7 comments

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.

Philippus avatar Jun 25 '18 13:06 Philippus

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.

Philippus avatar Jun 26 '18 07:06 Philippus

Solved for now by adding some exclusion rules in a .g8ignore file in the project root.

Philippus avatar Jun 26 '18 08:06 Philippus

@Philippus does the .g8ignore file take precedence over the .gitignore when present?

chrisbenincasa avatar Jul 14 '18 17:07 chrisbenincasa

yes, I found this out reading the test cases: https://github.com/foundweekends/giter8/blob/7be0a57af0b1f9d6dd4f43258b66fd4ea0af32fd/library/src/test/scala/giter8/IntegrationTest.scala#L148

Philippus avatar Jul 15 '18 19:07 Philippus

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 avatar May 18 '20 11:05 nicopap

@nicopap your comment should be treated as documentation

TonioGela avatar Apr 30 '21 19:04 TonioGela

This is unnecessarily complex to be honest. It took a while to figure this out and this is barely documented.

fmv1992 avatar Oct 03 '21 02:10 fmv1992