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

Allow External Plugins to use StandaloneRestTestPlugin gradle plugin #2811

Open
jmazanec15 opened this issue Apr 7, 2022 · 4 comments
Open
Labels
enhancement Enhancement or improvement to existing feature or request Plugins

Comments

@jmazanec15
Copy link
Member

Is your feature request related to a problem? Please describe.
For the k-NN plugin, I wanted to clean up our build.gradle a little bit and pull BWC tests out into a separate subproject. For this, I would like to apply the StandaloneRestTestPlugin or StandaloneTestPlugin as is done for OpenSearch.

However, I am unable to apply the plugin because it adds a project dependency on test-framework, which external plugins do not have access to.

I am wondering if it is possible to modify this so that external plugins can use this gradle plugin? External plugins are able to add dependencies like this:

testImplementation "org.opensearch.test:framework:${opensearch_version}"

Describe the solution you'd like
StandaloneRestTestPlugin can be applied to external plugin build scripts.

Describe alternatives you've considered
Currently, in opensearch-project/k-NN#359, I apply the opensearch build plugin and disable several tasks it adds.

@jmazanec15 jmazanec15 added enhancement Enhancement or improvement to existing feature or request untriaged labels Apr 7, 2022
@jmazanec15
Copy link
Member Author

Specifically, I was thinking something like this: jmazanec15@ba391b1. Going to try it out locally to see if it works for my use case.

@jmazanec15
Copy link
Member Author

Im wondering if something like this would make sense:

// For internal projects, using the project test framework dependency. Otherwise, use the opensearch test
// framework one
if (project.rootProject.name == "OpenSearch" && project.project(':test:framework') != null) {
    project.dependencies.add('testImplementation', project.project(':test:framework'))
    EclipseModel eclipse = project.extensions.getByType(EclipseModel)
    eclipse.classpath.sourceSets = [testSourceSet]
    eclipse.classpath.plusConfigurations = [project.configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)]

    IdeaModel idea = project.extensions.getByType(IdeaModel)
    idea.module.testSourceDirs += testSourceSet.java.srcDirs
    idea.module.scopes.put('TEST', [plus: [project.configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)]] as Map<String, Collection<Configuration>>)
}

jmazanec15@ba391b1 fails because the plugins don't have the Idea/Eclipse Models. In addition, the above snippet removes the auto addition of the dependency so that external projects can configure it to whatever version they want.

This would then require plugins to add their own dependency on test-framework. This seems okay to me, but want to get feedback from team on this.

@minalsha
Copy link
Contributor

IS this blocking your team? @jmazanec15

@jmazanec15
Copy link
Member Author

@minalsha Not blocked but would be nice to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Plugins
Projects
None yet
Development

No branches or pull requests

3 participants