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..
Related
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
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')
}
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.
Gradle setup for Spring-boot application : build.gradle file i have used sourcesSet where my all java source file resides.
buildscript {
repositories {
//Required repos
mavenCentral()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
mavenLocal()
}
dependencies {
//Required dependency for spring-boot plugin
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.2.BUILD-SNAPSHOT'
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'spring-boot'
apply plugin: 'eclipse-wtp'
bootRepackage {
mainClass = 'com.test.app.Application'
}
war {
baseName = 'companies'
version = '0.1'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
mavenLocal()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
//Required dependency for JSP
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
}
sourceSets {
main {
java {
srcDir 'app/GeneratedSource'
srcDir 'app/JavaSource'
srcDir 'web/JavaSource'
}
resources {
srcDir 'app/GeneratedSource'
srcDir 'app/JavaSource'
srcDir 'web/JavaSource'
}
}
}
eclipse {
classpath {
defaultOutputDir = file('web/WebContent/WEB-INF/classes')
}
}
webAppDirName = 'web/WebContent'
libsDirName = 'war'
war {
baseName = baseName
version = appVersion
archiveName = warName
}
task printClasspath {
doLast {
configurations.testRuntime.each { println it }
}
enter image description hereCommand Line able to build model
When in eclipse while importing gradle project it is showing error
Iam unable to import Gradle project in Eclipse
Do you have a Gradle plugin for eclipse?
Help -> Eclipse MArketplace -> Search "Gradle" -> Install the Gradle STS integration.
In addition I recomend you change Spring Boot version to '1.3.3.RELEASE'.
buildscript {
ext {
springBootVersion = '1.3.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}}
In my case there was an update available for the gradle plugin. Once I updated the plugin using eclipse marketplace everything worked fine and project was imported properly.
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 ?