-
Notifications
You must be signed in to change notification settings - Fork 134
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
Configurable java toolchains #2193
Merged
Merged
Changes from 13 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
a96512d
An entirely plain refactor
CRogers 533d5f7
Pass in project only
CRogers e56c43e
Write some code
CRogers 40e7ad7
Add jvm versions to extensions
CRogers 6e6d0ef
Get test working for jdk downloader
CRogers 1aa5cfd
Extract jdk on osx
CRogers 09c6d4f
Wire it all together
CRogers 7e68898
Fixes
CRogers 51b834a
Put a root plugin in so we can configure all the repos at the right time
CRogers 1c35750
be english good
CRogers 299e8c2
Clean up sstuff
CRogers d66ed8a
Fix test
CRogers bf928eb
Shorten paths
CRogers edd23d0
Merge branch 'develop' of github.com:palantir/gradle-baseline into ca…
CRogers edd8d6a
Add generated changelog entries
svc-changelog 612189f
Move code to BaselineJavaVersionsExtensions
CRogers a747e9f
Flail around trying to understand artifact transforms
CRogers ad42636
Less nots
CRogers 7330ac8
ArtifactView!!!!!!!
CRogers bd4efc7
Give up on copyspec madness
CRogers a402dc7
Use downloader only everywhere
CRogers 8457837
Simplify to just being configured with specific jdks
CRogers 5ef6fd4
Fix all those copyright notices
CRogers 3c996ea
Remove jarchivelib
CRogers 6c3df93
Tidy up diff
CRogers 5816d1f
Add generated changelog entries
svc-changelog fe0bf39
Merge branch 'develop' of github.com:palantir/gradle-baseline into ca…
CRogers d492489
Tidy up code
CRogers e19d229
Write a test
CRogers f6d2b22
Try reenabling fork
CRogers 1517462
Note one why fork is needed
CRogers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ out/ | |
docs/node_modules/ | ||
generated_src | ||
generated_testSrc | ||
generated | ||
generated_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ne-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/AzulJavaToolchain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.palantir.baseline.plugins.javaversions; | ||
|
||
import org.gradle.api.provider.Provider; | ||
import org.gradle.jvm.toolchain.JavaCompiler; | ||
import org.gradle.jvm.toolchain.JavaLauncher; | ||
import org.gradle.jvm.toolchain.JavadocTool; | ||
|
||
final class AzulJavaToolchain implements PalantirJavaToolchain { | ||
private final Provider<PalantirJavaInstallationMetadata> javaInstallationMetadata; | ||
|
||
AzulJavaToolchain(Provider<PalantirJavaInstallationMetadata> javaInstallationMetadata) { | ||
this.javaInstallationMetadata = javaInstallationMetadata; | ||
} | ||
|
||
@Override | ||
public Provider<JavaCompiler> javaCompiler() { | ||
return javaInstallationMetadata.map(PalantirJavaCompiler::new); | ||
} | ||
|
||
@Override | ||
public Provider<JavadocTool> javadocTool() { | ||
return javaInstallationMetadata.map(PalantirJavadocTool::new); | ||
} | ||
|
||
@Override | ||
public Provider<JavaLauncher> javaLauncher() { | ||
return javaInstallationMetadata.map(PalantirJavaLauncher::new); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ne-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/AzulJdkDownloader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.palantir.baseline.plugins.javaversions; | ||
|
||
import com.google.common.collect.Iterables; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.artifacts.Configuration; | ||
|
||
final class AzulJdkDownloader { | ||
private static final String AZUL_JDK = "azul-jdk"; | ||
|
||
private final Project rootProject; | ||
|
||
AzulJdkDownloader(Project rootProject) { | ||
this.rootProject = rootProject; | ||
|
||
if (rootProject != rootProject.getRootProject()) { | ||
throw new IllegalArgumentException("Must pass in the root project"); | ||
} | ||
|
||
String jdkBaseUrl = property("base-url").orElse("https://cdn.azul.com/zulu/bin/"); | ||
|
||
rootProject.getRepositories().ivy(ivy -> { | ||
ivy.setName(AZUL_JDK); | ||
ivy.setUrl(jdkBaseUrl); | ||
ivy.patternLayout(patternLayout -> patternLayout.artifact("[module].[ext]")); | ||
ivy.metadataSources(metadataSources -> metadataSources.artifact()); | ||
ivy.content(repositoryContentDescriptor -> { | ||
repositoryContentDescriptor.includeGroup(AZUL_JDK); | ||
}); | ||
}); | ||
|
||
rootProject | ||
.getRepositories() | ||
.matching(repo -> !repo.getName().equals(AZUL_JDK)) | ||
.configureEach(artifactRepository -> { | ||
artifactRepository.content(content -> content.excludeGroup(AZUL_JDK)); | ||
}); | ||
} | ||
|
||
public Path downloadJdkFor(JdkSpec jdkSpec) { | ||
Configuration configuration = rootProject | ||
.getConfigurations() | ||
.detachedConfiguration(rootProject | ||
.getDependencies() | ||
.create(String.format( | ||
"%s:zulu%s-ca-jdk%s-%s_%s:@zip", | ||
AZUL_JDK, jdkSpec.zuluVersion(), jdkSpec.javaVersion(), jdkSpec.os(), jdkSpec.arch()))); | ||
return Iterables.getOnlyElement(configuration.resolve()).toPath(); | ||
} | ||
|
||
private Optional<String> property(String name) { | ||
return Optional.ofNullable((String) rootProject.findProperty("com.palantir.baseline-java-versions." + name)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...main/groovy/com/palantir/baseline/plugins/javaversions/BaselineJavaVersionRootPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.palantir.baseline.plugins.javaversions; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
|
||
public final class BaselineJavaVersionRootPlugin implements Plugin<Project> { | ||
private JdkManager jdkManager; | ||
|
||
@Override | ||
public void apply(Project rootProject) { | ||
if (!rootProject.equals(rootProject.getRootProject())) { | ||
throw new RuntimeException( | ||
BaselineJavaVersionRootPlugin.class + " can only be applied on the root project"); | ||
} | ||
|
||
jdkManager = | ||
new JdkManager(rootProject.getBuildDir().toPath().resolve("jdks"), new AzulJdkDownloader(rootProject)); | ||
} | ||
|
||
public JdkManager jdkManager() { | ||
return jdkManager; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could define these at most once per repo instead of per-module? (possibly
BaselineJavaVersionsExtension.java
, which only exists on the root project)I don't think we would want the values to differ across modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh actually in the process of doing this right now. The
BaselineJavaVersion
vsBaselineJavaVersions
difference was lost on me for a little bit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have named things much better 😞 Sorry!