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

Bump Gradle to 8.5, fix cache. #4139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wwadge
Copy link
Contributor

@wwadge wwadge commented Nov 10, 2023

Updated #4069 to not touch junit.

@wwadge wwadge marked this pull request as draft November 10, 2023 09:55
@wwadge wwadge force-pushed the patch-to-8.4 branch 4 times, most recently from bde6b73 to d9f4877 Compare November 10, 2023 11:35
@wwadge
Copy link
Contributor Author

wwadge commented Nov 10, 2023

Note: shift from port 5000 -> 5001 is because macOS is running AirPlay Receiver on the same port (settings -> Airdrop & Handoff -> AirPlay Receiver)

@loosebazooka
Copy link
Member

Thanks for splitting it up!

Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

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

I understand that maybe you switching 5000 -> 5001 was needed for some local mac development, but it really does pollute this PR with a HUGE number of changed. Once again making it hard to review. I think isolating the logical changes in here from that massive change would make it easier to read and review (and not accidentally miss something).

@wwadge wwadge force-pushed the patch-to-8.4 branch 2 times, most recently from 7df6a84 to e12e973 Compare November 14, 2023 05:28
@wwadge
Copy link
Contributor Author

wwadge commented Nov 14, 2023

I understand that maybe you switching 5000 -> 5001 was needed for some local mac development, but it really does pollute this PR with a HUGE number of changed. Once again making it hard to review. I think isolating the logical changes in here from that massive change would make it easier to read and review (and not accidentally miss something).

Agree: removed the 5000 -> 5001 changes.

build.gradle Show resolved Hide resolved
@wwadge wwadge force-pushed the patch-to-8.4 branch 2 times, most recently from 49f88fb to 19daba5 Compare November 16, 2023 08:38
Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

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

okay cool, I think I got through most of this, just a few questions

@wwadge
Copy link
Contributor Author

wwadge commented Nov 17, 2023

Note: there's one more deprecated thing in place:

The StartParameter.settingsFile property has been deprecated. This is scheduled to be removed in Gradle 9.0. Setting custom build file to select the default project has been deprecated. Please use 'projectDir' to specify the directory of the default project instead.

This is coming from the researchgate plugin:

        at org.gradle.StartParameter.logBuildOrSettingsFileDeprecation(StartParameter.java:507)
        at org.gradle.StartParameter.getSettingsFile(StartParameter.java:497)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at net.researchgate.release.ReleasePlugin$_apply_closure5.doCall$original(ReleasePlugin.groovy:107)
        at net.researchgate.release.ReleasePlugin$_apply_closure5.doCall(ReleasePlugin.groovy)

There's no update to the version we're using (v3.0.2) at time of writing

@loosebazooka
Copy link
Member

Yeah it's okay about the research gate plugin. We'll deal with that later

Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

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

I think we're getting close! Added just a few questions. Thanks again so much for your patience @wwadge! Will take a look at the windows issue.

@mpeddada1
Copy link
Contributor

mpeddada1 commented Dec 13, 2023

Looks like we're getting a slightly different error message now:

com.google.cloud.tools.jib.gradle.GradleProjectPropertiesTest > testGetMajorJavaVersion_jvm11 SKIPPED

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties FAILED
    expected: \foo
    but was : C:\tmpfs\src\github\jib\jib-gradle-plugin\build\tmp\test\work\gradle1551860326683086368projectDir\foo
        at com.google.cloud.tools.jib.gradle.JibExtensionTest.testProperties(JibExtensionTest.java:525)

Hm it looks like the returned file path is resolving to the absolute path instead of the expected \foo.

@wwadge wwadge force-pushed the patch-to-8.4 branch 2 times, most recently from 7732789 to 8a62443 Compare December 14, 2023 14:14
@wwadge
Copy link
Contributor Author

wwadge commented Dec 14, 2023

Looks like we're getting a slightly different error message now:

com.google.cloud.tools.jib.gradle.GradleProjectPropertiesTest > testGetMajorJavaVersion_jvm11 SKIPPED

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties FAILED
    expected: \foo
    but was : C:\tmpfs\src\github\jib\jib-gradle-plugin\build\tmp\test\work\gradle1551860326683086368projectDir\foo
        at com.google.cloud.tools.jib.gradle.JibExtensionTest.testProperties(JibExtensionTest.java:525)

Hm it looks like the returned file path is resolving to the absolute path instead of the expected \foo.

I changed the way from(..) was implemented, let's try again with the new implementation that I just pushed

@loosebazooka
Copy link
Member

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties FAILED
    expected: \foo
    but was : C:\tmpfs\src\github\jib\jib-gradle-plugin\build\tmp\test\work\gradle5672696465279302889projectDir\foo
        at com.google.cloud.tools.jib.gradle.JibExtensionTest.testProperties(JibExtensionTest.java:525)

assertThat(
testJibExtension.getSkaffold().getWatch().getExcludes().getFiles().stream()
.map(File::toPath)
.collect(Collectors.toSet()))
.containsExactly(root.resolve("watch4").toAbsolutePath());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is some inconsistency in how windows and other systems resolve paths; the former resolves to the absolute path whereas the latter resolves to the relative path. For consistent test behavior, can we always test on the absolute path with the help of toAbsolutePath()?

assertThat(testJibExtension.getExtraDirectories().getPaths().get(0).getFrom())
.isEqualTo(Paths.get("/foo"));
assertThat(testJibExtension.getExtraDirectories().getPaths().get(1).getFrom())
.isEqualTo(Paths.get("/bar/baz"));

Same as what is being done in testSkaffold(). cc/ @loosebazooka

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These docs have this to say:
Never use new File(relative path) unless passed to file() or files() or from() or other methods being defined in terms of file() or files(). Otherwise this creates a path relative to the current working directory (CWD). Gradle can make no guarantees about the location of the CWD, which means builds that rely on it may break at any time.

Adding toAbsolutePath() to that test....

Copy link
Contributor

@mpeddada1 mpeddada1 Dec 21, 2023

Choose a reason for hiding this comment

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

Stacktrace:

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties FAILED
    expected: C:\foo
    but was : C:\tmpfs\src\github\jib\jib-gradle-plugin\build\tmp\test\work\gradle10718998764490656projectDir\foo
        at com.google.cloud.tools.jib.gradle.JibExtensionTest.testProperties(JibExtensionTest.java:525)

Added a few observations in #4159 (comment) after trying out a couple of things (including adjusting the tests to verify on the absolute path). The getFrom() method (pasted below) always resolves to the absolute path in both windows and ubuntu) when the file paths are provided through gradle properties but shows discrepancies when the path is provided through a System Property.

@Override
@InputFile
public Path getFrom() {
   return from.getSingleFile().toPath();
}

Since this is not a blocker for Gradle 8.x updates, could we revert the logic of extra directories to how it was originally? This annotation is an interesting enhancement to explore but probably belongs in a separate issue due to the change in behavior that is yet to be understood further.

@wwadge
Copy link
Contributor Author

wwadge commented Jan 4, 2024

Hopefully this latest commit is close enough to how it was and works - I cannot revert completely because we used "project.file" previously. I will try to obtain a windows box to test if this one fails too for I'm still working a bit blind.

Copy link

sonarcloud bot commented Jan 5, 2024

@wwadge
Copy link
Contributor Author

wwadge commented Jan 5, 2024

One more kokoru run please - I reverted that .toAbsolutePath() bit we had added to our tests. Now that I reverted how I'm handling paths, I needed to revert that .toAbsolutePath() bit too.

Seems to work on a local windows box.

@loosebazooka
Copy link
Member

@mpeddada1 I think this is ready for another review

import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.util.GradleVersion;

public class JibPlugin implements Plugin<Project> {

@VisibleForTesting static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("5.1");
@VisibleForTesting static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("8.0");

Choose a reason for hiding this comment

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

Unfortunately this is a breaking change for Jib, we still have customers on Gradle versions < 8, and we don't want to stop the support for them. Since javaPluginExtension.getSourceSets() does not exist until Gradle 8, I don't think we have a way to add this feature without stop supporting Gradle 6 and 7 customers.

Copy link
Member

Choose a reason for hiding this comment

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

Is this the only breaking change? We can make conditional calls to various things.

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's from 7.1 according to: https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/JavaPluginExtension.html#getSourceSets--

We're using it in very few places so I don't think it's very difficult to support older versions. I can attempt a patch to support as from v6 if you want though I understand if you wish to put this PR on hold till some arbitrary future date.

@blakeli0
Copy link

@wwadge Thanks for submitting this PR and all the effort! @loosebazooka Thanks for putting the effort reviewing the PR! Unfortunately, as I mentioned in the comment, after careful consideration, we don't want to introduce a breaking change for customers still use Gradle < 8 at this moment. So we can not accept this PR as it is right now, we may re-visit it once we feel comfortable to move the minimum supported version for jib to 8.

We are really sorry for the back and forth in the past few months, please let us know if you have other suggestions!

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.

None yet

5 participants