Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-108460

Prevent development artifacts from entering production JAR

    Details

      Description

      In liferay-portal we really only have two places that we can put source code:

      • "src": production source that will be compiled into a JAR file
      • "test": everything else

      The fact that the "everything else" category is named "test" even though it may in fact contain other, non-test, things isn't ideal, but it is the historical convention that we've been operating under.

      An example of where we've worked around this in the past has been with Storybook files, which we keep under "test/stories/" and which we configure Jest to ignore:

      https://github.com/liferay/liferay-npm-tools/blob/e8a96a04cf32cee63cf43d0434e1de82d79f21e0/packages/liferay-npm-scripts/src/config/jest.config.js#L16

      In Commerce, we have some source that does not conform to this pattern:

      • In commerce-frontend-js we have a "dev" folder that contains helpers to enable development outside of a running liferay-portal instance
      • We have "dev" code intermingled with production code elsewhere.

      I don't think we want to open the floodgates to more and more top-level folders because that causes problems elsewhere (eg. we have to configure our linting and formatting code to know about these additional locations); and what should these other top-level folders be called, and how many should there be?

      As such, I'd propose that we deal with the immediate problems in commerce by restructuring things under "test". The existing "src"vs"test" distinction isn't perfect, but it is working reasonably well. We can do some local Jest configuration to stop the tests from running against the non-test files, and if other projects beyond commerce show a need for the same, then we can make it official and bake it into the defaults.

        Attachments

          Activity

            People

            Assignee:
            fabio.mastrorilli Fabio Mastrorilli
            Reporter:
            greg.hurrell Greg Hurrell (Inactive)
            Engineering Assignee:
            Greg Hurrell (Inactive)
            Recent user:
            Enterprise Release HU
            Participants of an Issue:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:

                Packages

                Version Package
                7.1.X