Spring Boot "Hello World" example gives run method exception - eclipse

Before I recieve suggestive comments questioning my intelligence I will just go out and say that I just followed the guidance provided on official Spring website (https://spring.io/guides/gs/rest-service/). And as a reward I recieved an error.
Dont find it necessary to define anything that doesnt state in the documentation, Gradle build is copy-pasted, so where lies the problem?
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('org.springframework.boot:spring-boot-starter-test')
}

Related

Failed to apply plugin [id 'com.jfrog.artifactory']

I am using Gradle 6.7.1 and trying to apply the latest version of the plugin 'com.jfrog.artifactory', but get this error -
No signature of method: org.gradle.api.internal.tasks.RealizableTaskCollection.configureEach() is applicable for argument types: (org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$_addModuleInfoTask_closure2) values: [org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$_addModuleInfoTask_closure2#72132197]
This is what I have in my build.gradle -
apply plugin: 'com.jfrog.artifactory'
buildscript {
repositories {
jcenter()
maven {
url = 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.18.2"
}
}
I also tried to use 4.18.1 and 4.18.0, but got the same error. Help please!
your apply plugin line should be after the buildscript block
buildscript {
repositories {
jcenter()
maven {
url = 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.18.2"
}
}
apply plugin: 'com.jfrog.artifactory'

How to add generated sources for scala protobuf plugin using gradle?

I use gradle for building and want to generate some scala code for protobuf using this plugin: https://github.com/CharlesAHunt/scalapb-gradle-plugin
My gradle.build:
group 'xxxx'
version '1.0-SNAPSHOT'
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.charlesahunt:scalapb-plugin:1.2.4"
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.charlesahunt.scalapb'
apply plugin: 'java'
apply plugin: 'scala'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation 'org.scala-lang:scala-library:2.12.8'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'com.typesafe', name: 'config', version: '1.3.4'
testCompile group: 'org.scalatest', name: 'scalatest_2.12', version: '3.0.8'
}
scalapbConfig {
protocVersion = "-v360"
grpc = false
targetDir = "build/generated/scala"
projectProtoSourceDir = "src/main/protobuf"
extractedIncludeDir = "build/external_protos"
}
sourceSets {
generated {
scala.srcDirs += "build/generated/"
}
}
compileScala {
dependsOn scalapb
}
The problem is that generated code isn't visible for my code and i can't use it. I tried to change targetDir and scala.srcDirs but it didn't help.
How can i solve this problem?
p.s. i use IntelliJ

Idea cannot recognize a symbol even it is present in external dependencies

Does somebody understands what is a problem? Why my IDE doesn't see classes from dependencies? Idea version: 17.2.2
The root build.gradle:
subprojects.each {
apply plugin: 'idea'
}
The root setting.gradle:
include 'client'
include 'api'
rootProject.name = 'app-1-akka-reactjs'
My build.gradle of api project:
apply plugin: 'play'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.iatoki:gradle-play-idea:0.4.1'
}
}
apply plugin: 'org.iatoki.play-idea'
repositories {
jcenter()
ivy {
url "https://repo.typesafe.com/typesafe/ivy-releases/"
layout "pattern", {
ivy "[organisation]/[module]/[revision]/ivys/ivy.xml"
artifact "[organisation]/[module]/[revision]/jars/[artifact].[ext]"
}
}
}
model {
components {
play {
platform play: '2.5.8', scala: '2.11', java: '1.8'
injectedRoutesGenerator = true
}
}
}
dependencies {
play 'com.typesafe.play:play-slick_2.11:2.1.0'
play 'com.typesafe.play:play-slick-evolutions_2.11:2.1.0'
play 'org.postgresql:postgresql:9.4-1200-jdbc41'
}
The build.gradle of client is empty for now.
To generate idea's files I've used:
gradle cleanIdea idea
I faced a similar issue. I could resolve it by moving/copying the settings.xml file from $MVN_HOME/conf to ~/.m2 folder. As MVN_HOME was not detected by Idea it could not resolve the settings.xml from MVN_HOME.

Migrating from existing dynamic web project to gradle?

I have a following structure .
I am constructing build.gradle by copy-paste from numerous sources..
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'
webAppDirName = 'WebContent'
repositories {
jcenter()
mavenCentral()
}
sourceSets {
main {
// where does the Java source code live?
java {
srcDir 'src'
}
// where do classpath resources like *.properties files live?
resources {
srcDir 'src/main/resources'
}
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
testCompile("junit:junit")
compile fileTree(dir: 'WebContent/WEB-INF/lib', include: ['*.jar'])
String tomcatVersion = '7.0.52'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
tomcat "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
tomcat {
contextPath = '/'
}
when I run gradle tomcatRun, I see the following output
02:49:58.819 [QUIET]
[com.bmuschko.gradle.tomcat.embedded.BaseTomcatServerImpl$AfterStartEventLifecycleListener]
Started Tomcat Server 02:49:58.820 [QUIET]
[com.bmuschko.gradle.tomcat.embedded.BaseTomcatServerImpl$AfterStartEventLifecycleListener]
The Server is running at http://localhost:8080
Building 75% > :tomcatRun
But when I connect to http://localhost:8080 I see either 404 error or blank page..

Writing custom gradle plugin with non-transitive dependency

I am trying to implement a gradle plugin which in turn depends on an another gradle plugin. Here is a snippet of my plugin's build.gradle
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
}
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
dependencies {
repositories {
mavenCentral()
mavenLocal()
}
compile gradleApi()
compile localGroovy()
compile 'com.example:otherplugin:[0.1,)'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: mavenLocal())
pom.groupId = 'com.example'
pom.version = '0.5'
pom.artifactId = 'myplugin'
}
}
}
As you can see, I am using range dependency and not particular about any version of the 'otherplugin'. When the user includes my plugin in his build.gradle:
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.example:otherplugin:1.0', 'com.example:myplugin:2.3'
}
}
Gradle always uses the latest version of 'com.example:otherplugin' to process his project. Ideally, I would like the version specified by the user to be downloaded, and used by gradle.
I believe this is a problem with my plugin's build.gradle. How can I modify my plugin's build.gradle so that, this transitive dependency is avoided ?