-
Notifications
You must be signed in to change notification settings - Fork 435
Create production-package.zip earlier in the process #5691
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,54 +157,42 @@ val npmInstallTemp = tasks.register<NpmTask>("npmInstallTemp") { | |
val tempInstallDir = layout.buildDirectory.file("tmp/npmInstall") | ||
inputs.files(npmPack) | ||
.withPathSensitivity(PathSensitivity.RELATIVE) | ||
outputs.dir(tempInstallDir) | ||
dependsOn(npmInitTemp) | ||
|
||
// Use a provider to defer evaluation until execution time | ||
args = provider { listOf("install", npmPack.get().archiveFile.get().asFile.absolutePath, "--omit=dev") } | ||
workingDir.set(tempInstallDir) | ||
} | ||
|
||
sourceSets { | ||
main { | ||
resources { | ||
srcDir("src/main/generated-resources") | ||
} | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. callout: Avoid |
||
tasks.named("licenseMain") { | ||
dependsOn(createProductionPackage) | ||
} | ||
} | ||
|
||
tasks.named<Jar>("sourcesJar") { | ||
dependsOn("createProductionPackage") | ||
exclude("production-package.zip") | ||
} | ||
|
||
tasks.named("processResources") { | ||
dependsOn(createProductionPackage) | ||
} | ||
|
||
// Creates a production-ready package; writing it to `src/main/generated-resources` so that it will be included by IDEA | ||
val createProductionPackage by tasks.register<Zip>("createProductionPackage") { | ||
// Configure the tar output | ||
archiveFileName.set("production-package.zip") | ||
destinationDirectory.set(layout.projectDirectory.dir("src/main/generated-resources")) | ||
destinationDirectory.set(layout.buildDirectory.dir("generated/resources/distributions/")) | ||
|
||
dependsOn(npmInstallTemp) | ||
|
||
// Reference the actual directory where npm packages are installed | ||
from(layout.buildDirectory.dir("tmp/npmInstall")) { | ||
from(npmInstallTemp) { | ||
// Optionally exclude unnecessary files like package-lock.json, etc. | ||
// exclude("package-lock.json", ".npmrc") | ||
} | ||
} | ||
|
||
// Include production-ready package into jar | ||
tasks.named<Jar>("jar") { | ||
sourceSets { | ||
main { | ||
resources { | ||
srcDir(createProductionPackage.destinationDirectory) | ||
} | ||
} | ||
} | ||
|
||
tasks.named<Jar>("sourcesJar") { | ||
from(createProductionPackage) | ||
exclude("production-package.zip") | ||
} | ||
|
||
tasks.named<ProcessResources>("processResources") { | ||
dependsOn(createProductionPackage) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. callout: All of this is really a hack to make the IDE work correctly. The Overall, not ideal by any means. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can probably get rid of the hack and just require any IDE tests to specify the path to the dist dir of the project when setting up RPC. I think that is acceptable. |
||
|
||
tasks.named("integrationTest") { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
"removeComments": true | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
"test/**/*" | ||
"src/**/*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. callout: the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd still need some more refactoring to get rid of this. The problem is that some integration tests fail without this. The tests aren't executed on CI, so I can also fix this afterwards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a clarification, but as in the Java integration tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. They depend on a JS recipe which is in test. I will try to fix that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, so how would you feel about adding an NPM script to compile tests separate from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we can take this thought a step further by using the jvm-test-suite plugin instead of the Nebula IntegTest plugin. With the jvm-test-suite plugin, we would be declaring a dependency upon the production outgoing artifacts which would result in the jar being built and more closely aligning the integration tests with what the real runtime environment would look like. |
||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callout: Should always avoid writing to the project directory as it can result in triggering tasks to run unnecessarily.