Skip to content

Conversation

@jeandemanged
Copy link
Member

@jeandemanged jeandemanged commented Nov 13, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Bugfix & Feature

Rework of #3443.

What is the current behavior?

  • Add Third-party licenses #3443 has issue of looking in parent folder, hence copying licences and 3rd party files does not work for example for powsybl-distribution where we encounter:
[INFO] Copy file /home/runner/work/powsybl-distribution/powsybl-distribution/resources/XIIDM/eurostag-tutorial-example1.xml to /home/runner/work/powsybl-distribution/powsybl-distribution/target/powsybl-distribution-2025.2.1/etc
Warning:  License file /home/runner/work/powsybl-distribution/LICENSE.txt not found
Warning:  License file /home/runner/work/powsybl-distribution/THIRD-PARTY.txt not found
[INFO] Zip package
  • We use maven-plugin-testing-harness v3.3.0

What is the new behavior (if this is a feature change)?

  • User can configure the itools packager with explicit file locations for license and third party files. licenseFile and thirdPartyFile are optional. If not provided, the packager will look for LICENSE.txt, LICENSE, THIRD-PARTY and THIRD-PARTY.txt in the project directory as well as its parent directory.
                <configuration>
                    <licenseFile>LICENSE.txt</licenseFile>
                    <thirdPartyFile>THIRD-PARTY.txt</thirdPartyFile>
                </configuration>

In case no file could be found, a log indicates all attempted locations for license and third party.

  • User can configure the itools packager to copy any desired file via plugin configuration at the package root:
                <configuration>
                    <copyToPackageRoot>
                        <files>
                            <file>${project.basedir}/path/to/some/file.txt</file>
                        </files>
                    </copyToPackageRoot>
                </configuration>
  • We use maven-plugin-testing-harness v3.4.0 making tests much cleaner and easier with junit-jupiter instead of junit-vintage-engine

Does this PR introduce a breaking change or deprecate an API?

  • Yes

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

Signed-off-by: Damien Jeandemange <[email protected]>
@jeandemanged jeandemanged marked this pull request as ready for review November 17, 2025 13:55
Signed-off-by: Damien Jeandemange <[email protected]>
@rolnico
Copy link
Member

rolnico commented Nov 18, 2025

I think that the issue here is more that the "child project" (powsybl-distribution in your example) does not have a LICENSE.txt and a THIRD-PARTY.txt. According to some licenses, we should provide those files as soon as we make an executable (for example), that's why I hardcoded the two files during the itools generation.
However:

  • adding the possibility to add more files is nice to have
  • Fixing the paths of the files is also of course interesting (looking into the parent folder should be done only if the files are not found in the project directory level)

@jeandemanged
Copy link
Member Author

I think that the issue here is more that the "child project" (powsybl-distribution in your example) does not have a LICENSE.txt and a THIRD-PARTY.txt. According to some licenses, we should provide those files as soon as we make an executable (for example), that's why I hardcoded the two files during the itools generation. However:

  • adding the possibility to add more files is nice to have
  • Fixing the paths of the files is also of course interesting (looking into the parent folder should be done only if the files are not found in the project directory level)

Hi @rolnico

The issue for powsybl-distribution is that current implementation looks in parent folder always, so even if these files were added, they would not be found at all.

The warning in GitLab CI is

Warning:  License file /home/runner/work/powsybl-distribution/LICENSE.txt not found
Warning:  License file /home/runner/work/powsybl-distribution/THIRD-PARTY.txt not found

But what can be added to powsybl-distribution is:
/home/runner/work/powsybl-distribution/powsybl-distribution/LICENSE.txt
not
/home/runner/work/powsybl-distribution/LICENSE.txt

@rolnico
Copy link
Member

rolnico commented Nov 18, 2025

I think that the issue here is more that the "child project" (powsybl-distribution in your example) does not have a LICENSE.txt and a THIRD-PARTY.txt. According to some licenses, we should provide those files as soon as we make an executable (for example), that's why I hardcoded the two files during the itools generation. However:

  • adding the possibility to add more files is nice to have
  • Fixing the paths of the files is also of course interesting (looking into the parent folder should be done only if the files are not found in the project directory level)

Hi @rolnico

The issue for powsybl-distribution is that current implementation looks in parent folder always, so even if these files were added, they would not be found at all.

The warning in GitLab CI is

Warning:  License file /home/runner/work/powsybl-distribution/LICENSE.txt not found
Warning:  License file /home/runner/work/powsybl-distribution/THIRD-PARTY.txt not found

But what can be added to powsybl-distribution is: /home/runner/work/powsybl-distribution/powsybl-distribution/LICENSE.txt not /home/runner/work/powsybl-distribution/LICENSE.txt

Exactly, that's why I said that fixing the paths could be interesting.
What I'm wondering is: can we make adding these files a requirement while not providing fixed paths? Maybe having a specific parameter for each and, if it's not specified by the user, looking for the files in the standard directories (project + parent)?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 4, 2025

@jeandemanged jeandemanged removed the Breaking Change API is broken label Jan 8, 2026
@jeandemanged jeandemanged changed the title iTools packager: copy files at package root iTools packager: license files and misc files Jan 8, 2026
Signed-off-by: Damien Jeandemange <[email protected]>
@jeandemanged
Copy link
Member Author

...
... Maybe having a specific parameter for each and, if it's not specified by the user, looking for the files in the standard directories (project + parent)?

Hi @rolnico , done as per your suggestion above, let me know

Copy link
Member

@rolnico rolnico left a comment

Choose a reason for hiding this comment

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

I would make some changes: if the user specifies a license or 3rd party file, I think we should not look for a default file if the users file does not exist.
What do you think of that?

Comment on lines 33 to 34
<licenseFile>myLic.txt</licenseFile>
<thirdPartyFile>my3rdParties.txt</thirdPartyFile>
Copy link
Member

Choose a reason for hiding this comment

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

In this case, the files do not exist, but the standard files exist in the parent folder and we'll use those files. Is that the expected behavior? Or should we throw an exception when files with the expected names are not found?

Copy link
Member Author

@jeandemanged jeandemanged Jan 8, 2026

Choose a reason for hiding this comment

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

was intended, changed as you wanted.
you may change further if needed.

private void addLicenseFiles(Path packageDir) {
// List of the license files to copy
List<String> licenseFiles = Arrays.asList("LICENSE.txt", "THIRD-PARTY.txt");
Path projectRoot = Path.of(project.getBasedir().getPath());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Path projectRoot = Path.of(project.getBasedir().getPath());
Path projectRoot = project.getBasedir().toPath();

Comment on lines 183 to 184
List<Path> candidateLicenseFiles = Stream.of(licenseFile, "LICENSE.txt", "../LICENSE.txt")
.filter(Objects::nonNull).map(projectRoot::resolve).toList();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
List<Path> candidateLicenseFiles = Stream.of(licenseFile, "LICENSE.txt", "../LICENSE.txt")
.filter(Objects::nonNull).map(projectRoot::resolve).toList();
List<Path> candidateLicenseFiles = getFilePathList(licenseFile, "LICENSE", projectRoot);

Comment on lines 187 to 190
List<Path> candidateThirdPartyFiles = Stream.of(thirdPartyFile, "THIRD-PARTY.txt", "../THIRD-PARTY.txt")
.filter(Objects::nonNull).map(projectRoot::resolve).toList();
addLicenseFile(packageDir, candidateThirdPartyFiles);
}
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest a change, to only look for default files if no license/3rd party file was given by the user:

Suggested change
List<Path> candidateThirdPartyFiles = Stream.of(thirdPartyFile, "THIRD-PARTY.txt", "../THIRD-PARTY.txt")
.filter(Objects::nonNull).map(projectRoot::resolve).toList();
addLicenseFile(packageDir, candidateThirdPartyFiles);
}
List<Path> candidateThirdPartyFiles = getFilePathList(thirdPartyFile, "THIRD-PARTY", projectRoot);
addLicenseFile(packageDir, candidateThirdPartyFiles);
}
private List<Path> getFilePathList(String fileName, String defaultFileNameBase, Path projectRoot) {
if (fileName != null) {
return List.of(
projectRoot.resolve(fileName),
projectRoot.resolve("..").resolve(fileName)
);
}
// Search for default names
return Stream.of("", ".txt")
.flatMap(ext -> Stream.of(
projectRoot.resolve(defaultFileNameBase + ext),
projectRoot.resolve("..").resolve(defaultFileNameBase + ext)
))
.toList();
}

FileUtils.deleteDirectory(target2); // cleanup
String target = project.getBuild().getDirectory();
assertTrue(new File(target, DEFAULT_PACKAGE_NAME + ".zip").exists());
assertTrue(new File(target, DEFAULT_PACKAGE_NAME + "/LICENSE.txt").exists());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assertTrue(new File(target, DEFAULT_PACKAGE_NAME + "/LICENSE.txt").exists());
assertFalse(new File(target, DEFAULT_PACKAGE_NAME + "/LICENSE.txt").exists());

if you change also in the test pom.xml

</executions>
<configuration>
<licenseFile>myLic.txt</licenseFile>
<thirdPartyFile>my3rdParties.txt</thirdPartyFile>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<thirdPartyFile>my3rdParties.txt</thirdPartyFile>

remove this to test the case where only one file is specified (and since it does not exist, the test is modified too)

@github-project-automation github-project-automation bot moved this from In Progress to Waiting for review in Release 03/2026 Jan 8, 2026
Signed-off-by: Damien Jeandemange <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

Copy link
Member

@rolnico rolnico left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation bot moved this from Waiting for review to Approved in Release 03/2026 Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

3 participants