Skip to content

Fix for play-2.8 'Source directory xxx is not a directory.` #9357

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

Merged
merged 7 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dd-smoke-tests/play-2.8-split-routes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
}

apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/fix-play-routes.gradle"

def playVer = "2.8.15"
def scalaVer = System.getProperty("scala.version", /* default = */ "2.13")
Expand Down Expand Up @@ -66,7 +67,7 @@ dependencies {
}

configurations.testImplementation {
exclude group:'com.typesafe.play', module:"play-test_$scalaVer"
exclude group: 'com.typesafe.play', module: "play-test_$scalaVer"
}

tasks.named('compileTestGroovy').configure {
Expand Down
24 changes: 1 addition & 23 deletions dd-smoke-tests/play-2.8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
}

apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/fix-play-routes.gradle"

Copy link
Contributor

Choose a reason for hiding this comment

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

For my understanding, is the logic moving to a separate file necessary or for organizational / readability purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sarahchen6 I moved to separate file because I'm already using it 2 times and there is a chance that in future I will need it for all play-xxx modules.

Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 suggestion: ‏I would recommend to move it to a dd-smoke-tests/play-common then.
It will be easier to find (same logic as the instrumentations) and won't mix with the overall project build scripts.

def playVer = "2.8.15"
def scalaVer = System.getProperty("scala.version", /* default = */ "2.13")
Expand Down Expand Up @@ -72,29 +73,6 @@ configurations.testImplementation {
exclude group: 'com.typesafe.play', module: "play-test_$scalaVer"
}

// Fix for flaky error: Source directory '/dd-smoke-tests/play-2.8/build/src/play/routes' is not a directory.
// Probably, GitLab somehow creates (or restores from cache) file instead of folder.
tasks.register('fixPlayRoutesDirectory') {
group = 'build cleanup'
description = 'Deletes routes path if it is a file instead of directory'

def routesPath = layout.buildDirectory.dir('src/play/routes')
destroyables.register(routesPath)

doFirst {
def routesPathFile = routesPath.get().asFile

if (routesPathFile.exists() && !routesPathFile.isDirectory()) {
logger.lifecycle("Removing file that blocks routes directory: ${routesPathFile}")
project.delete(routesPathFile)
}
}
}

tasks.named('compilePlayRoutes') {
dependsOn tasks.named('fixPlayRoutesDirectory')
}

tasks.named('compileTestGroovy').configure {
dependsOn 'stageMainDist'
outputs.upToDateWhen {
Expand Down
22 changes: 22 additions & 0 deletions gradle/fix-play-routes.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Fix for flaky error: Source directory '/dd-smoke-tests/play-2.8/build/src/play/routes' is not a directory.
// Probably, GitLab somehow creates (or restores from cache) file instead of folder.
tasks.register('fixPlayRoutesDirectory') {
group = 'build cleanup'
description = 'Deletes routes path if it is a file instead of directory'

def routesPath = layout.buildDirectory.dir('src/play/routes')
destroyables.register(routesPath)

doFirst {
def routesPathFile = routesPath.get().asFile

if (routesPathFile.exists() && !routesPathFile.isDirectory()) {
logger.lifecycle("Removing file that blocks routes directory: ${routesPathFile}")
project.delete(routesPathFile)
}
}
}

tasks.named('processResources') {
dependsOn tasks.named('fixPlayRoutesDirectory')
}