@@ -29,8 +29,9 @@ import org.gradle.api.provider.ListProperty
29
29
import org.gradle.api.provider.Property
30
30
import org.gradle.api.provider.Provider
31
31
import java.io.File
32
+ import javax.inject.Inject
32
33
33
- public abstract class VaadinFlowPluginExtension {
34
+ public abstract class VaadinFlowPluginExtension @Inject constructor( private val project : Project ) {
34
35
/* *
35
36
* Whether we are running in productionMode or not. Defaults to false.
36
37
* Responds to the `-Pvaadin.productionMode` property.
@@ -286,102 +287,104 @@ public abstract class VaadinFlowPluginExtension {
286
287
block.execute(classpathFilter)
287
288
}
288
289
290
+ public val effective: PluginEffectiveConfiguration get() = PluginEffectiveConfiguration .get(project)
291
+
289
292
public companion object {
290
293
public fun get (project : Project ): VaadinFlowPluginExtension =
291
294
project.extensions.getByType(VaadinFlowPluginExtension ::class .java)
292
295
}
293
296
}
294
297
295
- internal class PluginEffectiveConfiguration (
298
+ public class PluginEffectiveConfiguration (
296
299
private val project : Project ,
297
300
extension : VaadinFlowPluginExtension
298
301
) {
299
- val productionMode: Provider <Boolean > = extension.productionMode
302
+ public val productionMode: Provider <Boolean > = extension.productionMode
300
303
.convention(false )
301
304
.overrideWithSystemProperty(" vaadin.productionMode" )
302
305
303
- val sourceSetName: Property <String > = extension.sourceSetName
306
+ public val sourceSetName: Property <String > = extension.sourceSetName
304
307
.convention(" main" )
305
308
306
- val webpackOutputDirectory: Provider <File > = extension.webpackOutputDirectory
309
+ public val webpackOutputDirectory: Provider <File > = extension.webpackOutputDirectory
307
310
.convention(sourceSetName.map { File (project.getBuildResourcesDir(it), Constants .VAADIN_WEBAPP_RESOURCES ) })
308
311
309
- val npmFolder: Provider <File > = extension.npmFolder
312
+ public val npmFolder: Provider <File > = extension.npmFolder
310
313
.convention(project.projectDir)
311
314
312
- val frontendDirectory: Provider <File > = extension.frontendDirectory
315
+ public val frontendDirectory: Provider <File > = extension.frontendDirectory
313
316
.convention(File (project.projectDir, " frontend" ))
314
317
315
- val generateBundle: Provider <Boolean > = extension.generateBundle
318
+ public val generateBundle: Provider <Boolean > = extension.generateBundle
316
319
.convention(true )
317
320
318
- val runNpmInstall: Provider <Boolean > = extension.runNpmInstall
321
+ public val runNpmInstall: Provider <Boolean > = extension.runNpmInstall
319
322
.convention(true )
320
323
321
- val generateEmbeddableWebComponents: Provider <Boolean > = extension.generateEmbeddableWebComponents
324
+ public val generateEmbeddableWebComponents: Provider <Boolean > = extension.generateEmbeddableWebComponents
322
325
.convention(true )
323
326
324
- val frontendResourcesDirectory: Property <File > = extension.frontendResourcesDirectory
327
+ public val frontendResourcesDirectory: Property <File > = extension.frontendResourcesDirectory
325
328
.convention(File (project.projectDir, Constants .LOCAL_FRONTEND_RESOURCES_PATH ))
326
329
327
- val optimizeBundle: Property <Boolean > = extension.optimizeBundle
330
+ public val optimizeBundle: Property <Boolean > = extension.optimizeBundle
328
331
.convention(true )
329
332
330
- val pnpmEnable: Provider <Boolean > = extension.pnpmEnable
333
+ public val pnpmEnable: Provider <Boolean > = extension.pnpmEnable
331
334
.convention(Constants .ENABLE_PNPM_DEFAULT )
332
335
.overrideWithSystemProperty(InitParameters .SERVLET_PARAMETER_ENABLE_PNPM )
333
336
334
- val bunEnable: Provider <Boolean > = extension.bunEnable
337
+ public val bunEnable: Provider <Boolean > = extension.bunEnable
335
338
.convention(Constants .ENABLE_BUN_DEFAULT )
336
339
.overrideWithSystemProperty(InitParameters .SERVLET_PARAMETER_ENABLE_BUN )
337
340
338
- val useGlobalPnpm: Provider <Boolean > = extension.useGlobalPnpm
341
+ public val useGlobalPnpm: Provider <Boolean > = extension.useGlobalPnpm
339
342
.convention(Constants .GLOBAL_PNPM_DEFAULT )
340
343
.overrideWithSystemProperty(InitParameters .SERVLET_PARAMETER_GLOBAL_PNPM )
341
344
342
- val requireHomeNodeExec: Property <Boolean > = extension.requireHomeNodeExec
345
+ public val requireHomeNodeExec: Property <Boolean > = extension.requireHomeNodeExec
343
346
.convention(false )
344
347
345
- val eagerServerLoad: Provider <Boolean > = extension.eagerServerLoad
348
+ public val eagerServerLoad: Provider <Boolean > = extension.eagerServerLoad
346
349
.convention(false )
347
350
.overrideWithSystemProperty(" vaadin.eagerServerLoad" )
348
351
349
- val applicationProperties: Property <File > = extension.applicationProperties
352
+ public val applicationProperties: Property <File > = extension.applicationProperties
350
353
.convention(File (project.projectDir, " src/main/resources/application.properties" ))
351
354
352
- val openApiJsonFile: Property <File > = extension.openApiJsonFile
355
+ public val openApiJsonFile: Property <File > = extension.openApiJsonFile
353
356
.convention(project.layout.buildDirectory.file(" generated-resources/openapi.json" ).asFile())
354
357
355
- val javaSourceFolder: Property <File > = extension.javaSourceFolder
358
+ public val javaSourceFolder: Property <File > = extension.javaSourceFolder
356
359
.convention(File (project.projectDir, " src/main/java" ))
357
360
358
- val javaResourceFolder: Property <File > = extension.javaResourceFolder
361
+ public val javaResourceFolder: Property <File > = extension.javaResourceFolder
359
362
.convention(File (project.projectDir, " src/main/resources" ))
360
363
361
- val generatedTsFolder: Property <File > = extension.generatedTsFolder
364
+ public val generatedTsFolder: Property <File > = extension.generatedTsFolder
362
365
.convention(File (project.projectDir, " frontend/generated" ))
363
366
364
- val nodeVersion: Property <String > = extension.nodeVersion
367
+ public val nodeVersion: Property <String > = extension.nodeVersion
365
368
.convention(FrontendTools .DEFAULT_NODE_VERSION )
366
369
367
- val nodeDownloadRoot: Property <String > = extension.nodeDownloadRoot
370
+ public val nodeDownloadRoot: Property <String > = extension.nodeDownloadRoot
368
371
.convention(Platform .guess().nodeDownloadRoot)
369
372
370
- val nodeAutoUpdate: Property <Boolean > = extension.nodeAutoUpdate
373
+ public val nodeAutoUpdate: Property <Boolean > = extension.nodeAutoUpdate
371
374
.convention(false )
372
375
373
- val resourceOutputDirectory: Property <File > = extension.resourceOutputDirectory
376
+ public val resourceOutputDirectory: Property <File > = extension.resourceOutputDirectory
374
377
.convention(project.layout.buildDirectory.dir(" vaadin-generated" ).asFile())
375
378
376
- val projectBuildDir: Property <String > = extension.projectBuildDir
379
+ public val projectBuildDir: Property <String > = extension.projectBuildDir
377
380
.convention(project.layout.buildDirectory.map { it.asFile.toString() })
378
381
379
- val postinstallPackages: ListProperty <String > = extension.postinstallPackages
382
+ public val postinstallPackages: ListProperty <String > = extension.postinstallPackages
380
383
.convention(listOf ())
381
384
382
- val classpathFilter = extension.classpathFilter
385
+ public val classpathFilter: ClasspathFilter = extension.classpathFilter
383
386
384
- val dependencyScope: Property <String > = extension.dependencyScope
387
+ public val dependencyScope: Property <String > = extension.dependencyScope
385
388
.convention(sourceSetName.map {
386
389
if (it == " main" ) {
387
390
" runtimeClasspath"
@@ -390,7 +393,7 @@ internal class PluginEffectiveConfiguration(
390
393
}
391
394
})
392
395
393
- val processResourcesTaskName: Property <String > = extension.processResourcesTaskName
396
+ public val processResourcesTaskName: Property <String > = extension.processResourcesTaskName
394
397
.convention(sourceSetName.map {
395
398
if (it == " main" ) {
396
399
" processResources"
@@ -399,29 +402,29 @@ internal class PluginEffectiveConfiguration(
399
402
}
400
403
})
401
404
402
- val frontendHotdeploy: Provider <Boolean > = extension.frontendHotdeploy
405
+ public val frontendHotdeploy: Provider <Boolean > = extension.frontendHotdeploy
403
406
.convention(FrontendUtils .isHillaUsed(frontendDirectory.get()))
404
407
.overrideWithSystemProperty(InitParameters .FRONTEND_HOTDEPLOY )
405
408
406
- val ciBuild: Provider <Boolean > = extension.ciBuild
409
+ public val ciBuild: Provider <Boolean > = extension.ciBuild
407
410
.convention(false )
408
411
.overrideWithSystemProperty(InitParameters .CI_BUILD )
409
412
410
- val skipDevBundleBuild: Property <Boolean > = extension.skipDevBundleBuild
413
+ public val skipDevBundleBuild: Property <Boolean > = extension.skipDevBundleBuild
411
414
.convention(false )
412
415
413
- val forceProductionBuild: Provider <Boolean > = extension.forceProductionBuild
416
+ public val forceProductionBuild: Provider <Boolean > = extension.forceProductionBuild
414
417
.convention(false )
415
418
.overrideWithSystemProperty(InitParameters .FORCE_PRODUCTION_BUILD )
416
419
417
- val alwaysExecutePrepareFrontend: Property <Boolean > = extension.alwaysExecutePrepareFrontend
420
+ public val alwaysExecutePrepareFrontend: Property <Boolean > = extension.alwaysExecutePrepareFrontend
418
421
.convention(false )
419
422
420
- val reactEnable: Provider <Boolean > = extension.reactEnable
423
+ public val reactEnable: Provider <Boolean > = extension.reactEnable
421
424
.convention(FrontendUtils .isReactRouterRequired(frontendDirectory.get()))
422
425
.overrideWithSystemProperty(InitParameters .REACT_ENABLE )
423
426
424
- var cleanFrontendFiles: Property <Boolean > = extension.cleanFrontendFiles
427
+ public val cleanFrontendFiles: Property <Boolean > = extension.cleanFrontendFiles
425
428
.convention(true )
426
429
/* *
427
430
* Finds the value of a boolean property. It searches in gradle and system properties.
@@ -436,7 +439,7 @@ internal class PluginEffectiveConfiguration(
436
439
project.getBooleanProperty(propertyName) ? : originalValue
437
440
}
438
441
439
- override fun toString (): String = " VaadinFlowPluginExtension (" +
442
+ override fun toString (): String = " PluginEffectiveConfiguration (" +
440
443
" productionMode=${productionMode.get()} , " +
441
444
" webpackOutputDirectory=${webpackOutputDirectory.get()} , " +
442
445
" npmFolder=${npmFolder.get()} , " +
@@ -473,8 +476,8 @@ internal class PluginEffectiveConfiguration(
473
476
" reactEnable=${reactEnable.get()} ," +
474
477
" cleanFrontendFiles=${cleanFrontendFiles.get()} " +
475
478
" )"
476
- companion object {
477
- internal fun get (project : Project ): PluginEffectiveConfiguration =
479
+ public companion object {
480
+ public fun get (project : Project ): PluginEffectiveConfiguration =
478
481
PluginEffectiveConfiguration (project, VaadinFlowPluginExtension .get(project))
479
482
}
480
483
}
0 commit comments