dweiss commented on code in PR #14862: URL: https://github.com/apache/lucene/pull/14862#discussion_r2173824500
########## build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaFolderLayoutPlugin.java: ########## @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.lucene.gradle.plugins.java; + +import java.io.File; +import java.util.List; +import org.gradle.api.GradleException; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.artifacts.ConfigurationContainer; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; +import org.gradle.language.jvm.tasks.ProcessResources; + +/** Configure up non-standard, legacy folder structure in Lucene projects. */ +public class JavaFolderLayoutPlugin implements Plugin<Project> { + @Override + public void apply(Project project) { + JavaPlugin javaPlugin = project.getPlugins().findPlugin(JavaPlugin.class); + if (javaPlugin == null) { + throw new GradleException( + getClass().getName() + + " should be applied to java projects only (after the java plugin is applied)."); + } + + JavaPluginExtension javaExt = project.getExtensions().getByType(JavaPluginExtension.class); + SourceSetContainer sourceSets = javaExt.getSourceSets(); + + SourceSet mainSrcSet = sourceSets.named("main").get(); + mainSrcSet.java(srcSetDir -> srcSetDir.setSrcDirs(List.of("src/java"))); + mainSrcSet.resources(resources -> resources.setSrcDirs(List.of("src/resources"))); + + SourceSet testSrcSet = sourceSets.named("test").get(); + testSrcSet.java(srcSetDir -> srcSetDir.setSrcDirs(List.of("src/test"))); + testSrcSet.resources(resources -> resources.setSrcDirs(List.of("src/test-files"))); + Review Comment: I agree. This has become such a black magic that anything that lowers the entry bar is worth the effort. Using java may be more verbose but at least it's understandable what's going on. Groovy is great but - as anywhere - dynamic properties and no types make it a headache to figure out what's going on. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org