Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ARCHETYPE-274] Conditionally include or exclude a file from archetype during generation #244

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Giovds
Copy link
Contributor

@Giovds Giovds commented Nov 22, 2024

PoC to make it possible to optionally include filesets.


Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [ARCHETYPE-XXX] SUMMARY,
    where you replace ARCHETYPE-XXX and SUMMARY with the appropriate JIRA issue.
  • Also format the first line of the commit message like [ARCHETYPE-XXX] SUMMARY.
    Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@Giovds Giovds force-pushed the add-conditional-fileset-inclusion branch from f3f3af6 to aaa74e8 Compare November 22, 2024 12:05
@Giovds Giovds force-pushed the add-conditional-fileset-inclusion branch from aaa74e8 to e980722 Compare November 22, 2024 12:18
@Giovds
Copy link
Contributor Author

Giovds commented Nov 22, 2024

I'd like to know if we would want something like this, where the property must resolve to either true or false.

<fileSet includeCondition="${extraSupport}">
   ...
</fileSet>

Perhaps there are other ways forward.

@@ -162,6 +162,13 @@
<required>false</required>
<description>Encoding to use when filtering content.</description>
</field>
<field xml.attribute="true">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does xml.attribute come from? Per XML 1.0 spec "Names beginning with the string 'xml', or with any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that is seriously broken. Not something we can fix in this PR, but another reason to avoid Modello.

package=com.company.project

extraSupport=true
anotherSupport=false
Copy link
Member

@slawekjaranowski slawekjaranowski Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line at end here, and in other files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider adding something like. Either in parent pom or in this project

<pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <configuration>
            <formats>
              <format>
                <includes>
                  <include>**.java</include>
                  <include>**pom.xml</include>
                  <include>**.txt</include>
                  <include>**.groovy</include>
                  <include>**.properties</include>
                </includes>
                <endWithNewline />
              </format>
            </formats>
          </configuration>
        </plugin>
    </pluginManagement>
 </plugins>

@@ -162,6 +162,13 @@
<required>false</required>
<description>Encoding to use when filtering content.</description>
</field>
<field xml.attribute="true">
<name>includeCondition</name>
<version>1.0.0+</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think about put 1.1.0+ here ... we also need update version for model in plugin configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be backwards compatible so that's why I put it in v1.0.0, but I'm fine with both. I'm not sure what the implications would be when adding it for 1.0.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will publish next schema version, for backward compatible users can use old schema without new field ....

<version>1.0.0+</version>
<type>String</type>
<required>false</required>
<description>Condition to include the fileset based on a property value.</description>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should contains more details ...

after looking into code and test I see that it is evaluated be velocity ... and should have a true value

@Giovds Giovds force-pushed the add-conditional-fileset-inclusion branch from 778b5f5 to 6c5e4b7 Compare December 6, 2024 17:02
@Giovds
Copy link
Contributor Author

Giovds commented Dec 20, 2024

I think I've resolved all the feedback on the PR. Is there anything I can do to help moving this feature forwards, or am I missing some more comments that I need to implement still?

@slawekjaranowski slawekjaranowski self-assigned this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants