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 @@ -207,6 +207,10 @@ public Builder profile() {
return scope(Scope.PROFILE);
}

public Builder integrationTestImplementationTestFixtures() {
return scope(Scope.INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES);
}

public Builder annotationProcessor(boolean requiresPriority) {
this.annotationProcessorPriority = requiresPriority;
return annotationProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public enum Phase {
RUNTIME,
OPENREWRITE,
BUILD,
PROFILE
PROFILE,
INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class Scope {
public static final Scope TEST_RUNTIME = new Scope(Source.TEST, Collections.singletonList(Phase.RUNTIME));
public static final Scope OPENREWRITE = new Scope(Source.MAIN, Collections.singletonList(Phase.OPENREWRITE));
public static final Scope PROFILE = new Scope(Source.MAIN, Collections.singletonList(Phase.PROFILE));
public static final Scope INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES = new Scope(Source.MAIN, Collections.singletonList(Phase.INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES));


@NonNull
private Source source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ public enum GradleConfiguration implements Ordered {
RUNTIME_ONLY("runtimeOnly", 7),
TEST_ANNOTATION_PROCESSOR("testAnnotationProcessor", 8),
TEST_KAPT("kaptTest", 9),
TEST_IMPLEMENTATION("testImplementation", 10),
TEST_COMPILE_ONLY("testCompileOnly", 11),
TEST_RUNTIME_ONLY("testRuntimeOnly", 12),
OPENREWRITE("rewrite", 13);
INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES("integrationTestImplementation testFixtures", 10),
TEST_IMPLEMENTATION("testImplementation", 11),
TEST_COMPILE_ONLY("testCompileOnly", 12),
TEST_RUNTIME_ONLY("testRuntimeOnly", 13),
OPENREWRITE("rewrite", 14);

private final String configurationName;
private final int order;
Expand Down Expand Up @@ -99,6 +100,9 @@ public static Optional<GradleConfiguration> of(@NonNull Scope scope,
if (scope.getPhases().contains(Phase.PROFILE)) {
return Optional.of(GradleConfiguration.PROFILE);
}
if (scope.getPhases().contains(Phase.INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES)) {
return Optional.of(GradleConfiguration.INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES);
}
break;

case TEST:
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 @@ -43,19 +43,7 @@ apply from: "gradle/asciidoc.gradle"
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core/" }
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')
}
}
}
}
maven { url "https://repository.apache.org/content/repositories/snapshots"}
}

@dependencies.template(applicationType, project, features, gradleBuild)
Expand All @@ -67,11 +55,7 @@ application {

}

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

@if (features.contains("jrebel")) {
run {
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,16 @@ Features features,
GradleBuild gradleBuild
)

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

@if(!gradleBuild.getBuildscriptDependencies().isEmpty()) {
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core/" }
maven { url "https://repository.apache.org/content/repositories/snapshots"}
}
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 @@ -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 @@ -103,26 +103,22 @@ public void apply(GeneratorContext generatorContext) {
generatorContext.addDependency(Dependency.builder()
.groupId("org.grails.plugins")
.artifactId("geb")
.test());
.integrationTestImplementationTestFixtures());

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-firefox-driver")
.testRuntime());
generatorContext.addDependency(Dependency.builder()
.groupId("org.seleniumhq.selenium")
.lookupArtifactId("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
42 changes: 1 addition & 41 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,46 +82,11 @@
<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>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>com.bertramlabs.plugins</groupId>
<artifactId>asset-pipeline-gradle</artifactId>
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 @@ -17,12 +17,11 @@ class GebSpec extends ApplicationContextSpec implements CommandOutputFixture {
final def buildGradle = output["build.gradle"]

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("integrationTestImplementation testFixtures(\"org.grails.plugins:geb\")")
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-firefox-driver\")")
}

void "test GebConfig.groovy file is present"() {
Expand All @@ -33,17 +32,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