Skip to content

fix: export maven/gradle, install runtime wrappers #1991

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

Merged
merged 14 commits into from
Apr 9, 2025

Conversation

wfouche
Copy link
Contributor

@wfouche wfouche commented Apr 7, 2025

Closes #1987

@wfouche wfouche changed the title Install runtime wrappers for maven or gradle fix: export maven/gradle, install runtime wrappers Apr 7, 2025
@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

This code has been tested to work with Maven and Gradle on Linux and Windows.

@quintesse
Copy link
Contributor

Looks like a good start, but why did you remove the JAR from the resources?

@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

Looks like a good start, but why did you remove the JAR from the resources?

Encountered a weird issue. File gradle-wrapper.jar (binary file) was not copied to the JBang JAR file, so it could not be read at runtime. Does thiis make any sense?

So I reverted to downloading the file at runtime. But would prefer to have it in the JBang JAR if possible.

@quintesse
Copy link
Contributor

Aha, I guess it must be something in the Gradle assembly process that filters out files that it thinks should not be part of the output.

@quintesse
Copy link
Contributor

Just as a test, try renaming the file to give it a different extension from ".jar" and see if that works.

@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

Just as a test, try renaming the file to give it a different extension from ".jar" and see if that works.

Renamed it to -jar instead of .jar; and it works fine at runtime.

Will update the pull request shortly.

@quintesse
Copy link
Contributor

Ok, good to know, still I'd like to find out how we can get it to work with its original name.
Why? Because if we keep the original name updating the wrappers to neewer versions is much easier: we can just go into the resources/dist/gradle or maven folder and run the required gradle/maven command to update the files and commit.

@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

Ok, good to know, still I'd like to find out how we can get it to work with its original name.

It might be added to the classpath if it is stored as a .jar file, and then it will be loaded and the classes it contains made available to the JVM. Maybe not what we want.

I think it would be fine to keep it as a -jar file, and also simple enough to rename the file when updating it in the future.

@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

Adding scrupt update-version.sh to the dist/gradle folder to be used in the future to update the Gradle wrapper files.

#!/bin/bash

export GRADLE_VERSION=8.9

mv gradle/wrapper/gradle-wrapper-jar gradle/wrapper/gradle-wrapper.jar

touch build.gradle
touch settings.gradle

./gradlew wrapper --gradle-version $GRADLE_VERSION

mv gradle/wrapper/gradle-wrapper.jar gradle/wrapper/gradle-wrapper-jar

rm -f -r .gradle build.gradle settings.gradle

tree -a

git status
git diff

@wfouche
Copy link
Contributor Author

wfouche commented Apr 7, 2025

Created an update-version.sh script for Maven as well.

@quintesse
Copy link
Contributor

Adding scrupt update-version.sh to the dist/gradle folder to be used in the future to update the Gradle wrapper files.

Good enough 👍

@wfouche
Copy link
Contributor Author

wfouche commented Apr 8, 2025

Done with coding and testing; ready to be reviewed.

@wfouche
Copy link
Contributor Author

wfouche commented Apr 9, 2025

@quintesse , please restart the build. (smile)

if (isWindows)
return;

if (execFlag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, everything is perfect for merging, but .... I wonder if you could do me a favor and perform a small refactor: there is already some code in JBang to set a file as executable (See https://github.com/jbangdev/jbang/blob/main/src/main/java/dev/jbang/cli/App.java#L192). Could you perhaps extract that, move it to Util.java (just below the isExecutable() method for example) and make Export use that one as well?

Copy link
Contributor Author

@wfouche wfouche Apr 9, 2025

Choose a reason for hiding this comment

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

That's a good idea. I'll implement the requested changes.

Copy link
Contributor Author

@wfouche wfouche Apr 9, 2025

Choose a reason for hiding this comment

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

@quintesse , I tested the refactored code using the new Util.setExecutable() method on Linux and Windows, with Maven and Gradle. All tests were successful.

The build failed again, so when you have a chance please restart it. Thanks.

@quintesse quintesse self-requested a review April 9, 2025 23:42
@quintesse quintesse merged commit 28ae085 into jbangdev:main Apr 9, 2025
12 of 14 checks passed
@quintesse
Copy link
Contributor

Thanks for your effort @wfouche !

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.

Export maven/gradle should create Maven/Gradle wrappers
2 participants