./gradlew quarkusBuild creates a jar (1.0.1 Final)
Q: How to run it from with some profile/env ?
java -jar -Dquarkus-profile=dev build/my-project-service-1.0.0-SNAPSHOT.jar
or
java -jar -Dquarkus-profile=dev build/libs/my-project-service-1.0.0-SNAPSHOT.jar
ERROR:
no main manifest attribute, in
build/my-project-service-1.0.0-SNAPSHOT.jar
Checked this. I do not have META-INF in my src/main/resources
if relevant, In application.properites:
quarkus.package.uber-jar=true // tried with true & false
Related
I have a Springboot project and I know I can send a application.properties file as a argument, but is this possible using a jar file?
I built my jar file using maven and in my application I have this piece of code that runs the programm if the user sent the argument run.
Is there any method that allows me to set the application properties if I receive it through argument? Or does the override of the file happens automatically as it does when I use the command
mvn spring-boot:run -Dspring.config.location=your.properties
if (args[0].equals("run")) {
ConfigurableApplicationContext ctx = SpringApplication.run(MigrationsApplication.class, args);
int exitCode = SpringApplication.exit(ctx, () -> 0);
System.exit(exitCode);
}
For jar you can either pass one of the properties or the complete or its location as beow.
we can configure the location directly in the command line:
java -jar app.jar --spring.config.location=file:///Users/home/config/jdbc.properties
We can also pass a folder location where the application will search for the file:
java -jar app.jar --spring.config.name=application,jdbc --spring.config.location=file:///Users/home/config
And, an alternative approach is running the Spring Boot application through the Maven plugin. There, we can use a -D parameter:
mvn spring-boot:run -Dspring.config.location="file:///Users/home/jdbc.properties"
I have 2 sub-projects/modules in my gradle project. one is a plain jar (let's call it libApp), the 2nd is an executable spring-boot application (let's call it execApp). I normally build execApp with "bootjar" gradle task but because I don't want to include libApp in execApp's fat/uber jar, so in my gradle.build, the libApp dependency is defined as:
compileOnly project(':libApp')
I normally launch execApp inside Intellij by right-clicking execApp's main class and choosing "debug 'execAppMainClass'".
However when execApp calls a class part of libApp, I get a ClassNotFoundException.
Hence my question is:
How can I prevent libApp from being part of the fat jar created by "bootjar" task while still being able to debug my application in Intellij ?
Note1: using gradle 6.6.1 with Idea 2020.3.2
Note2: Intellij's setting for gradle is set to: "build and run using: Gradle"
Note3: in Intellij's Run/Debug configuration, I tried to set "include dependencies with 'provided' scope" but that didn't seem to make any difference (still getting ClassNotFoundException)
SAMPLE PROJECT:
a) download https://spring.io/guides/gs/multi-module/ and import into Intellij
b) in application module replace "implementation project(':library')" with "compileOnly project(':library')"
c) inside Intellij, right-click DemoApplication class, and choose "Debug DemoApplication.main()".
d) you get ClassNotFoundException: com.example.multimodule.service.MyService
thanks a lot in advance for your expertise and your time.
Best Regards
I want to run Micronaut server from Gradle command line with "local" environment variables.
The regular command
.\gradlew.bat run
will use default variables defined in application.yml file.
I want to override some of them with values for my local environment and therefore need to specify system property micronaut.environments=local to use overriding values from application-local.yml file.
.\gradlew.bat run -Dmicronaut.environments=local
The command above won't work as Gradle will take only -Dmicronaut for the system property and the rest ".environments=local" will be considered as another task name:
Task '.environments=local' not found in root project 'abc'
What would be the correct way to pass such system property to the java process?
Command below works for unix, probably it should work also for windows:
MICRONAUT_ENVIRONMENTS=local gradle run
or use gradle wrapper
MICRONAUT_ENVIRONMENTS=local .\gradlew.bat run
P.S. also, you can find the same approach for Spring Boot
My approach is to add a gradle task.
task runLocal(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = "dontdrive.Application"
jvmArgs '-Dmicronaut.environments=local'
}
then start with:
./gradlew runLocal
Is it possible to use gretty integrationTestTask with a project that uses a war folder?
It seems from the documentation appBeforeIntegrationTest does not have access to the war. Is there another way to run test cases so that it uses the war folder?
Ideally, I want jettyStart -> test -> jettyStop to run. Although when I run it straight jettyStart hangs indefinitely, until jettyStop is run. Is there a way to run jettyStart in Gradle in the background or something?
Regardless what file structure your application has, the integrationTestTask is supposed to be configured with the name of an exsiting gradle task to execute when gradle integrationTest is run:
gretty {
// ...
integrationTestTask = 'integrationTest' // name of existing gradle task
// ...
}
What you want to archive is this:
gretty {
integrationTestTask = 'test'
}
Gretty's workflow when calling integrationTest is as follows:
I am currently integrating webpack with gradle like this...
task webpack(type: Exec) {
commandLine 'webpack'
}
task npm(type: Exec) {
commandLine 'npm install'
}
npm_install.dependsOn npm_cache_clean
webpack.dependsOn npm_install
build.dependsOn webpack
Webpack then creates the JS files and html files in the src/main/resources/static. The problem I am having is the first time gradle is run it must create the jar before webpack runs because I get a 404 on localhost:8080. Whereas, if I run it once (so the files are already created) it finds the old ones.
Is there a way to run this webpack before the src/main/resources folder is grabbed?
This fixed the situation, processResources.dependsOn webpack instead of build.dependsOn webpack