dev.hilla.gradle.plugin.HillaPlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hilla-gradle-plugin Show documentation
Show all versions of hilla-gradle-plugin Show documentation
This maven module act as a proxy to test, build, and release the hilla gradle plugin,
which is written in Kotlin and is built by gradle natively. This makes development
and testing of the gradle plugin much easier against the changes of flow, especially
the engine-core. However, publishing the hilla-gradle-plugin to gradle plugin
central repo is done within platform final releases.
/**
* Copyright 2000-2023 Vaadin Ltd
*
* Licensed 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 dev.hilla.gradle.plugin
import com.vaadin.gradle.VaadinFlowPluginExtension
import com.vaadin.gradle.VaadinPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.bundling.Jar
/**
* The main class of the Hilla Gradle Plugin
*/
public class HillaPlugin : Plugin {
override fun apply(project: Project) {
// we need Java Plugin conventions so that we can ensure the order of tasks
project.pluginManager.apply(JavaPlugin::class.java)
// we apply Vaadin (flow) plugin so that the users do not need to add it themselves
// to leverage from vaadinPrepareFrontend and vaadinBuildFrontend:
project.pluginManager.apply(VaadinPlugin::class.java)
project.tasks.replace("vaadinBuildFrontend", HillaBuildFrontendTask::class.java)
val extensionName = "hilla"
project.extensions.create(extensionName, EngineProjectExtension::class.java, project)
project.tasks.apply {
register("hillaConfigure", EngineConfigureTask::class.java)
register("hillaGenerate", EngineGenerateTask::class.java)
register("hillaInitApp", EngineInitAppTask::class.java)
}
project.tasks.named("processResources") {
val copyTask = it as? Copy
if (copyTask != null) {
copyTask.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
project.afterEvaluate {
val extension: EngineProjectExtension = EngineProjectExtension.get(it)
extension.autoconfigure(it)
if (extension.productionMode) {
// this will also catch the War task since it extends from Jar
project.tasks.withType(Jar::class.java) { task: Jar ->
task.dependsOn("vaadinBuildFrontend")
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy