Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle migration #144

Merged
merged 4 commits into from
Jul 2, 2021
Merged
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATH_add scripts
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: adopt
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build with Gradle
run: ./gradlew build
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.sw*
_site/
.factorypath
.gradle
.gradletasknamecache
.DS_Store
.checkstyle
Expand Down
1 change: 0 additions & 1 deletion .mvn/jvm.config

This file was deleted.

Empty file removed .mvn/maven.config
Empty file.
Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 0 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id "io.spring.nohttp"
}

description = 'Java Library for Accessing Cloud Foundry Environment Variables'

wrapper {
gradleVersion = "7.1"
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}
140 changes: 140 additions & 0 deletions buildSrc/src/main/groovy/io.pivotal.cfenv.java-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import org.gradle.api.tasks.testing.TestDescriptor
import org.gradle.api.tasks.testing.TestOutputEvent
import org.gradle.api.tasks.testing.TestResult

import java.util.concurrent.ConcurrentHashMap

plugins {
id 'java-library'
id 'maven-publish'
id 'checkstyle'
id 'jacoco'
}

ext.javadocLinks = [
"https://docs.oracle.com/javase/8/docs/api/",
] as String[]

java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

javadoc {
description = "Generates project-level javadoc for use in -javadoc jar"

options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.links(project.ext.javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
}

checkstyle {
configFile = file("${project.rootDir}/src/checkstyle/checkstyle.xml")
}

test {
test.useJUnitPlatform()
}

afterEvaluate { Project project ->
if (project.description == null || project.description.isEmpty()) {
throw new InvalidUserDataException("A project description is required for publishing to maven central")
}

tasks.withType(Test).forEach { Test task ->
task.with {
def jmockit = classpath.find { it.name.contains("jmockit") }
if (jmockit) {
jvmArgs "-javaagent:${jmockit.absolutePath}"
}

testLogging {
exceptionFormat = "full"
events = ["passed", "skipped", "failed"]
showStandardStreams = !project.onlyShowStandardStreamsOnTestFailure
}

if (project.onlyShowStandardStreamsOnTestFailure) {
Map<String, StringBuilder> testOutput = new ConcurrentHashMap<>()

onOutput { TestDescriptor descriptor, TestOutputEvent event ->
testOutput.compute(descriptor.displayName, { k, v ->
v == null ? new StringBuilder(event.message) : v.append(event.message)
})
}

afterTest { TestDescriptor descriptor, TestResult result ->
if (result.resultType == TestResult.ResultType.FAILURE && testOutput.containsKey(descriptor.displayName)) {
logger.lifecycle("\n\n${testOutput.get(descriptor.displayName)}")
testOutput.remove(descriptor.displayName)
}
}
}

// print failed tests after the execution
def failedTests = []
afterTest { test, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failedTests << test
}
}

// create a summary after the execution
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"

failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
}
}
}
}
}

publishing {
repositories {
maven {
url = project.properties.getOrDefault('publicationRepository', "${System.getenv('HOME')}/.m2/repository")
}
}
publications {
mavenJava(MavenPublication) {
suppressAllPomMetadataWarnings()
from components.java

pom {
afterEvaluate {
name = project.description
description = project.description
}
withXml {
def pomNode = asNode()
def dependencyManagementNode = pomNode.get('dependencyManagement')
if (dependencyManagementNode) pomNode.remove(dependencyManagementNode)
}
}

// Published pom will use fully-qualified dependency versions and no BOMs
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
if (project.configurations.findByName('testFixturesRuntimeClasspath')) {
fromResolutionOf('testFixturesRuntimeClasspath')
}
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}
4 changes: 4 additions & 0 deletions ci/config-concourse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
artifactory-server: https://repo.spring.io
build-name: java-cfenv
github-repo: https://github.com/pivotal-cf/java-cfenv
scs-slack-failure-channel: "#spring-cloud-services"
27 changes: 27 additions & 0 deletions ci/config/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!--
~ Copyright 2002-2019 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<module name="Header">
<property name="headerFile" value="ci/config/license.header"/>
<property name="ignoreLines" value="2"/>
</module>
</module>
15 changes: 15 additions & 0 deletions ci/config/license.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
10 changes: 10 additions & 0 deletions ci/config/release-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
logging:
level:
io.spring.concourse: DEBUG
spring:
main:
banner-mode: off
sonatype:
exclude:
- 'build-info\.json'
- '.*\.zip'
14 changes: 14 additions & 0 deletions ci/images/java-cfenv-ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM harbor-repo.vmware.com/dockerhub-proxy-cache/library/ubuntu:bionic

RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates net-tools git curl
RUN rm -rf /var/lib/apt/lists/*

ENV JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH
RUN mkdir -p /opt/openjdk && \
cd /opt/openjdk && \
curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz | tar xz --strip-components=1

ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh /opt/
ADD https://repo.spring.io/libs-release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.3/concourse-release-scripts-0.3.3.jar /opt/

Loading