Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ plugins {
id "com.diffplug.spotless" version "6.25.0"
}

dependencyManagement {
applyMavenExclusions = false
}

apply from: 'gradle/spotless.gradle'

group = 'com.rangerforce'
version = '1.0.0'
def spockVersion = '2.4-M4-groovy-4.0' // Doesn't follow SimVer so using a variable
def swt_version = '3.124.100'

java {
sourceCompatibility = '17'
Expand Down Expand Up @@ -40,6 +45,9 @@ dependencies {
// Spock Framework
testImplementation "org.spockframework:spock-core:${spockVersion}"
testImplementation "org.spockframework:spock-spring:${spockVersion}"

// Spotless workaround for Groovy
compileOnly 'org.eclipse.platform:org.eclipse.swt:3.124.100'
}

test {
Expand All @@ -58,3 +66,25 @@ test {
info.exceptionFormat = lifecycle.exceptionFormat
}
}

// Setting value of osgi_platform based on OS value
def os = System.getProperty("os.name").toLowerCase()
if (os.contains("win")) {
ext.osgi_platform = "win32.win32.x86_64"
} else if (os.contains("mac")) {
ext.osgi_platform = "cocoa.macosx.x86_64"
} else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
ext.osgi_platform = "linux"
} else {
ext.osgi_platform = "unknown"
}

configurations.all {
resolutionStrategy {
dependencySubstitution {
// The maven property ${osgi.platform} is not handled by Gradle
// so we replace the dependency, using the osgi platform from the project settings
substitute module('org.eclipse.platform:org.eclipse.swt.${osgi.platform}') with module("org.eclipse.platform:org.eclipse.swt.${ext.osgi_platform}:${swt_version}")
}
}
}
14 changes: 14 additions & 0 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ spotless {

licenseHeader '/* (C) $YEAR */' // or licenseHeaderFile
}

groovy {
target '**/*.groovy' // Specify the files to format (all .groovy files in the project)
greclipse("4.9") // Use Google Java Format for Groovy code formatting
trimTrailingWhitespace() // Trim trailing whitespace
indentWithSpaces(4) // Use 4 spaces for indentation
}

groovyGradle {
target '**/*.gradle' // Specify the files to format (all .groovy files in the project)
greclipse("4.9") // Use Google Java Format for Groovy code formatting
trimTrailingWhitespace() // Trim trailing whitespace
indentWithSpaces(4) // Use 4 spaces for indentation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import spock.lang.Specification
@SpringBootTest
class LoadContextSpec extends Specification {

@Autowired (required = false)
private HelloController helloController

def "when context is loaded then all expected beans are created"() {
expect: "the HelloController is created"
helloController
}
@Autowired (required = false)
private HelloController helloController

def "when context is loaded then all expected beans are created"() {
expect: "the HelloController is created"
helloController
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rangerforce.spockexample.domain.repository


import spock.lang.Shared
import spock.lang.Specification

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class StarFleetShipResourceSpec extends Specification {
@SpringBean
private StarshipsRepository starshipsRepository = Stub() {
findAll() >> [
"USS Enterprise (NCC-1701)",
"USS Voyager (NCC-74656)",
"USS Defiant (NX-74205)"
"USS Enterprise (NCC-1701)",
"USS Voyager (NCC-74656)",
"USS Defiant (NX-74205)"
]
findByRegistryName("ncc-1701") >> ussEnterprise
findByRegistryName(_ as String) >> { throw new RecordNotFoundException("Not Found") }
Expand Down