Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit 6a068b7

Browse files
committed
Fix Gradle 6 warnings and issues (#289)
1 parent e146c4b commit 6a068b7

10 files changed

+112
-40
lines changed

src/functionalTest/groovy/com/devsoap/vaadinflow/FunctionalTest.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FunctionalTest extends Specification {
3636

3737
static final String PLUGIN_ID = 'com.devsoap.vaadin-flow'
3838

39-
static final String DEFAULT_TEST_VAADIN_VERSION = '14.0.3'
39+
static final String DEFAULT_TEST_VAADIN_VERSION = '14.0.11'
4040

4141
@Rule
4242
protected TemporaryFolder testProjectDir

src/functionalTest/groovy/com/devsoap/vaadinflow/GradleVersionSmokeTest.groovy

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import spock.lang.Unroll
3131
@Smoke
3232
class GradleVersionSmokeTest extends FunctionalTest {
3333

34-
private static final List<String> VERSIONS = ['5.6']
34+
private static final List<String> VERSIONS = ['5.6', '6.0-rc-2']
3535

3636
@Unroll
3737
void 'Test Gradle #version'(String version) {
@@ -41,7 +41,10 @@ class GradleVersionSmokeTest extends FunctionalTest {
4141
'''.stripIndent()
4242
run( { it.withGradleVersion(version) }, 'vaadinCreateProject')
4343
when:
44-
BuildResult result = run( { it.withGradleVersion(version) }, 'jar')
44+
BuildResult result = run( {
45+
it.withGradleVersion(version)
46+
it.arguments = ['--warning-mode', 'all'] + it.arguments
47+
}, 'jar')
4548
then:
4649
result.task(':jar').outcome == TaskOutcome.SUCCESS
4750
!result.output.contains('Deprecated Gradle features')

src/main/groovy/com/devsoap/vaadinflow/VaadinFlowPlugin.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class VaadinFlowPlugin implements Plugin<Project> {
6666
static final String PLUGIN_ID = 'com.devsoap.vaadin-flow'
6767
static final String PRODUCT_NAME = 'gradle-vaadin-flow'
6868

69-
private static final String COMPILE_CONFIGURATION = 'compile'
69+
private static final String COMPILE_CONFIGURATION = 'implementation'
7070
private final List<PluginAction> actions = []
7171

7272
@Inject

src/main/groovy/com/devsoap/vaadinflow/extensions/VaadinFlowPluginExtension.groovy

+45-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.devsoap.vaadinflow.extensions
1919

2020
import com.devsoap.license.Validator
2121
import com.devsoap.vaadinflow.VaadinFlowPlugin
22+
import com.devsoap.vaadinflow.models.ProjectType
2223
import com.devsoap.vaadinflow.util.Versions
2324
import groovy.util.logging.Log
2425
import org.gradle.api.GradleException
@@ -27,9 +28,13 @@ import org.gradle.api.artifacts.Dependency
2728
import org.gradle.api.artifacts.dsl.DependencyHandler
2829
import org.gradle.api.artifacts.dsl.RepositoryHandler
2930
import org.gradle.api.artifacts.repositories.ArtifactRepository
31+
import org.gradle.api.file.SourceDirectorySet
3032
import org.gradle.api.plugins.ExtraPropertiesExtension
33+
import org.gradle.api.plugins.JavaPluginConvention
3134
import org.gradle.api.provider.ListProperty
3235
import org.gradle.api.provider.Property
36+
import org.gradle.api.tasks.SourceSet
37+
import org.gradle.util.RelativePathUtil
3338

3439
/**
3540
* The main plugin extension
@@ -41,16 +46,18 @@ import org.gradle.api.provider.Property
4146
class VaadinFlowPluginExtension {
4247

4348
static final String NAME = VAADIN
44-
static final String GROUP = 'com.vaadin'
49+
static final String GROUP = VAADIN_ROOT_PACKAGE
4550
static final String VAADIN = 'vaadin'
4651

4752
private static final String COLON = ':'
48-
private static final String COMPILE = 'compile'
53+
private static final String COMPILE = 'implementation'
4954
private static final String BOM_ARTIFACT_NAME = 'bom'
5055
private static final String VAADIN_VERSION_PROPERTY = 'vaadinVersion'
5156
private static final String LUMO = 'lumo'
5257
private static final String TRUE = 'true'
5358
private static final String COMPATIBILITY_MODE_PROPERTY = 'vaadin.compatibilityMode'
59+
private static final String VAADIN_ROOT_PACKAGE = 'com.vaadin'
60+
private static final String GROOVY_STRING = 'groovy'
5461

5562
private final Property<String> version
5663
private final Property<Boolean> unsupportedVersion
@@ -224,9 +231,42 @@ class VaadinFlowPluginExtension {
224231

225232
/**
226233
* Get an optional whitelist with packages to scan
234+
*
235+
* Defaults to all project packages as well as com.vaadin-packages
227236
*/
228237
Collection<String> getWhitelistedPackages() {
229-
whitelistedPackages.getOrElse([])
238+
if (whitelistedPackages.present && !whitelistedPackages.get().empty) {
239+
return whitelistedPackages.get()
240+
}
241+
242+
LOGGER.info('Returning default whitelisted packages...')
243+
List<String> defaultPackages = [VAADIN_ROOT_PACKAGE]
244+
ProjectType type = ProjectType.get(project)
245+
JavaPluginConvention javaPlugin = project.convention.getPlugin(JavaPluginConvention)
246+
247+
List<SourceDirectorySet> sourceDirectories = []
248+
249+
SourceSet mainSourceSet = javaPlugin.sourceSets.main
250+
sourceDirectories.add(mainSourceSet.java)
251+
252+
if (mainSourceSet.hasProperty(GROOVY_STRING)) {
253+
sourceDirectories.add(mainSourceSet.groovy)
254+
}
255+
256+
if (mainSourceSet.hasProperty('kotlin')) {
257+
sourceDirectories.add(mainSourceSet.kotlin)
258+
}
259+
260+
sourceDirectories.each { srcDirSet ->
261+
File srcDir = srcDirSet.sourceDirectories.first()
262+
defaultPackages += mainSourceSet.allSource
263+
.filter { File f -> f.path.endsWith(".${type.extension}") }
264+
.filter { File f -> f.exists() }
265+
.collect { File f -> RelativePathUtil.relativePath(srcDir, f.parentFile) }
266+
.findAll { String path -> !path.startsWith('..') }
267+
.collect { String path -> path.replace('/', '.').trim() }
268+
}
269+
defaultPackages.unique()
230270
}
231271

232272
/**
@@ -263,7 +303,7 @@ class VaadinFlowPluginExtension {
263303

264304
DependencyHandler dh = dependencyHandler // Because Groovy bug hiding this private field from closure
265305

266-
project.plugins.withId('groovy') {
306+
project.plugins.withId(GROOVY_STRING) {
267307
dh.add(COMPILE, groovy())
268308
}
269309

@@ -460,7 +500,7 @@ class VaadinFlowPluginExtension {
460500
}
461501

462502
/**
463-
* Provides a clusure that will exclude all Vaadin theme dependencies
503+
* Provides a closure that will exclude all Vaadin theme dependencies
464504
*/
465505
private final Closure<Void> excludeThemesConfiguration = {
466506
exclude group: GROUP, module: 'vaadin-material-theme'

src/main/groovy/com/devsoap/vaadinflow/tasks/AssembleClientDependenciesTask.groovy

+15-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.gradle.api.GradleException
2626
import org.gradle.api.file.CopySpec
2727
import org.gradle.api.file.RegularFileProperty
2828
import org.gradle.api.tasks.CacheableTask
29+
import org.gradle.api.tasks.Internal
30+
import org.gradle.api.tasks.LocalState
2931
import org.gradle.api.tasks.TaskAction
3032

3133
import java.nio.file.Paths
@@ -48,19 +50,21 @@ class AssembleClientDependenciesTask extends DefaultTask {
4850
private static final String VAADIN = 'VAADIN'
4951
private static final String BUILD = 'build'
5052
private static final String WEBCOMPONENTS_LOADER = 'webcomponents-loader.js'
51-
public static final String BUNDLES = 'bundles/*.js'
5253

53-
final File frontendBuildDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
54-
final File sourceDirEs5 = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR + '/build/frontend-es5')
55-
final File sourceDirEs6 = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR + '/build/frontend-es6')
54+
protected static final String BUNDLES = 'bundles/*.js'
5655

57-
final File webAppGenDir = new File(project.buildDir, 'webapp-gen')
58-
final File webAppGenFrontendDir = new File(webAppGenDir, FRONTEND)
56+
protected final File frontendBuildDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
57+
protected final File sourceDirEs5 = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR +
58+
'/build/frontend-es5')
59+
protected final File sourceDirEs6 = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR +
60+
'/build/frontend-es6')
5961

60-
final File targetDirEs5 = new File(webAppGenDir, 'frontend-es5')
61-
final File targetDirEs6 = new File(webAppGenDir, 'frontend-es6')
62+
protected final File webAppGenDir = new File(project.buildDir, 'webapp-gen')
63+
protected final File webAppGenFrontendDir = new File(webAppGenDir, FRONTEND)
64+
protected final File targetDirEs5 = new File(webAppGenDir, 'frontend-es5')
65+
protected final File targetDirEs6 = new File(webAppGenDir, 'frontend-es6')
6266

63-
final RegularFileProperty webappDir = project.objects.fileProperty()
67+
protected final RegularFileProperty webappDir = project.objects.fileProperty()
6468

6569
/**
6670
* Assembles the built client artifacts into the webapp frontend directories
@@ -196,6 +200,7 @@ class AssembleClientDependenciesTask extends DefaultTask {
196200
/**
197201
* Get the webapp directory which contains the frontend directory
198202
*/
203+
@Internal
199204
File getWebappDir() {
200205
webappDir.getOrElse(null)?.asFile ?: project.file('src/main/webapp')
201206
}
@@ -210,6 +215,7 @@ class AssembleClientDependenciesTask extends DefaultTask {
210215
/**
211216
* Has the webapp directory been set by the user?
212217
*/
218+
@Internal
213219
boolean isWebappDirSet() {
214220
webappDir.present
215221
}

src/main/groovy/com/devsoap/vaadinflow/tasks/InstallYarnDependenciesTask.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class InstallYarnDependenciesTask extends DefaultTask {
5050
private static final String PACKAGE_JSON = 'package.json'
5151
private static final String NODE_MODULES = 'node_modules'
5252

53-
final File workingDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
54-
final File distDir = new File(workingDir, 'dist')
53+
protected final File workingDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
54+
protected final File distDir = new File(workingDir, 'dist')
5555

56-
final VaadinYarnRunner yarnRunner = new VaadinYarnRunner(project, workingDir)
56+
protected final VaadinYarnRunner yarnRunner = new VaadinYarnRunner(project, workingDir)
5757

5858
@OutputFile
5959
final File appPackageJson = new File(distDir, PACKAGE_JSON)

src/main/groovy/com/devsoap/vaadinflow/tasks/NodeSetupTask.groovy

+6
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ class NodeSetupTask extends DefaultTask {
197197
ivy NodeSetupTask.IVY_XML_PATH
198198
}
199199
}
200+
if (IvyArtifactRepository.metaClass.respondsTo(this, 'metadataSources', Closure)) {
201+
//Gradle 6 ->
202+
metadataSources {
203+
artifact()
204+
}
205+
}
200206
}
201207
}
202208

src/main/groovy/com/devsoap/vaadinflow/tasks/TranspileDependenciesTask.groovy

+21-11
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ import org.gradle.api.GradleException
3636
import org.gradle.api.file.CopySpec
3737
import org.gradle.api.provider.ListProperty
3838
import org.gradle.api.tasks.CacheableTask
39+
import org.gradle.api.tasks.Input
3940
import org.gradle.api.tasks.InputDirectory
4041
import org.gradle.api.tasks.InputFile
4142
import org.gradle.api.tasks.Internal
4243
import org.gradle.api.tasks.Optional
4344
import org.gradle.api.tasks.OutputDirectory
4445
import org.gradle.api.tasks.OutputFile
46+
import org.gradle.api.tasks.PathSensitive
47+
import org.gradle.api.tasks.PathSensitivity
4548
import org.gradle.api.tasks.TaskAction
4649
import org.gradle.api.tasks.options.Option
4750
import org.gradle.internal.hash.HashUtil
@@ -88,12 +91,12 @@ class TranspileDependenciesTask extends DefaultTask {
8891
private static final String RUN_WITH_INFO_FOR_MORE_INFORMATION = 'Run with --info to get more information.'
8992
private static final String VAADIN_FLOW_PACKAGE = 'com.vaadin.flow'
9093

91-
final File workingDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
92-
final VaadinYarnRunner yarnRunner = new VaadinYarnRunner(project, workingDir)
93-
final File srcDir = new File(workingDir, 'src')
94-
final File webappGenDir = new File(project.buildDir, 'webapp-gen')
95-
final File webappGenFrontendDir = new File(webappGenDir, FRONTEND)
96-
final Closure<File> configDir = {
94+
protected final File workingDir = project.file(VaadinClientDependenciesExtension.FRONTEND_BUILD_DIR)
95+
protected final VaadinYarnRunner yarnRunner = new VaadinYarnRunner(project, workingDir)
96+
protected final File srcDir = new File(workingDir, 'src')
97+
protected final File webappGenDir = new File(project.buildDir, 'webapp-gen')
98+
protected final File webappGenFrontendDir = new File(webappGenDir, FRONTEND)
99+
protected final Closure<File> configDir = {
97100
File rootDir = SpringBootAction.isActive(project) ? webappGenDir :
98101
Paths.get(project.buildDir.canonicalPath, 'resources', 'main').toFile()
99102
Paths.get(rootDir.canonicalPath, 'META-INF', VAADIN, 'config').toFile()
@@ -109,20 +112,23 @@ class TranspileDependenciesTask extends DefaultTask {
109112
@Deprecated
110113
@Optional
111114
@InputDirectory
115+
@PathSensitive(PathSensitivity.ABSOLUTE)
112116
final Closure<File> webappGenFrontendStylesDir = {
113117
new File(webappGenFrontendDir, STYLES).with { it.exists() ? it : null }
114118
}
115119

116120
@Deprecated
117121
@Optional
118122
@InputDirectory
123+
@PathSensitive(PathSensitivity.ABSOLUTE)
119124
final Closure<File> webappGenFrontendTemplatesDir = {
120125
new File(webappGenFrontendDir, TEMPLATES).with { it.exists() ? it : null }
121126
}
122127

123128
@Deprecated
124129
@Optional
125130
@InputDirectory
131+
@PathSensitive(PathSensitivity.ABSOLUTE)
126132
final Closure<File> webTemplatesDir = {
127133
AssembleClientDependenciesTask assembleTask = project.tasks.findByName(AssembleClientDependenciesTask.NAME)
128134
Paths.get(assembleTask.webappDir.canonicalPath, FRONTEND, TEMPLATES).toFile().with { it.exists() ? it : null }
@@ -131,12 +137,14 @@ class TranspileDependenciesTask extends DefaultTask {
131137
@Deprecated
132138
@Optional
133139
@InputDirectory
140+
@PathSensitive(PathSensitivity.ABSOLUTE)
134141
final Closure<File> webStylesDir = {
135142
AssembleClientDependenciesTask assembleTask = project.tasks.findByName(AssembleClientDependenciesTask.NAME)
136143
Paths.get(assembleTask.webappDir.canonicalPath, FRONTEND, STYLES).toFile().with { it.exists() ? it : null }
137144
}
138145

139146
@InputDirectory
147+
@PathSensitive(PathSensitivity.ABSOLUTE)
140148
final File nodeModules = new File(workingDir, NODE_MODULES)
141149

142150
@Optional
@@ -149,18 +157,21 @@ class TranspileDependenciesTask extends DefaultTask {
149157
@Deprecated
150158
@Optional
151159
@InputDirectory
160+
@PathSensitive(PathSensitivity.ABSOLUTE)
152161
final Closure<File> bowerComponents = {
153162
new File(workingDir, BOWER_COMPONENTS).with { it.exists() ? it : null }
154163
}
155164

156165
@Optional
157166
@InputDirectory
167+
@PathSensitive(PathSensitivity.ABSOLUTE)
158168
final Closure<File> unpackedStaticResources = {
159169
new File(workingDir, 'static').with { it.exists() ? it : null }
160170
}
161171

162172
@Optional
163173
@InputDirectory
174+
@PathSensitive(PathSensitivity.ABSOLUTE)
164175
final Closure<File> stylesheetsSources = {
165176
Paths.get(project.projectDir.canonicalPath,
166177
JavaPluginAction.STYLESHEETS_SOURCES.split(SLASH))
@@ -169,13 +180,15 @@ class TranspileDependenciesTask extends DefaultTask {
169180

170181
@Optional
171182
@InputDirectory
183+
@PathSensitive(PathSensitivity.ABSOLUTE)
172184
final Closure<File> javascriptSources = {
173185
Paths.get(project.projectDir.canonicalPath,
174186
JavaPluginAction.JAVASCRIPT_SOURCES.split(SLASH))
175187
.toFile().with { it.exists() ? it : null }
176188
}
177189

178190
@InputFile
191+
@PathSensitive(PathSensitivity.ABSOLUTE)
179192
final File packageJson = new File(workingDir, PACKAGE_JSON_FILE)
180193

181194
@Optional
@@ -286,7 +299,6 @@ class TranspileDependenciesTask extends DefaultTask {
286299
}
287300
}
288301

289-
@Internal
290302
@PackageScope
291303
void bundle(ScanResult scan) {
292304

@@ -384,7 +396,6 @@ class TranspileDependenciesTask extends DefaultTask {
384396
}
385397
}
386398

387-
@Internal
388399
@PackageScope
389400
void checkIdUsage(ScanResult scan) {
390401
if (!ignoreIdUsage) {
@@ -400,7 +411,6 @@ class TranspileDependenciesTask extends DefaultTask {
400411
}
401412
}
402413

403-
@Internal
404414
@PackageScope
405415
void checkJsModulesInCompatibilityMode(ScanResult scan) {
406416
Map<String,String> modules = ClassIntrospectionUtils
@@ -416,7 +426,6 @@ class TranspileDependenciesTask extends DefaultTask {
416426
}
417427
}
418428

419-
@Internal
420429
@PackageScope
421430
void checkCssImportsInCompatibilityMode(ScanResult scan) {
422431
Map<String,String> imports = ClassIntrospectionUtils
@@ -505,7 +514,6 @@ class TranspileDependenciesTask extends DefaultTask {
505514
}
506515
}
507516

508-
@Internal
509517
@PackageScope
510518
void bundleInCompatibilityMode(ScanResult scan) {
511519
LOGGER.info('Searching for HTML imports...')
@@ -570,6 +578,7 @@ class TranspileDependenciesTask extends DefaultTask {
570578
* @deprecated since 1.3 in favour of importExcludes
571579
*/
572580
@Deprecated
581+
@Internal
573582
List<String> getBundleExcludes() {
574583
VaadinFlowPluginExtension vaadin = project.extensions.getByType(VaadinFlowPluginExtension)
575584
if (vaadin.compatibilityMode) {
@@ -581,6 +590,7 @@ class TranspileDependenciesTask extends DefaultTask {
581590
/**
582591
* Get import exclusions
583592
*/
593+
@Input
584594
List<String> getImportExcludes() {
585595
importExcludes.getOrElse([])
586596
}

0 commit comments

Comments
 (0)