Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependency cleanup with grails-bom #411

Merged
merged 13 commits into from
Oct 26, 2024
Merged
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void apply(GeneratorContext generatorContext) {

generatorContext.addDependency(Dependency.builder()
.groupId("com.bertramlabs.plugins")
.lookupArtifactId("asset-pipeline-grails")
.artifactId("asset-pipeline-grails")
.runtime());

final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GradleBuild gradleBuild
)

@seleniumVersion => { @coordinateResolver.apply("selenium-api").getVersion() }
@assetPipelineVersion => { @coordinateResolver.apply("asset-pipeline-grails").getVersion() }
@assetPipelineVersion => { @coordinateResolver.apply("asset-pipeline-gradle").getVersion() }

@for (String importLine : gradleBuild.getPluginsImports()) {
@(importLine)
Expand All @@ -46,18 +46,6 @@ repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

configurations {
all {
@if (features.contains("geb")) {
resolutionStrategy.eachDependency { DependencyResolveDetails details->
if (details.requested.group == 'org.seleniumhq.selenium') {
details.useVersion('@seleniumVersion')
}
}
}
}
}

@dependencies.template(applicationType, project, features, gradleBuild)

@if (features.mainClass().isPresent()) {
Expand All @@ -67,10 +55,8 @@ application {

}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(@features.getTargetJdk())
}
compileJava {
options.release = @features.getTargetJdk()
}

@if (features.contains("jrebel")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import org.grails.forge.feature.Features
@import org.grails.forge.build.gradle.GradleBuild
@import org.grails.forge.build.gradle.GradleDependency
@import org.grails.forge.util.VersionInfo

@args (
ApplicationType applicationType,
Expand All @@ -11,12 +12,15 @@ Features features,
GradleBuild gradleBuild
)

@grailsVersion => { @VersionInfo.getGrailsVersion() }

@if(!gradleBuild.getBuildscriptDependencies().isEmpty()) {
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core/" }
}
dependencies {
implementation platform("org.grails:grails-bom:@grailsVersion")
@for (GradleDependency dependency : gradleBuild.getBuildscriptDependencies()) {
@dependency.toSnippet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GradleBuild gradleBuild
)

dependencies {
implementation platform("org.grails:grails-bom:$grailsVersion")
@for (GradleDependency dependency : gradleBuild.getDependencies()) {
@dependency.toSnippet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Features features)

@grailsGradlePluginVersion => { @coordinateResolver.apply("grails-gradle-plugin").getVersion() }
@viewsGradlePluginVersion => { @coordinateResolver.apply("views-gradle").getVersion() }
@assetPipelineVersion => { @coordinateResolver.apply("asset-pipeline-grails").getVersion() }
@assetPipelineVersion => { @coordinateResolver.apply("asset-pipeline-gradle").getVersion() }

@gradleBuild.renderSettingsExtensions()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,29 @@ public void apply(GeneratorContext generatorContext) {
.artifactId("geb")
.test());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be included as integrationTestImplementation testFixtures('org.grails.plugins:geb')

However, to be able to run the create-functional-test command (which has not been upgraded to a Grails 6 GrailsApplicationCommand), I'm not yet sure what needs to be put where. Is there any point in rewriting the create-functional-test command as a GrailsApplicationCommand now that the grails-shell cli is back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this with a generated app and then make the changes in forge. It was not loading the transitive geb-spock dependency as is, but it wasn't using integrationTestImplementation testFixtures

Copy link
Contributor Author

@jamesfredley jamesfredley Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"integrationTestImplementation testFixtures('org.grails.plugins:geb' worked great and that scope is now an option in forge.

I think we should hold off on command conversions.


generatorContext.addDependency(Dependency.builder()
.groupId("org.gebish")
.artifactId("geb-spock")
.test());

Stream.of("api", "support", "remote-driver")
.map(name -> "selenium-" + name)
.forEach(name -> generatorContext.addDependency(Dependency.builder()
.groupId("org.seleniumhq.selenium")
.lookupArtifactId(name)
.artifactId(name)
.test()));

generatorContext.addDependency(Dependency.builder()
.groupId("org.seleniumhq.selenium")
.lookupArtifactId("selenium-chrome-driver")
.artifactId("selenium-chrome-driver")
.testRuntime());
generatorContext.addDependency(Dependency.builder()
.groupId("org.seleniumhq.selenium")
.lookupArtifactId("selenium-firefox-driver")
.artifactId("selenium-firefox-driver")
.testRuntime());
generatorContext.addDependency(Dependency.builder()
.groupId("org.seleniumhq.selenium")
.lookupArtifactId("selenium-safari-driver")
.artifactId("selenium-safari-driver")
.testRuntime());

TestFramework testFramework = generatorContext.getTestFramework();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void processSelectedFeatures(FeatureContext featureContext) {
public void apply(GeneratorContext generatorContext) {
generatorContext.addDependency(Dependency.builder()
.groupId("org.fusesource.jansi")
.lookupArtifactId("jansi")
.artifactId("jansi")
.runtime());

generatorContext.addDependency(Dependency.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public Options(TestFramework testFramework,
this(testFramework, GormImpl.DEFAULT_OPTION, ServletImpl.DEFAULT_OPTION, javaVersion, operatingSystem, Collections.emptyMap());
}


public Options(TestFramework testFramework,
OperatingSystem operatingSystem) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
39 changes: 2 additions & 37 deletions grails-forge-core/src/main/resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-gradle-plugin</artifactId>
Expand All @@ -30,7 +25,7 @@
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>cache</artifactId>
<version>7.0.0</version>
<version>8.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
Expand Down Expand Up @@ -87,44 +82,14 @@
<artifactId>webdriver-binaries-gradle-plugin</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-safari-driver</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>4.19.1</version>
</dependency>
<dependency>
<groupId>org.zeroturnaround</groupId>
<artifactId>gradle-jrebel-plugin</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.bertramlabs.plugins</groupId>
<artifactId>asset-pipeline-grails</artifactId>
<artifactId>asset-pipeline-gradle</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssetPipelineSpec extends ApplicationContextSpec implements CommandOutputF

then:
template.contains("id \"com.bertramlabs.asset-pipeline\"")
template.contains("runtimeOnly(\"com.bertramlabs.plugins:asset-pipeline-grails:5.0.1\")")
template.contains("runtimeOnly(\"com.bertramlabs.plugins:asset-pipeline-grails\")")
template.contains('''
assets {
minifyJs = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class GebSpec extends ApplicationContextSpec implements CommandOutputFixture {

expect:
buildGradle.contains("testImplementation(\"org.grails.plugins:geb\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-api:4.19.1\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-support:4.19.1\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-remote-driver:4.19.1\")")
buildGradle.contains("testRuntimeOnly(\"org.seleniumhq.selenium:selenium-chrome-driver:4.19.1\")")
buildGradle.contains("testRuntimeOnly(\"org.seleniumhq.selenium:selenium-firefox-driver:4.19.1\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-api\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-support\")")
buildGradle.contains("testImplementation(\"org.seleniumhq.selenium:selenium-remote-driver\")")
buildGradle.contains("testRuntimeOnly(\"org.seleniumhq.selenium:selenium-chrome-driver\")")
buildGradle.contains("testRuntimeOnly(\"org.seleniumhq.selenium:selenium-firefox-driver\")")
}

void "test GebConfig.groovy file is present"() {
Expand All @@ -33,17 +33,6 @@ class GebSpec extends ApplicationContextSpec implements CommandOutputFixture {
output.containsKey('src/integration-test/resources/GebConfig.groovy')
}

void "test build.gradle contains logic to force selenium version"() {
given:
final def output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK))
final def buildGradle = output["build.gradle"]

expect:
buildGradle.contains("if (details.requested.group == 'org.seleniumhq.selenium') {\n" +
" details.useVersion('4.19.1')\n" +
" }")
}

@Unroll
void "test feature geb is not supported for #applicationType application"(ApplicationType applicationType) {
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ScaffoldingSpec extends ApplicationContextSpec implements CommandOutputFix

then:
template.contains('implementation("org.grails.plugins:scaffolding")')
template.contains('runtimeOnly("org.fusesource.jansi:jansi:1.18")')
template.contains('runtimeOnly("org.fusesource.jansi:jansi")')
}

}
Loading