How to setup Spek Framework - gradle

I've checked the docs:
https://spekframework.org/migration/#maven-coordinates
I wanted to try out version 2.x.x, so I added in build.gradle:
testImplementation ("org.spekframework.spek2:spek-dsl-jvm:2.0.0")
testRuntimeOnly ('org.spekframework.spek2:spek-runner-junit5')
But Gradle is unable to find that 2.x.x library in Maven Central:
https://search.maven.org/search?q=spek-dsl-jvm
What should I do? Is there a special repo?

try to configure your repositories with:
maven { url 'https://oss.jfrog.org/artifactory/libs-snapshot'}
Your dependency should be as follows:
dependency "org.spekframework.spek2:spek-dsl-jvm:$spekVersion"
where spekVersion = "2.0.0-SNAPSHOT"

You should add the following maven repo to your build file:
repositories {
jcenter()
}
Then for the dependencies:
testCompile group: 'org.spekframework.spek2', name: 'spek-dsl-jvm', version: '2.0.0-rc.1'
testCompile group: 'org.spekframework.spek2', name: 'spek-runner-junit5', version: '2.0.0-rc.1'
You could also checkout https://github.com/spekframework/spek-multiplatform-example for more info.

Related

Adding sources for IntelliJ plugin via Gradle

I've setup an IntelliJ plugin using Gradle. My build.gradle file contains:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
}
//...
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
intellij {
version '2018.2.4'
plugins 'git4idea'
}
Is there any way how I can include/download the sources of the Git4Idea plugin to the project so that they are available automatically?
No, you can't. It'a bug. I filed it here on the plugin's issue tracker.

Unable to pass argument from gradle command line to Spring project (not Boot)

I am developing Spring project.
I would like to load credentials from the command line not storying them in the code. I'm trying to execute this gradle command
gradlew build -Dspring.datasource.username=tester
and when I startup the Spring project, the program stops on a breakpoint and I see whether variable is declared or not. I have tried using -P instead of -D but it still didn't help.
I deploy the spring app remotely using bmuschko plugin I've tried to use, but also without success. I checked in java code Properties by using System.getProperties() and Environment object supported by Spring.
gradlew cargoredeployremote -Dspring.datasource.username=tester
Application properties are loaded succesfully.
IMPORTANT: I saw many tutorials how to make it but using Spring Boot I use just selected components from Spring.
For instance: http://nixmash.com/post/passing-arguments-to-spring-boot - this doesn't work in my case because I have no bootRun task.
Any ideas? Am I missing something in my steps?
Here is my build.gradle
group 'example'
version '1.0.0'
apply plugin: 'application'
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'com.bmuschko.cargo'
apply plugin: 'org.liquibase.gradle'
compileJava.options.encoding = 'UTF-8'
mainClassName = 'api.optic.config.WebAppInitializer'
sourceCompatibility = 1.8
buildscript {
repositories{
jcenter()
mavenCentral()
}
dependencies{
classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3'
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.liquibase:liquibase-core:3.4.1'
classpath "org.liquibase:liquibase-gradle-plugin:1.2.4"
classpath "mysql:mysql-connector-java:5.1.13"
}
}
project.ext {
springVersion = "4.3.6.RELEASE"
junitVersion = "5.0.0-RC3"
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-context-support:${springVersion}"
compile "org.springframework:spring-beans:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"
compile "org.springframework:spring-oxm:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework:spring-test:${springVersion}"
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.38'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.6'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.2'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.0.pr2'
compile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
cargo {
containerId = 'tomcat8x'
port = 8080
deployable {
context = 'example'
}
remote {
hostname = 'host.name.com'
username = 'tomcat'
password = 'pass'
}
Basically were 2 issues
1. Name mismatch: in application.properties the name inside the ${} was different than this provided from command-line
Solution:
application.properties
spring.datasource.username=${username}
and in gradle command-line
gradle build -Pusername=tester
2. Dot issue with gradle:
Can't put
gradle build -Pspring.datasource.username=tester
even if you have in application.properties
spring.datasource.username=${spring.datasource.username}
because you get an exception:
Execution failed for task ':processResources'.
Could not copy file '.\src\main\resources\application.properties' to '.\build\resources\main\application.properties'.
Solution:
Instead of dots use _ sign
gradle build -Pspring_datasource_username=tester
and in Application properties
spring.datasource.username=${spring_datasource_username}

How to download Griffon distribution in Intellij Gradle project?

I am trying to start a Griffon project. The Griffon repository is available from bintray. I created a Gradle project in Intellij and added the maven repository provided into the build.gradle file. But the project structure is not being generated. I need to know how create a Griffon project in Intellij correctly. I am adding the code from the build.gradle file that i edited.
apply plugin: 'java'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/griffon/griffon"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Please follow the instructions found at http://griffon-framework.org/ and http://griffon-framework.org/tutorials/1_getting_started.html.
Note that IntelliJ includes a Griffon plugin that works with Griffon 1.x but does not work with Griffon 2.x. Griffon 2 can be opened/imported as a normal Gradle or Maven project.

Gradle dependency management using pom.xml

In build.gradle we specify the dependencies as
compile group: 'org.apache.pig', name: 'pigunit', version: '0.11.0-cdh4.5.0', transitive: true
Running gradle cleanEclipse eclipse sets up the projects(adds the jar to classpath)
However there are only maven dependencies available for some APIs
(I am trying to run jersey 2.x examples bundle from https://jersey.java.net/download.html and it provides only pom.xml)
EDIT:
I know i can specify
compile group: 'groupId', name: 'artifactId', version: 'version' gradle but doing it manually for all dependencies or writing a program to do so should not be natural gradle way.
Gradle provides a maven plugin http://gradle.org/docs/current/userguide/maven_plugin.html.I haven't tried it out but it should be able to do it
Gradle supports Maven dependencies. Just specify the dependencies in the same way as your example:
compile group: 'groupId', name: 'artifactId', version: 'version'
To lookup the the artifact coordinates, you can use sites like http://search.maven.org
The only thing you have to make sure is to include either your internal Maven repository (if you are in a company which has one) or Maven Central:
repositories {
mavenCentral()
}
or
repositories {
maven {
url "http://repo.mycompany.com/maven2"
}
}

Confused with Gradle Dependencies

I am trying to add my dependencies to Gradle Dependencies library in eclipse, and when I run this, it downloads these dependencies, however my other dependencies are in the Gradle Dependencies folder under Gradle Project in eclipse but this one is not. Please help, I just need to add a Gradle Dependency in eclipse.
repositories {
mavenCentral()
maven {
url "http://clojars.org/repo"
}
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile "org.clojars.jmeeks:jfugue-with-musicxml:4.0.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
You should tell to gradle about your local repository adding mavenLocal() first in repositories section. Using your current configuration you are telling to gradle that everything is stored in mavenCentral or the custom repo.

Resources