Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Template project code is not compiled during test #860

Open
jpsacha opened this issue Jan 4, 2024 · 4 comments
Open

Template project code is not compiled during test #860

jpsacha opened this issue Jan 4, 2024 · 4 comments

Comments

@jpsacha
Copy link

jpsacha commented Jan 4, 2024

steps

sbt or Giter8 version: 1.9.8

Generate a new new template project:

g8 foundweekends/giter8.g8

Start the SBT prompt and run tests:

sbt:My Template Project> test

problem

Something is published locally:

[info] Wrote C:\tmp\my-template-project.g8\target\scala-2.12\my-template-project_2.12-0.1.0-SNAPSHOT.pom
[info] :: delivering :: my-template-project#my-template-project_2.12;0.1.0-SNAPSHOT :: 0.1.0-SNAPSHOT :: integration :: Wed Jan 03 19:26:00 EST 2024
[info]  delivering ivy file to C:\tmp\my-template-project.g8\target\scala-2.12\ivy-0.1.0-SNAPSHOT.xml
[info]  published my-template-project_2.12 to C:\Users\x\.ivy2\local\my-template-project\my-template-project_2.12\0.1.0-SNAPSHOT\poms\my-template-project_2.12.pom
[info]  published my-template-project_2.12 to C:\Users\x\.ivy2\local\my-template-project\my-template-project_2.12\0.1.0-SNAPSHOT\jars\my-template-project_2.12.jar
[info]  published my-template-project_2.12 to C:\Users\x\.ivy2\local\my-template-project\my-template-project_2.12\0.1.0-SNAPSHOT\srcs\my-template-project_2.12-sources.jar
[info]  published my-template-project_2.12 to C:\Users\x\.ivy2\local\my-template-project\my-template-project_2.12\0.1.0-SNAPSHOT\docs\my-template-project_2.12-javadoc.jar
[info]  published ivy to C:\Users\x\.ivy2\local\my-template-project\my-template-project_2.12\0.1.0-SNAPSHOT\ivys\ivy.xml

but template project is not compiled, there is no directory target/sbt-test, as described in:
https://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin

If the src/main/g8/src/main/scala/Stub.scala is modified to be invalid code, no error messages are shown when running test or g8Test

@performantdata
Copy link

I noticed this, too. The plugin seems to use the scripted plugin, but I don't yet understand how, or why it doesn't do its job. (Having difficulties getting sbt running in debug in IDEA.)

@performantdata
Copy link

performantdata commented Jan 30, 2024

test does more if you first run Test / g8, which creates the src/sbt-test/template-name.g8/scripted directory, filled out with an instantiation of your template.

I'm not sure yet why this is necessary, since

scriptedDependencies := { val x = (Test / g8).value }

https://github.com/foundweekends/giter8/blob/v0.16.2/plugin/src/main/scala/Giter8Plugin.scala#L109-L111

scriptedDependencies has no description, so I suspect that it wasn't intended to be used this way.

@performantdata
Copy link

performantdata commented Jan 31, 2024

I discovered that the scriptedDependencies that's defined in Giter8Plugin isn't being used; sbt test is using the one defined in ScriptedPlugin instead.

This seems to be resolved by using

.enablePlugins(Giter8Plugin)

instead of the .enablePlugins(ScriptedPlugin) that g8 foundweekends/giter8.g8 generates into build.sbt—in fact, it works just as well to remove this line entirely. This also causes the sbt-scripted scenario to be generated in target/sbt-test/ instead of in src/sbt-test/, which seems more appropriate.

I haven't gotten a completely clean run yet, but that seems to be because of an error in my template. But the above so far seems to fix your issue.

@TonioGela
Copy link
Member

TonioGela commented Apr 8, 2024

@eed3si9n I think this issue requires some attention, as apparently now all the g8Test are no-ops. Following the findings of @performantdata, I've been able to determine that this has been introduced between sbt 1.9.6 and 1.9.7. Here's the diff.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

3 participants