so I've added a png img to my resources, since I want to use it in my project.
But Gradle seems not to let me build the project anymore, it's giving me the following error:
* What went wrong:
Execution failed for task ':processResources'.
> Could not copy file 'C:\workspace\Java\Utilities\EmailService\src\main\resources\img\watermark.png' to 'C:\workspace\Java\Utilities\EmailService\build\resources\main\img\watermark.png'.
Important part of Stacktrace is:
Caused by: groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript28.groovy: 4: illegal string body character after dollar sign;
solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" # line 4, column 99.
o¿dHÌIDATx^Ý?╝$Eı┼Ù¥Ö┘]r♫↕$-↓$g%(êê
^
My setup of the project:
build.gradle:
import java.text.SimpleDateFormat
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
ext {
springBootVersion = '2.1.5.RELEASE'
set('springCloudVersion', 'Greenwich.RELEASE')
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'com.palantir.git-version' version '0.11.0'
}
def appName = 'EmailService'
version = '1.1.5'
group = 'dk.xx.email'
if (!hasProperty('mainClass')) {
ext.mainClass = 'dk.xx.email.EmailApplication'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
apply plugin: 'com.palantir.git-version'
sourceCompatibility = 1.8
repositories {
maven {
credentials {
username XXX
password XXXXXXX
}
url 'http://maven01.local:8080/repository/XX/'
}
mavenCentral()
maven { url 'https://jitpack.io' }
}
bootJar {
baseName = "${appName}"
version = "${version}"
}
dependencies {
compile('net.sf.jt400:jt400:9.5:jt400_jdk8')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile group: 'org.springframework', name: 'spring-mock', version: '2.0.8'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '2.1.0.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.1.0.RELEASE'
compile group: 'xx', name: 'NhoData-Entities', version: '0.1.99'
compile group: 'xx', name: 'xx-Entities', version: '2.1.7'
compile('dk.xx.stakeholder.document.archive:DocumentArchive:1.1.10:proxy')
compile group: 'com.itextpdf', name: 'itext7-core', version: '7.0.4'
compile('dk.xx.gui.start:EngagementGui:1.2.2:proxy')
compileOnly("org.projectlombok:lombok:1.18.6")
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-mail')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// Auto-produce swagger
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
}
task versionTxt() {
doLast {
def versionFile = new File("$projectDir/.ci/version.txt");
versionFile.getParentFile().mkdir();
versionFile.text = """
Version=$version
BuildTime=${new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())}
ApplicationName=${appName}
"""
}
}
def dependencyName = "${appName}-proxy-${version}"
task tJar(type: Jar, dependsOn: compileJava) {
archiveName = "${dependencyName}.jar"
classifier = 'proxy'
from(sourceSets.main.output) {
includeEmptyDirs=false
include '**/feign/*'
include '**/domain/*'
include '**/entities/*'
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
publishing {
publications {
maven(MavenPublication) {
artifacts {
groupId "${group}"
artifactId "${appName}"
version "${version}"
}
artifact tJar
artifact sourcesJar
}
repositories.maven {
url 'http://maven01.local:8080/repository/xx/'
credentials {
username xx
password xxxxxxxx
}
}
}
}
processResources {
filter(ReplaceTokens, tokens:[gitVersion: gitVersion()])
expand(project.properties)
}
static def buildTime() {
final dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
dateFormat.timeZone = TimeZone.getTimeZone('UTC')
dateFormat.format(new Date())
}
springBoot {
// This statement tells the Gradle Spring Boot plugin to generate a file
// build/resources/main/META-INF/build-info.properties
// that is picked up by Spring Boot to display via /actuator/info endpoint.
buildInfo {
// Generate extra build info.
properties {
def details = versionDetails()
additional = [
by : System.properties['user.name'],
time : buildTime(),
operatingSystem : "${System.properties['os.name']} (${System.properties['os.version']})",
machine : InetAddress.localHost.hostName,
ci_enabled : System.getenv('CI') ? true : false,
ci_buildNumber : System.env.'BUILD_NUMBER' ?: 'UNKNOWN',
ci_jobName : System.env.'JOB_NAME' ?: 'UNKNOWN',
appVersion : version
]
}
}
}
I think it's the filter statement in your processResources config. You're asking Gradle to replace text inside the PNG, but it can't make sense of the text in the PNG (which is because there is no text in it; probably doesn't conform to any reasonable character encoding).
I am trying to install BEAM, an extention on MatSim through the GIT Bash and I keep running into this error. This is exactly what I get:
$ gradle classes
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Build file 'K:\beam\build.gradle' line: 414
* What went wrong:
A problem occurred evaluating root project 'beam'.
> For input string: "=10"
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 16s
The stacktrace is too big to put in the body, but I could include a screenshot if needed.
This is my build.gradle:
import java.time.Instant
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath group: 'kr.motd.gradle', name: 'sphinx-gradle-plugin', version: '1.0.3.Final'
classpath "jp.classmethod.aws:gradle-aws-plugin:0.35"
classpath "com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
classpath 'cz.alenkacz:gradle-scalafmt:1.7.0'
classpath 'com.bmuschko:gradle-docker-plugin:3.6.1'
}
}
plugins {
id "net.ltgt.apt" version "0.5"
id "de.undercouch.download" version "3.2.0"
id "org.scoverage" version "2.5.0"
id 'maven-publish'
}
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'kr.motd.sphinx'
apply plugin: 'application'
apply plugin: 'ManifestClasspath'
apply plugin: 'scalafmt'
apply plugin: 'com.bmuschko.docker-java-application'
group = 'beam'
version = '0.8.0'
description = """"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileScala.options.encoding = 'UTF-8'
def scalaBinaryVersion = "2.12"
def akkaBinaryVersion = "2.5.22"
def circeBinaryVersion = "0.7.1"
def slf4jVersion = "1.7.25"
def kamonVersion = "0.6.7"
def tscfgVersion = "0.9.4"
sourceSets.main.scala.srcDirs = ["src/main/scala", "src/main/java"]
sourceSets.main.java.srcDirs = []
sourceSets.test.java.srcDirs = []
sourceSets.test.scala.srcDirs = ["src/test/scala", "src/test/java"]
sourceSets {
main {
resources {
srcDir "src/main/resources"
}
}
test {
resources {
srcDir "src/test/resources"
}
}
}
if (project.hasProperty('env')) {
sourceSets {
main {
resources {
srcDirs "test/input/" + project.getProperty('env')
}
}
}
}
allprojects {
repositories {
maven { url 'https://download.osgeo.org/webdav/geotools/' }
// maven { url "https://maven.geotoolkit.org/" }
maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases" }
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "https://download.osgeo.org/webdav/geotools" }
maven { url "https://dl.bintray.com/matsim/matsim" }
maven { url "https://maven.conveyal.com/" }
maven { url "https://repo1.maven.org/maven2" }
maven { url "https://download.java.net/maven/2/" }
maven { url "https://people.apache.org/repo/m1-ibiblio-rsync-repository/org.apache.axis2/" }
maven { url "https://dl.bintray.com/andimarek/graphql-java" }
maven { url "https://maven.geo-solutions.it" }
maven { url "https://dl.bintray.com/scalaz/releases" }
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://nexus.onebusaway.org/content/groups/public/" }
maven { url "https://jitpack.io" }
}
}
dependencies {
compile(group: 'com.github.LBNL-UCB-STI', name: 'beam-utilities', version: 'v0.2.4') {
exclude group: 'com.github.LBNL-UCB-STI', module: 'r5'
exclude group: 'org.matsim', module: 'matsim'
}
////////////////////////////
// Java dependencies
////////////////////////////
compile group: 'com.google.inject', name: 'guice', version: '4.1.0'
compile group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: '4.1.0'
compile group: 'com.google.inject.extensions', name: 'guice-multibindings', version: '4.1.0'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.5'
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.2'
// Apache 2.0
compile group: 'com.univocity', name: 'univocity-parsers', version: '2.8.1'
// LGPL
compile group: 'org.geotools', name: 'gt-main', version: '13.0'
compile group: 'org.geotools', name: 'gt-shapefile', version: '13.0'
compile group: 'org.geotools', name: 'gt-referencing', version: '15.2'
compile group: 'org.geotools', name: 'gt-epsg-wkt', version: '15.2'
compile group: 'org.jfree', name: 'jfreechart', version: '1.0.14'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.4'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.12', version: '2.9.4'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'jdom', name: 'jdom', version: '1.1'
compile group: 'org.jdom', name: 'jdom2', version: '2.0.5'
compile 'com.hubspot.jinjava:jinjava:2.0.5'
compile group: 'org.yaml', name: 'snakeyaml', version: '1.18'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'net.sf.supercsv:super-csv:2.4.0'
compile 'org.reflections:reflections:0.9.10'
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.2-b01'
compile group: 'com.github.stephenc.eaio-uuid', name: "uuid", version: "3.4.0"
compile "org.jgrapht:jgrapht-core:1.3.0"
compile ('com.github.LBNL-UCB-STI:or-tools-wrapper:7.5-0'){
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
// GPLv3
compile group: 'org.matsim.contrib', name: 'multimodal', version: '0.10.0'
compile group: 'org.matsim.contrib', name: 'bicycle', version: '0.10.0'
compile(group: 'org.matsim.contrib', name: 'decongestion', version: '0.11.0-2018w44') {
exclude group: 'org.matsim', module: 'matsim'
}
compile(group: 'com.github.wrashid.matsim', name: 'matsim', version: '0.10.1-beam-11') {
exclude group: 'log4j', module: 'log4j'
}
compile "org.slf4j:slf4j-api:${slf4jVersion}"
compile "ch.qos.logback:logback-classic:1.2.3"
compile "com.typesafe.scala-logging:scala-logging_${scalaBinaryVersion}:3.9.0"
compile "org.slf4j:log4j-over-slf4j:${slf4jVersion}"
compile(group: 'com.github.michaz', name: 'r5', version: '3ab4fa04') {
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
compile "com.sigopt:sigopt-java:4.9.0"
compile("com.uber:h3:3.4.1")
testCompile group: 'junit', name: 'junit', version: '4.8'
testCompile group: 'org.mockito', name: 'mockito-inline', version: '2.27.0'
testCompile group: "org.mockito", name: "mockito-core", version: "2.+"
/////////////////////////////////
// Scala dependencies
/////////////////////////////////
// CORE Scala //
compile "org.scala-lang:scala-library:2.12.10"
compile group: 'org.scala-lang.modules', name: "scala-xml_${scalaBinaryVersion}", version: '1.0.6'
// NEEDED FOR USING REPL //
compile "org.scala-lang:scala-compiler:2.12.10"
// TEST Scala //
testCompile group: 'org.scalatest', name: "scalatest_${scalaBinaryVersion}", version: '3.0.8'
testRuntime "org.pegdown:pegdown:1.4.2" // HTML report for scalatest
// 3rd Party Scala //
compile group: 'org.jliszka', name: 'probability-monad_2.11', version: '1.0.1'
// https://mvnrepository.com/artifact/com.beachape/enumeratum_2.12
compile group: 'com.beachape', name: "enumeratum_${scalaBinaryVersion}", version: "1.5.12"
// https://mvnrepository.com/artifact/com.beachape/enumeratum-circe_2.12
compile group: 'com.beachape', name: "enumeratum-circe_${scalaBinaryVersion}", version: "1.5.14"
compile "com.github.scopt:scopt_${scalaBinaryVersion}:3.7.0"
compile "net.codingwell:scala-guice_${scalaBinaryVersion}:4.1.0" // DI
compile('com.github.carueda:tscfg:v' + tscfgVersion) { // config
exclude group: 'org.scala-lang.modules', module: 'scala-xml_2.11'
}
// https://mvnrepository.com/artifact/io.circe/circe-core_2.12
compile group: 'io.circe', name: "circe-core_${scalaBinaryVersion}", version: circeBinaryVersion
// https://mvnrepository.com/artifact/io.circe/circe-generic_2.12
compile group: 'io.circe', name: "circe-generic_${scalaBinaryVersion}", version: circeBinaryVersion
// https://mvnrepository.com/artifact/io.circe/circe-parser_2.12
compile group: 'io.circe', name: "circe-parser_${scalaBinaryVersion}", version: circeBinaryVersion
compile group: 'com.typesafe.play', name: "play-json_${scalaBinaryVersion}", version: '2.6.3'
compile (group: 'com.github.romix.akka', name: "akka-kryo-serialization_${scalaBinaryVersion}", version: '0.5.2') {
exclude group: 'com.esotericsoftware', module: 'kryo'
}
compile group: 'com.esotericsoftware', name: 'kryo', version: '4.0.2'
compile "com.github.vagmcs:optimus_${scalaBinaryVersion}:3.1.0"
compile "com.github.vagmcs:optimus-solver-oj_${scalaBinaryVersion}:3.1.0"
////////////////////////////////////
///Performance Monitoring (Kamon)///
////////////////////////////////////
compile("io.kamon:kamon-core_${scalaBinaryVersion}:${kamonVersion}")
compile("io.kamon:kamon-scala_${scalaBinaryVersion}:${kamonVersion}")
compile("io.kamon:kamon-akka-2.4_${scalaBinaryVersion}:${kamonVersion}")
compile("io.kamon:kamon-statsd_${scalaBinaryVersion}:${kamonVersion}")
compile "io.kamon:kamon-influxdb_${scalaBinaryVersion}:0.6.9"
compile("io.kamon:kamon-log-reporter_${scalaBinaryVersion}:${kamonVersion}")
/////////////
// Akka Dependencies
////////////
// CORE Akka //
compile group: 'com.typesafe.akka', name: "akka-actor_${scalaBinaryVersion}", version: akkaBinaryVersion
compile group: 'com.typesafe.akka', name: "akka-slf4j_${scalaBinaryVersion}", version: akkaBinaryVersion
//compile group: 'com.typesafe.akka', name: "akka-persistence_${scalaBinaryVersion}", version: akkaBinaryVersion
//compile group: 'com.typesafe.akka', name: "akka-remote_${scalaBinaryVersion}", version: akkaBinaryVersion
compile group: 'com.typesafe.akka', name: "akka-cluster_${scalaBinaryVersion}", version: akkaBinaryVersion
compile group: 'com.typesafe.akka', name: "akka-contrib_${scalaBinaryVersion}", version: akkaBinaryVersion
//compile group: 'org.iq80.leveldb', name: 'leveldb', version: '0.9'
compile group: 'com.typesafe.akka', name: "akka-http_${scalaBinaryVersion}", version: "10.1.8"
compile group: 'de.heikoseeberger', name: "akka-http-circe_${scalaBinaryVersion}", version: "1.25.2"
// TEST Akka //
testCompile group: 'com.typesafe.akka', name: "akka-testkit_${scalaBinaryVersion}", version: akkaBinaryVersion
// 3rd Party Akka //
//compile group: 'org.iq80.leveldb', name: 'leveldb', version: '0.7'
//compile group: 'org.fusesource.leveldbjni', name: 'leveldbjni-all', version: '1.8'
//compile group: 'com.google.protobuf', name: 'protobuf-java', version: '2.5.0'
scoverage "org.scoverage:scalac-scoverage-plugin_${scalaBinaryVersion}:1.3.1", "org.scoverage:scalac-scoverage-runtime_${scalaBinaryVersion}:1.3.1"
compile 'org.apache.commons:commons-compress:1.18'
compile group: 'de.lmu.ifi.dbs.elki', name: 'elki', version:'0.7.5'
compile group: 'com.zaxxer', name: 'nuprocess', version: '1.2.4'
def parquet = "1.10.0"
compile group: 'org.apache.parquet', name: 'parquet-hadoop', version: parquet
compile group: 'org.apache.parquet', name: 'parquet-avro', version: parquet
compile (group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.7.3') {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
// Exclude `ASM` because it is binary incompatible with the one which is gotten from `com.conveyal:kryo-tools`: `org.ow2.asm:asm:5.0.4`
exclude group: 'asm', module: 'asm'
}
}
// Autoformatting using scalafmt
scalafmt {
// configFilePath = ".scalafmt.conf" // .scalafmt.conf in the project root is default value, provide only if other location is needed
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails dependencyResolveDetails ->
final requestedDependency = dependencyResolveDetails.requested
if (requestedDependency.name != 'beam-utilities') {
force 'javax.media:jai_core:1.1.3'
}
}
}
exclude group: 'javax.media', module: 'jai_codec'
exclude group: 'javax.media', module: 'jai_imageio'
}
//compileScala.dependsOn(scalafmtAll)
// Task to run scala tests, as Scala tests not picked up by Gradle by default.
task spec(dependsOn: ['testClasses'], type: JavaExec) {
main = 'org.scalatest.tools.Runner'
args = ['-R', 'build/classes/scala/test', '-h', 'build/scalatest-report', '-oD', '-l', 'beam.tags.ExcludeRegular']
classpath = sourceSets.test.runtimeClasspath
}
build.dependsOn spec
/* //////////////////////////////////////////////////
* Task to run tagged tests.
* Note: use space separated list of tags
* ./gradlew taggedTest -Ptags="beam.tags.Performance beam.tags.Integration"
* /////////////////////////////////////////////////// */
task taggedTest(dependsOn: ['testClasses'], type: JavaExec) {
main = 'org.scalatest.tools.Runner'
args = ['-R', 'build/classes/scala/test', '-o', '-n'] << (project.findProperty('tags') ?: 'org.scalatest.Ignore')
classpath = sourceSets.test.runtimeClasspath
}
task specificTest(dependsOn: ['testClasses'], type: JavaExec) {
main = 'org.scalatest.tools.Runner'
args = ['-R', 'build/classes/scala/test', '-o', '-s'] << (project.findProperty('suite') ?: 'org.scalatest.Ignore')
classpath = sourceSets.test.runtimeClasspath
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Task to run tests periodically on continue integration server.
// ./gradlew periodicTest -Pconfig=test/input/sf-light/sf-light-1k.conf -Piterations=1
////////////////////////////////////////////////////////////////////////////////////////////////////////////
task periodicTest(dependsOn: ['testClasses'], type: JavaExec) {
main = 'org.scalatest.tools.Runner'
args = ['-R', 'build/classes/scala/test', '-o', '-n', 'beam.tags.Periodic'] <<
(project.hasProperty('config') ? '-Dconfig=' + project.findProperty('config') :
(project.hasProperty('iterations') ? '-Diterations=' + project.findProperty('iterations') : '')) <<
(project.hasProperty('config') && project.hasProperty('iterations') ?
'-Diterations=' + project.findProperty('iterations') : '')
jvmArgs = ['-javaagent:build/aspectjweaver-1.8.10.jar']
classpath = sourceSets.test.runtimeClasspath
doFirst() {
if (!project.file('build/aspectjweaver-1.8.10.jar').exists()) {
download {
src 'https://repo1.maven.org/maven2/org/aspectj/aspectjweaver/1.8.10/aspectjweaver-1.8.10.jar'
dest buildDir
}
}
}
}
//////////////////////////////////////////////////////////////////////
// Generate config classes reflecting the application.conf file
//////////////////////////////////////////////////////////////////////
task generateConfig {
doLast {
def tscfgJarFile = project.file('build/tscfg-' + tscfgVersion + '.jar')
if (!tscfgJarFile.exists() || !tscfgJarFile.isFile()) {
download {
src 'https://github.com/carueda/tscfg/releases/download/v' + tscfgVersion + '/tscfg-' + tscfgVersion + '.jar'
dest buildDir
}
}
javaexec {
main = "-jar"
args = [
"build/tscfg-${tscfgVersion}.jar",
"--spec", "src/main/resources/beam-template.conf",
"--scala",
"--pn", "beam.sim.config",
"--cn", "BeamConfig",
"--dd", "src/main/scala/beam/sim/config/"
]
}
}
}
task repl(type: JavaExec) {
main = "scala.tools.nsc.MainGenericRunner"
classpath = sourceSets.main.runtimeClasspath
standardInput System.in
args '-usejavacp'
}
task deleteSf {
doLast {
if (project.file('production/application-sfbay/r5/network.dat').exists()) {
delete 'production/application-sfbay/r5/network.dat'
}
if (project.file('production/application-sfbay/r5/osm.mapdb').exists()) {
delete 'production/application-sfbay/r5/osm.mapdb'
}
if (project.file('production/application-sfbay/r5/osm.mapdb.p').exists()) {
delete 'production/application-sfbay/r5/osm.mapdb.p'
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Run Via application plugin
// Note: colon preceding "run" is necessary to only run the main project and not launch the GUI as well.
// ./gradlew :run -PappArgs="['--config', 'production/application-sfbay/beam.conf']"
////////////////////////////////////////////////////////////////////////////////////////////////////////////
mainClassName = "beam.sim.RunBeam"
def myAvailableRam = (System.getenv("MAXRAM") ?: (project.findProperty('maxRAM') ?: "140")).toString().replace("g", "").toInteger()
def getCurrentTimestamp = {
DateTimeFormatter.ofPattern("MM-dd-yyyy_HH-mm-ss")
.withLocale(Locale.US)
.withZone(ZoneOffset.UTC)
.format(Instant.now())
}
def logGC = ["-XX:+PrintGCDetails", "-XX:+PrintGCDateStamps", "-Xloggc:gc_${getCurrentTimestamp()}.log"]
// Use following for remote debug mode
def remoteDebug = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8005"]
def jfr = ["-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder",
"-XX:FlightRecorderOptions=defaultrecording=true,disk=true,maxage=10h,dumponexit=true,loglevel=info"]
// On the running machine there should be file /usr/lib/jvm/java-8-oracle/jre/lib/jfr/profile_heap_exception.jfc with content from
// https://pastebin.com/N3uuUfPz - it's Java Mission Control with metrics about heap allocation and details about exceptions
def jfrWithMem = ["-XX:+UnlockCommercialFeatures", "-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints",
"-XX:StartFlightRecording=delay=2s,duration=60m,name=mem_ex,filename=recording.jfr,settings=profile_heap_exception",
"-XX:+FlightRecorder", "-XX:FlightRecorderOptions=disk=true,maxage=10h,dumponexit=true,loglevel=info"]
def jmx = ["-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.port=9005", "-Dcom.sun.management.jmxremote.host=127.0.0.1",
"-Dcom.sun.management.jmxremote.local.only=true", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.ssl=false",
"-Djava.net.preferIPv4Stack=true", "-Djava.rmi.server.hostname=127.0.0.1"]
// UseParallelGC
applicationDefaultJvmArgs = ["-Xmx${myAvailableRam}g", "-Xms${myAvailableRam/2}g",
"-XX:+UseParallelGC", "-XX:+UseParallelOldGC", "-XX:MetaspaceSize=150M", "-Djava.awt.headless=true",
"-Dlogback.configurationFile=logback_prod.xml", "-Xss2048k"] + logGC + jmx
println(applicationDefaultJvmArgs)
run {
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
doFirst() {
if (!project.file('build/aspectjweaver-1.8.10.jar').exists()) {
download {
src 'https://repo1.maven.org/maven2/org/aspectj/aspectjweaver/1.8.10/aspectjweaver-1.8.10.jar'
dest buildDir
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Run ExperimentGenerator from Command line
// gradle :execute -PmainClass=beam.experiment.ExperimentGenerator -PappArgs="['--experiments', 'test/input/beamville/example-experiment/experiment.yml']"
// Run R5 GUI server
// gradle --stacktrace :execute -PmainClass=com.conveyal.r5.R5Main -PappArgs="['point','--graphs','production/application-sfbay/r5/']"
////////////////////////////////////////////////////////////////////////////////////////////////////////////
task execute(type: JavaExec) {
jvmArgs = applicationDefaultJvmArgs
if (project.hasProperty("mainClass")) {
main = mainClass
} else {
main = mainClassName
}
classpath = sourceSets.main.runtimeClasspath
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
doFirst() {
if (!project.file('build/aspectjweaver-1.8.10.jar').exists()) {
download {
src 'https://repo1.maven.org/maven2/org/aspectj/aspectjweaver/1.8.10/aspectjweaver-1.8.10.jar'
dest buildDir
}
}
}
}
task matsimConversion(type: JavaExec) {
main = 'beam.utils.matsim_conversion.MatsimConversionTool'
classpath = sourceSets.main.runtimeClasspath
environment "PWD", "na"
if (project.hasProperty("confPath")) {
args Eval.me(confPath)
// if this triggers an error, try
// args "${confPath}"
}
}
task generateDocumentation(type: JavaExec) {
group 'Documentation'
description 'Format the data using Sphinx RST formats'
main = 'beam.docs.GenerateDocumentationTask'
classpath = sourceSets.main.runtimeClasspath
}
tasks.withType(ScalaCompile) {
// Enable Scala warnings output
scalaCompileOptions.additionalParameters = ["-unchecked", "-deprecation", "-feature", "-Xfatal-warnings"]
}
task fmt(dependsOn: scalafmtAll)
task checkScalaFmt() {
doLast {
try {
def workingDir = new File("${project.projectDir}")
def result = 'git diff --exit-code'.execute(null, workingDir)
result.waitFor()
if (result.exitValue() != 0) throw new Exception("""
Please run ./gradlew scalaFmtAll and commit/push the subsequent results to fix this error.
This happened because a git diff yielded a non-zero exit code.
This task was built to be run on the CI server AFTER scalaFmtAll
It should only error if the results of scalaFmtAll resulted in code modifications.
And that would only happen if the committed code is not formatted as expected.""")
} catch (e) {
throw new Exception("An unexpected error was encountered while checking that scalaFmtAll was committed.", e)
}
}
}
docker{
registryCredentials {
url = 'https://index.docker.io/v1/'
username = System.getenv("DOCKER_USER")
password = System.getenv("DOCKER_PASSWORD")
}
javaApplication {
baseImage = 'continuumio/miniconda3'
maintainer = 'LBNL Beam Team'
tag = "beammodel/beam:$version"
}
}
dockerDistTar {
instruction 'RUN apt-get update && apt-get -y install openjdk-8-jdk && rm -rf /var/lib/apt/lists/*'
addFile 'test/', 'test/'
}
dockerCopyDistResources {
from('test/') {
into('test/')
}
}
Specifically line 414 is:
def myAvailableRam = (System.getenv("MAXRAM") ?: (project.findProperty('maxRAM') ?: "140")).toString().replace("g", "").toInteger()
Any help with this would be awesome, none of this is my own code, this is all cloned from a git repository that should be working.
I am working on selenium Gradle project in which I accidentally changed some configuration that causes changes in build structure. before change my project structure was
project-dir
.gradle
.idea
build
gradle
out
src
now its
project-dir
.gradle
.idea
classes
gradle
out
src
when I run command "gradlew build" it should run all the feature files but it is not working after change. can you help me what went wrong. I am new to all this.
I am using
gradle 4.12
selenium 2.53.0
cucumber-junit 1.2.5
cucumber-java 1.2.5
cucumber-core 1.2.5
Gradle.build file:
-
import java.text.DateFormat
import java.text.SimpleDateFormat
version '1.0-SNAPSHOT'
task gitBuildId {
description = "Determine the build id from git"
def buildIdOut = new ByteArrayOutputStream()
def errorsOut = new ByteArrayOutputStream()
def extraInfo = ""
try {
exec {
// TODO: use a java git library?
standardOutput = buildIdOut
errorOutput = errorsOut
commandLine 'git', 'log', '-1', '--pretty=format:%ct|%h', 'HEAD'
}
} catch (Exception e) {
buildIdOut.write('0'.getBytes())
if (errorsOut.toString().contains("Not a git repository")) {
extraInfo = "(Not a git repository and/or no commits found)\n" +
"Type: git init; git add *; git commit *;"
}
}
//OR? def buildIdOut = (long) ((new Date()).getTime() / 1000)
DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss")
df.setTimeZone(TimeZone.getTimeZone("GMT"))
//split into hash and timestamp
String[] parts = buildIdOut.toString().split("\\|")
def inTimeStamp = Long.parseLong(parts[0])
def date = new Date((inTimeStamp as long) * 1000)
def dateString = df.format(date)
def buildId = "${dateString}.${parts[1]}"
println "buildId = ${buildId} ${extraInfo}"
ext.output = {
return buildId
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
//def buildId = rootProject.tasks.gitBuildId.output()
def rpmVersion = '0.0.0'
//apply plugin: 'java'
//apply plugin: 'gradle-one-jar'
apply plugin: 'application'
//apply plugin: 'idea'
sourceCompatibility = 1.8
// UTF-8 should be standard by now. So use it!
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
mainClassName = 'cucumber.api.cli.Main'
// Add Gradle OneJar Plugin, see https://github.com/rholder/gradle-one-jar
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.53.0'
testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-jvm-deps', version: '1.0.3'
testCompile group: 'info.cukes', name: 'gherkin', version: '2.7.3'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.8'
testCompile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.6'
testCompile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.0.2'
testCompile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.6'
testCompile group: 'org.json', name: 'json', version: '20140107'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'
compile group: 'info.cukes', name: 'cucumber-jvm-deps', version: '1.0.3'
}
// Configure the oneJar task
task oneJar() {
doLast {
mainClass = mainClassName
}
}
//def buildId = rootProject.tasks.gitBuildId.output()
allprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'application'
mainClassName = 'cucumber.api.cli.Main'
// IDE support
apply from: rootProject.file('gradle/ide.gradle')
//cucumber support
//apply from: rootProject.file('gradle/cucumber.gradle')
if (version == 'unspecified') {
version = '0.0.0'
def envVersion = System.env['VERSION']
if (envVersion) {
version = envVersion
}
}
distZip.doFirst {
copy {
from('bin') {
include '**/*'
}
into file("src/dist/bin")
fileMode = 0755
}
}
}
task deleteTestResults() {
delete "build/test-results/test/"
delete "cucumber-html-reports"
}
/*task cucumberTest() {
def arglist = ["--monochrome", "--plugin", "pretty", "--glue", "com.automation.server",
"src/test/resources/features/"]
return javaexec {
main = "cucumber.api.cli.Main"
classpath = sourceSets.main.runtimeClasspath
args = arglist
}
}*/
test {
//we want display the following test events
testLogging {
events "PASSED", "STARTED", "FAILED", "SKIPPED"
//showStandardStreams = true
}
}
task testBoth {
println 'This is executed last during the execution phase.'
}
task wrapper(type: Wrapper) {
gradleVersion = '4.0'
}
artifacts {
oneJar
}
Hej everyone,
I am trying to migrate a small spring boot project from java 8 to kotlin.
I ran into an issue where i have the following configuration class
#EnableCaching
#Configuration
open class CacheConfiguration : CachingConfigurer {
#Bean
override fun cacheManager(): CacheManager {
return ConcurrentMapCacheManager()
}
#Bean
override fun cacheResolver(): CacheResolver {
return SimpleCacheResolver(cacheManager())
}
/**
* Simple Key Generator
* #return not null
*/
#Bean
override fun keyGenerator(): KeyGenerator {
return SimpleKeyGenerator()
}
#Bean
override fun errorHandler(): CacheErrorHandler {
return SimpleCacheErrorHandler()
}
}
This is the actual class. This is literaly the first and only kotlin class in my project.
Starting the project now with gradle bootRun results in a Nullpointer exception in
AutoProxyRegistrar.java#L63
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
Object mode = candidate.get("mode"); <-- candidate is null
It tries to retrieve Annotation Attributes, which works well for the 2 Annotations i provided
#EnableCaching
#Configuration
Though it seems that kotlin adds a new annotation called kotlin.Metadata
which seemingly can not be processed.
build.gradle
buildscript {
ext {
ext.kotlin_version = '1.0.5-2'
springBootVersion = '1.4.3.RELEASE'
asciiDoctorVersion = '1.5.2'
snippetsDir = file('build/generated-snippets')
}
repositories {
jcenter()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.asciidoctor:asciidoctor-gradle-plugin:${asciiDoctorVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'kotlin'
apply plugin: 'org.asciidoctor.convert'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14'
}
test {
outputs.dir snippetsDir
testLogging {
events "passed", "skipped", "failed", "standardError"
}
}
task stage {
dependsOn build
}
asciidoctor {
attributes 'snippets': snippetsDir
inputs.dir snippetsDir
dependsOn test
}
// Force ./gradlew cleanTest
allprojects {
tasks.matching { task -> task.name == "test" }.all {
outputs.upToDateWhen { false }
}
}
dependencies {
compile(group: 'org.springframework.boot', name: 'spring-boot-starter')
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-web')
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa')
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-actuator')
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-security')
compile(group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.0.10.RELEASE')
compile(group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.4.RELEASE')
compile(group: 'org.postgresql', name: 'postgresql', version: '9.4.1209.jre7')
testCompile(group: 'com.jayway.restassured', name: 'rest-assured', version: '2.9.0')
testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test')
}
Reproducible Sample
I have created a small repository to reproduce this issue.
https://github.com/spring-projects/spring-framework-issues/pull/145
And This https://jira.spring.io/browse/SPR-15055
This was an actual bug which was fixed here https://jira.spring.io/browse/SPR-15055