Skip to content

Commit

Permalink
Handle deprecated Gradle properties "archiveName" and "extension"
Browse files Browse the repository at this point in the history
The following output was shown when running `gradle help --warning-mode all`
for a Jenkins plugin that is based on this one:

> The archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead.
> The extension property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveExtension property instead.

These new properties are implemented as `Property` instead of `String` now.
Therefore the `get()` calls in the test.
  • Loading branch information
darxriggs committed Dec 21, 2019
1 parent 06124a7 commit e30f50f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.gradle.api.tasks.bundling.War
import org.gradle.api.tasks.compile.GroovyCompile
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.util.GradleVersion

import static org.gradle.api.logging.LogLevel.INFO
import static org.gradle.api.plugins.JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME
Expand Down Expand Up @@ -194,8 +195,13 @@ class JpiPlugin implements Plugin<Project> {
project.afterEvaluate {
war.configure {
it.description = 'Generates the JPI package'
it.archiveName = "${jpiExtension.shortName}.${jpiExtension.fileExtension}"
it.extension = jpiExtension.fileExtension
if (GradleVersion.current() >= GradleVersion.version('5.0')) {
it.archiveFileName = "${jpiExtension.shortName}.${jpiExtension.fileExtension}"
it.archiveExtension = jpiExtension.fileExtension
} else {
it.archiveName = "${jpiExtension.shortName}.${jpiExtension.fileExtension}"
it.extension = jpiExtension.fileExtension
}
it.classpath -= project.sourceSets.main.output
it.classpath(jar)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.War
import org.gradle.testfixtures.ProjectBuilder
import org.gradle.util.GradleVersion
import spock.lang.Specification

class JpiPluginSpec extends Specification {
Expand Down Expand Up @@ -95,15 +96,20 @@ class JpiPluginSpec extends Specification {
task != null
task.description != null
task.group == BasePlugin.BUILD_GROUP
task.archiveName == archiveName
task.extension == extension
if (GradleVersion.current() >= GradleVersion.version('5.0')) {
task.archiveFileName.get() == fileName
task.archiveExtension.get() == extension
} else {
task.archiveName == fileName
task.extension == extension
}
Task jpi = project.tasks[JpiPlugin.JPI_TASK_NAME]
jpi != null
jpi.description != null
jpi.group == BasePlugin.BUILD_GROUP

where:
name | extension || archiveName
name | extension || fileName
'' | 'jpi' || 'test.jpi'
null | 'jpi' || 'test.jpi'
'foo' | 'jpi' || 'foo.jpi'
Expand Down

0 comments on commit e30f50f

Please sign in to comment.