eclipse-ee4j / starter

Eclipse Starter for Jakarta EE
Eclipse Public License 2.0
50 stars 40 forks source link

Indentation of conditional controls like #if/#else in Velocity template result in oddly-formatted generated artifacts post-substitution #179

Closed scottkurz closed 1 year ago

scottkurz commented 1 year ago

E.g. I just generated with a pom.xml with this excerpt:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.report.sourceEncoding>UTF-8</project.report.sourceEncoding>
                <maven.compiler.release>17</maven.compiler.release>
                <jakartaee-api.version>8.0.0</jakartaee-api.version>
                                        <open-liberty.version>RELEASE</open-liberty.version>
                <compiler-plugin.version>3.10.1</compiler-plugin.version>
        <war-plugin.version>3.3.2</war-plugin.version>
                                                <liberty-plugin.version>3.7.1</liberty-plugin.version>
            </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${jakartaee-api.version}</version>
            <scope>provided</scope>
        </dependency>
            </dependencies>

Apparently we need to do better than the type of indentations one would typically use for say, a nested if-then-else in Java.

Since others are probably more familiar with this Groovy templating I'll just post the issue and maybe someone already knows a good technique to fix this.

Note I did address this for Liberty server.xml in https://github.com/eclipse-ee4j/starter/pull/178 by simply giving up on a nested indentation corresponding to the nested "if" blocks.

m-reza-rahman commented 1 year ago

Open to ideas on how to address this. Honestly I can do without the indentation fine personally. However, I get the impression some folks are not entirely comfortable with the Velocity and Groovy way of doing things just yet.

scottkurz commented 1 year ago

Looks like here's a good starting point: https://velocity.apache.org/engine/2.0/developer-guide.html#space-gobbling. That's all I have time for today.. didn't know "gobbling" was the search term.

m-reza-rahman commented 1 year ago

It's potentially very promising. I'll look into how we could use this within Archetypes. Help is of course welcome.

scottkurz commented 1 year ago

Added a PR to just move the velocity directives to the beginning of the columns so the generated artifacts don't look weird.