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

set the jakartaPackages flag via a gradle property #1250

Open
wants to merge 1 commit into
base: blaub/jakartaPackagesTest-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import groovy.lang.DelegatesTo;
import java.util.HashMap;
import java.util.Map;
import org.gradle.api.Project;

public class ConjureExtension {

Expand All @@ -31,12 +32,16 @@ public class ConjureExtension {
private final GeneratorOptions pythonOptions = new GeneratorOptions();
private final Map<String, GeneratorOptions> genericOptions = new HashMap<>();

public ConjureExtension() {
public ConjureExtension(Project project) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could potentially change this to be String jakartaPackagesProperty and just make the caller use project.findProperty - i'm not really sure which is preferred.

// Projects using sufficiently new gradle-conjure have jetbrains-annotations
// added by default. Conjure generators ignore unknown flags and will not be
// impacted if generators have not been updated.
// See https://github.com/palantir/conjure-java/pull/1884
javaOptions.addFlag("jetbrainsContractAnnotations");

if (Boolean.parseBoolean((String) project.findProperty("conjure.java.jakartaPackages"))) {
javaOptions.addFlag("jakartaPackages");
}
}

public final void typescript(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public void apply(Project project) {
ConjureProductDependenciesExtension.EXTENSION_NAME,
ConjureProductDependenciesExtension.class,
project);
conjureExtension = project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class);
conjureExtension =
project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class, project);
SourceDirectorySet conjureSourceSet = createConjureSourceSet(project);
TaskProvider<Copy> copyConjureSourcesTask = createCopyConjureSourceTask(project, conjureSourceSet);
compileIrProvider =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void apply(Project project) {
project.getPlugins().apply(JavaBasePlugin.class);

ConjureExtension extension =
project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class);
project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class, project);

Configuration conjureIrConfiguration = project.getConfigurations().create(CONJURE_CONFIGURATION);
TaskProvider<Copy> extractConjureIr = project.getTasks().register("extractConjureIr", Copy.class, task -> {
Expand All @@ -79,12 +79,11 @@ private static void setupSubprojects(
createGenerateTask(subproject, extension, extractJavaTask, extractConjureIr);
});

project.getChildProjects().forEach((_name, subproject) -> {
configureDependencies(subproject, extension);
});

project.afterEvaluate(_p -> {
project.getChildProjects().forEach((_name, subproject) -> {
// Configure subproject dependencies in after-evaluate to ensure
// extension the has been evaluated.
configureDependencies(subproject, extension);
});
// Validating that each subproject has a corresponding definition and vice versa.
// We do this in afterEvaluate to ensure the configuration is populated.
Set<String> apis = conjureIrConfiguration.getAllDependencies().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void apply(Project project) {
project.getConfigurations().maybeCreate(ConjurePlugin.CONJURE_GENERATORS_CONFIGURATION_NAME);

ConjureExtension extension =
project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class);
project.getExtensions().create(ConjureExtension.EXTENSION_NAME, ConjureExtension.class, project);

TaskProvider<Task> generateConjure = project.getTasks().register("generateConjure", task -> {
task.setDescription("Generates code for all requested languages (for which there is a subproject) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ private void setupConjureJavaProjects(
+ difference);
}

project.afterEvaluate(_p -> configs.forEach((suffix, config) -> setupDerivedJavaProject(
configs.forEach((suffix, config) -> setupDerivedJavaProject(
suffix,
project,
optionsSupplier,
compileConjure,
compileIrTask,
productDependencyExt,
extractJavaTask,
config)));
config));
}

private static Project setupDerivedJavaProject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,9 @@ class ConjurePluginTest extends IntegrationSpec {
}
}
""".stripIndent()
file('api/build.gradle') << '''
conjure {
java {
jakartaPackages = true
}
}
'''.stripIndent()
createFile('gradle.properties') << """
conjure.java.jakartaPackages=true
""".stripIndent()
Copy link
Contributor

Choose a reason for hiding this comment

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

might as well test both

updateSettings(prefix)

when:
Expand Down