Skip to content
Merged
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
4 changes: 4 additions & 0 deletions build-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ gradlePlugin {
id = 'elasticsearch.stable-esplugin'
implementationClass = 'org.elasticsearch.gradle.plugin.StablePluginBuildPlugin'
}
testBuildInfo {
id = 'elasticsearch.test-build-info'
implementationClass = 'org.elasticsearch.gradle.test.TestBuildInfoPlugin'
}
javaRestTest {
id = 'elasticsearch.java-rest-test'
implementationClass = 'org.elasticsearch.gradle.test.JavaRestTestPlugin'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.elasticsearch.gradle.test

import com.fasterxml.jackson.databind.ObjectMapper

import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
import org.gradle.testkit.runner.TaskOutcome

class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
def "works"() {
given:
file("src/main/java/com/example/Example.java") << """
package com.example;

public class Example {
}
"""

file("src/main/java/module-info.java") << """
module com.example {
exports com.example;
}
"""

buildFile << """
import org.elasticsearch.gradle.plugin.GenerateTestBuildInfoTask;

plugins {
id 'java'
id 'elasticsearch.test-build-info'
}

repositories {
mavenCentral()
}

tasks.withType(GenerateTestBuildInfoTask.class) {
componentName = 'example-component'
outputFile = new File('build/generated-build-info/plugin-test-build-info.json')
}
"""

when:
def result = gradleRunner('generateTestBuildInfo').build()
def task = result.task(":generateTestBuildInfo")


then:
task.outcome == TaskOutcome.SUCCESS

def output = file("build/generated-build-info/plugin-test-build-info.json")
output.exists() == true

def location = Map.of(
"module", "com.example",
"representative_class", "com/example/Example.class"
)
def expectedOutput = Map.of(
"component", "example-component",
"locations", List.of(location)
)
new ObjectMapper().readValue(output, Map.class) == expectedOutput
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ private TaskProvider<Zip> createBundleTasks(final Project project, PluginPropert
task.getIsLicensed().set(providerFactory.provider(extension::isLicensed));

var mainSourceSet = project.getExtensions().getByType(SourceSetContainer.class).getByName(SourceSet.MAIN_SOURCE_SET_NAME);
FileCollection moduleInfoFile = mainSourceSet.getOutput().getAsFileTree().matching(p -> p.include("module-info.class"));
FileCollection moduleInfoFile = mainSourceSet.getOutput()
.getClassesDirs()
.getAsFileTree()
.matching(p -> p.include("module-info.class"));
task.getModuleInfoFile().setFrom(moduleInfoFile);

});
Expand Down
Loading