Hello i am testing GKE features and i created gradle java 17 init application, while deployment i have issue with manifest so i generated manually to artifact to resources :
Manifest-Version: 1.0
Main-Class: pl.kathelan.mdbackend.MdBackendApplication
here is my gradle build :
plugins {
id 'org.springframework.boot' version '2.7.3'
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'java'
}
group = 'pl.kathelan'
version = '0.0.1'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
jar {
manifest {
attributes(
"Class-Path": configurations.runtimeClasspath .collect { it.getName() }.join(' '))
}
}
sourceSets.main.resources.srcDirs = [ "src/" ]
i have tried this solution Gradle - no main manifest attribute , but for me was exception class no found. Looking for any help thanks.
found mistake in docker file :
ENV ARTIFACT_NAME=md-backend-0.0.1.jar
was md-backend-0.0.1-plain.jar
Related
I'm trying to set up a nested multi module project with gradle.
I have the following structure:
stock-client-root
|-- settings.gradle
|-- build.gradle
|-- stock-client
| |-- build.gradle
|-- stock-ui
|-- build.gradle
The problem is, that I cannot import any dependencies that are declared in the build.gradle files except spring boot related things.
Example: I want to use javafx. I declared it in the stock-ui/build.gradle file but when I want to import it in the module, intelliJ tells me, it cannot resolve that dependency.
I tried almost everything to solve this:
Reload the project via gradle
Restart the IDE
Invalidate cache + rebuild project
Created a new project with that structure and tried it again
Can anyone point out, where the problem might be?
And here is the content of the files:
stock-client-root/settings.gradle
rootProject.name = 'stock-client-root'
include 'stock-client'
include 'stock-ui'
stock-client-root/build.gradle
subprojects {
apply plugin: 'java'
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
}
stock-client/build.gradle
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
test {
useJUnitPlatform()
}
stock-ui/build.gradle
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.openjfx', name: 'javafx-graphics', version: '13.0.1'
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
I am using apollo graphql client in java code. My gradle file is
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven {
url 'http://dl.bintray.com/apollographql/android'
}
}
dependencies {
implementation "com.apollographql.apollo:apollo-android-support:1.0.0"
implementation "com.apollographql.apollo:apollo-runtime:1.0.0"
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
I have followed the docs mentioned in https://github.com/apollographql/apollo-android
I got stuck at step 4 and 5.
Not able to add
generateKotlinModels.set(false)
}
in gradle file and while executing the command
gradlew generateApollo its getting error as
Task 'generateApolloSources' not found in root project 'testProject'
Could anyone please help
You will need to apply the Apollo plugin:
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'com.apollographql.apollo' version '2.1.0'
}
You should also bump the Apollo dependencies to '2.1.0' as '1.0.0' is pretty old.
I got this error while executing a Gradle Project in Java using JavaFX.
My build.gradle:
plugins {
id 'eclipse'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
sourceCompatibility = 11
targetCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.12'
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
compile group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev222-1.25.0'
}
javafx {
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
version = "11.0.2"
}
mainClassName = "Younify_Gradle.Main"
Any ideas or is anything in my build.gradle wrong?
I have a Spring Boot (2.1.7) (Gradle project) that I want to deploy to Google App Engine.
I am able to successfully deploy the app (using the documentation found here) but when visiting the app url it returns a 404 Not Found screen:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>404 Not Found</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Not Found</h1>
</body></html>
Here's what my build.gradle file looks like:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.1.0'
classpath 'org.akhikhl.gretty:gretty:+'
}
}
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'com.google.cloud.tools.appengine'
group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jetty'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
providedCompile 'com.google.appengine:appengine:+'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
gretty {
httpPort = 8080
contextPath = '/'
servletContainer = 'jetty9' // What App Engine Flexible uses
}
appengine {
deploy {
version = "3"
projectId = "apprealtest"
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
}
Here is what my {projectRoot}/src/main/appengine/app.yaml file looks like:
runtime: java
env: flex
runtime_config: # Optional
jdk: openjdk8
handlers:
- url: /.*
script: this field is required, but ignored
manual_scaling:
instances: 1
This is what my {projectRoot}/src/main/webapp/WEB-INF/appengine-web.xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<runtime>java8</runtime>
<threadsafe>true</threadsafe>
</appengine-web-app>
This is what the {projectRoot}/src/main/java/com/company/hello/HelloApplication.java looks like:
package com.company.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
This is what the {projectRoot}/src/main/java/com/company/hello/HelloController.java looks like:
package com.company.hello;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HelloController {
#GetMapping("/")
public String get() {
return System.currentTimeMillis() + "";
}
#GetMapping("/greeting")
public String getGreeting() {
return "Greetings!";
}
}
I'm making the call to https://apprealtest.appspot.com and https://apprealtest.appspot.com/greeting.
What am I doing wrong?
To deploy it in GAE Standard you can download this official SpringBoot for App Engine Standard sample.
The instructions are for maven but to do it with Gradle you can simply add this build.gradle file:
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.+' // Latest 1.x.x release
}
}
repositories { // repositories for Jar's you access in your code
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed)
}
mavenCentral()
jcenter()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
apply plugin: 'maven-publish'
dependencies {
compile 'com.google.appengine:appengine-api-1.0-sdk:+' // Latest App Engine Api's
compile 'org.springframework.boot:spring-boot-starter-web:2.1.1.RELEASE'
testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.1.RELEASE'
providedCompile 'org.slf4j:jul-to-slf4j:1.7.25'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
group = 'com.google.appengine.demos'
version = '0.0.1-SNAPSHOT'
description = 'springboot-appengine-standard'
sourceCompatibility = '1.8'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
And you can deploy it with gradle appengineDeploy.
I tested it myself and it worked. If you want to do it in GAE Flexible the corresponding sample would be this one which also has instructions for Maven so you would have to do the necessary migration to Gradle.
As I have not found a complete example of spring boot with the Gradle build tool.
Added a complete example with updated spring boot version 2.2.3 and AppEngine Gradle plugin 2.2.0.
buildscript {
repositories {
mavenCentral()
maven{
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
}
}
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '2.2.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compile "com.google.appengine:appengine-api-1.0-sdk:+"
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
providedCompile "com.google.appengine:appengine-api-stubs:+"
providedCompile "com.google.appengine:appengine-testing:+"
providedCompile 'org.slf4j:jul-to-slf4j:1.7.25'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile group: 'net.bytebuddy', name: 'byte-buddy', version: '1.10.3'
}
apply plugin: "com.google.cloud.tools.appengine"
appengine { // App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
jvmFlags = ['-Ddatastore.backing_store=../../src/main/webapp/WEB-
INF/appengine-generated/local_db.bin', '-Dappengine.fullscan.seconds=5']
port = 8812 // default
}
deploy { // deploy configuration\
stopPreviousVersion = false // default - stop the current version
promote = false // default - & make this the current version
version = 'pr'
projectId = ''
}
}
This repo has a complete example and the test case for its controller. hope it would help.
I am facing following issue while building spring boot project with gradle
What went wrong:
A problem occurred evaluating settings 'ConfigurationManager'.
Could not find method pluginManagement() for arguments [settings_4czoxeapfgxghi54ogzhrlgs9$_run_closure1#6e5e4ee] on settings 'ConfigurationManager' of type org.gradle.initialization.DefaultSettings.
Content of settings.gradle is as follows
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'ConfigurationManager'
Content of gradle-wrapper.properties is as follows
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Content of build.gradle is as follows
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
id 'war'
}
apply plugin: 'io.spring.dependency-management'
group = 'demo.comp.dept'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}