Skip to content

Generate a test dependencies file to support unit tests in entitlements #127486

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 41 commits into from
May 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ee7acf3
add task skeleton
jdconrad Apr 27, 2025
619fd63
generate file for test dependencies
jdconrad Apr 28, 2025
1de3d1d
fix policy file
jdconrad Apr 28, 2025
9841168
update
jdconrad Apr 29, 2025
a69872e
convert to json file isntead of properties file
jdconrad Apr 29, 2025
73af578
fix dependency link
jdconrad May 1, 2025
40cc22f
start of jar entry lookup
jdconrad May 4, 2025
06522bd
Merge remote-tracking branch 'upstream/main' into eut2
jdconrad May 4, 2025
65c7d72
generate file with class to module info
jdconrad May 4, 2025
a9984fe
add module info to build info file
jdconrad May 5, 2025
445d3bf
added files to resources
jdconrad May 5, 2025
2c1a15f
protect task for plugins with no source
jdconrad May 5, 2025
73e6379
separate into separate plugin
jdconrad May 6, 2025
036fed8
add output for server
jdconrad May 6, 2025
fdf526e
remove todo
jdconrad May 6, 2025
7d7f8cd
Merge branch 'main' into eut2
jdconrad May 6, 2025
5f4c870
clean up
jdconrad May 7, 2025
729559b
add module info for directory
jdconrad May 7, 2025
9867a39
add module inference when plugin is not modular
jdconrad May 7, 2025
c4764b9
Merge branch 'main' into eut2
jdconrad May 7, 2025
ff80fda
Merge branch 'main' into eut2
jdconrad May 7, 2025
f6585fc
[CI] Auto commit changes from spotless
elasticsearchmachine May 7, 2025
927f9bf
Merge branch 'main' into eut2
jdconrad May 8, 2025
32cadde
Merge branch 'main' into eut2
jdconrad May 8, 2025
887e600
add comments
jdconrad May 8, 2025
9949f91
Merge remote-tracking branch 'upstream/main' into eut2
prdoyle May 13, 2025
e57cd37
First pass addressing PR comments
prdoyle May 13, 2025
444da3d
WIP non-working TestBuildInfoPluginFuncTest
prdoyle May 13, 2025
dd56d50
TestBuildInfoPluginFuncTest
prdoyle May 13, 2025
854df10
Tweaks
prdoyle May 14, 2025
931deb9
TestBuildInfoPluginFuncTest check the file's contents
prdoyle May 14, 2025
461af45
Merge branch 'main' into eut2
jdconrad May 20, 2025
33ce238
Use Files.walkFileTree
prdoyle May 21, 2025
460ea40
some response to pr comments
jdconrad May 21, 2025
8833e6e
Merge remote-tracking branch 'origin/eut2' into eut2
jdconrad May 21, 2025
1266847
update gradle values to use callable
jdconrad May 21, 2025
a38969c
Split out extractModuleNameFromJar into smaller steps
prdoyle May 21, 2025
0df276a
fix test
jdconrad May 21, 2025
69742cf
Merge remote-tracking branch 'origin/eut2' into eut2
jdconrad May 21, 2025
1d1c27d
Merge branch 'main' into eut2
jdconrad May 21, 2025
75496f4
remove extraneous callable
jdconrad May 21, 2025
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
Prev Previous commit
Next Next commit
start of jar entry lookup
  • Loading branch information
jdconrad committed May 4, 2025
commit 40cc22f93d470ed612abe65ff764a947d84c417f
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.jvm.tasks.Jar;
import org.gradle.language.jvm.tasks.ProcessResources;

import javax.inject.Inject;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Optional;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import static java.util.stream.Collectors.toList;

/**
Expand Down Expand Up @@ -60,6 +68,8 @@ public void apply(final Project project) {

SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);

// TODO: we no longer care about descriptor remove as inputs
// TODO: we no longer care about policy-yaml file remove as inputs
var testBuildInfoTask = project.getTasks().register("generateTestBuildInfo", GenerateTestBuildInfoTask.class, task -> {
var pluginProperties = project.getTasks().withType(GeneratePluginPropertiesTask.class).named("pluginProperties");
task.getDescriptorFile().set(pluginProperties.flatMap(GeneratePluginPropertiesTask::getOutputFile));
Expand All @@ -69,12 +79,31 @@ public void apply(final Project project) {
if (policy.getAsFile().exists()) {
task.getPolicyFile().set(policy);
}
task.getCodeLocations().set(
project.getConfigurations()
// TODO: get first class of each location in deterministic order
// TODO: filter META_INF and module-info.class out of these
for (File file : project.getConfigurations()
.getByName("runtimeClasspath")
.minus(project.getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME))
.plus(sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getClassesDirs()).getFiles()) {
project.getLogger().lifecycle("HELLO: " + file.getAbsolutePath() + " - " + file.isDirectory());
if (file.getName().endsWith(".jar")) {
try (JarFile jarFile = new JarFile(file)) {
Optional<JarEntry> jarEntry = jarFile.stream()
.filter(je -> je.getName().startsWith("META-INF") || je.getName().endsWith("module-info.class") || je.getName().endsWith(".class") == false).findFirst();
if (jarEntry.isPresent()) {
project.getLogger().lifecycle("ENTRY: " + jarEntry.get().getName());
}
//project.getLogger().lifecycle("LIST: " + jarFile.stream().toList());
} catch (IOException ioe) {
throw new UncheckedIOException(ioe);
}
}
}

task.getCodeLocations().set(project.getConfigurations()
.getByName("runtimeClasspath")
.minus(project.getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME))
.plus(sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getClassesDirs())
.plus(sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME).getOutput().getClassesDirs())
);

Provider<Directory> directory = project.getLayout()
Expand All @@ -87,11 +116,12 @@ public void apply(final Project project) {
sourceSet.getResources().srcDir(testBuildInfoTask);
});

// TODO: get the jar task
// TODO: configure on this task
// TODO: task.from()
//project.getLogger().lifecycle(
// "HELLO: " + project.getTasks().withType(Jar.class).getByName("jar").getArchiveFile().get().getAsFile().getAbsolutePath());
project.getTasks().withType(ProcessResources.class).named("processResources").configure(task -> {
// TODO: this is a copy task
// TODO: do this for descriptor and policy-yaml file
// TODO: use child copy spec
//task.into()
});
}

}