-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d418eb
commit f9aa08d
Showing
8 changed files
with
593 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
build/ | ||
target/ | ||
bin/ | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
.gradle/ | ||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar | ||
**/.mvn/wrapper/maven-wrapper.jar | ||
.settings/ | ||
.classpath | ||
.project | ||
.DS_Store | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
// define all versioned plugins here and apply in subprojects as necessary without version | ||
plugins { | ||
id 'com.github.sherter.google-java-format' version '0.8' apply false | ||
id 'net.ltgt.errorprone' version '0.6' apply false | ||
id 'net.researchgate.release' version '2.7.0' apply false | ||
|
||
// apply so we can correctly configure the test runner to be gradle at the project level | ||
id 'org.jetbrains.gradle.plugin.idea-ext' version '0.7' | ||
} | ||
|
||
// run tests in intellij using gradle test runner | ||
idea.project.settings { | ||
delegateActions { | ||
delegateBuildRunToGradle = false | ||
testRunner = 'GRADLE' | ||
} | ||
} | ||
|
||
import net.ltgt.gradle.errorprone.CheckSeverity | ||
|
||
subprojects { | ||
group 'com.google.cloud.tools' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'checkstyle' | ||
apply plugin: 'com.github.sherter.google-java-format' | ||
apply plugin: 'net.ltgt.errorprone' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
compileJava.options.encoding = 'UTF-8' | ||
compileJava.options.compilerArgs += [ '-Xlint:deprecation' ] | ||
compileTestJava.options.compilerArgs += [ '-Xlint:deprecation' ] | ||
|
||
/* PROJECT DEPENDENCY VERSIONS */ | ||
// define all common versioned dependencies here | ||
project.ext.dependencyVersions = [ | ||
GUAVA: '28.1-jre', | ||
JSR305: '3.0.2', // transitively pulled in by GUAVA | ||
|
||
// for Build Plan and Jib Plugins Extension API | ||
GRADLE_EXTENSION: '0.3.0', | ||
MAVEN_EXTENSION: '0.3.0', | ||
|
||
MAVEN_API: '3.5.2', | ||
|
||
//test | ||
JUNIT: '4.12', | ||
MOCKITO_CORE: '3.2.4', | ||
SLF4J_API: '1.7.25', | ||
SYSTEM_RULES: '1.19.0', | ||
] | ||
/* PROJECT DEPENDENCY VERSIONS */ | ||
|
||
/* ERROR PRONE */ | ||
dependencies { | ||
// NullAway errorprone plugin | ||
annotationProcessor 'com.uber.nullaway:nullaway:0.7.9' | ||
errorprone 'com.google.errorprone:error_prone_core:2.3.4' | ||
// Using github.com/google/error-prone-javac is required when running on | ||
// JDK 8. Remove when migrating to JDK 11. | ||
if (System.getProperty('java.version').startsWith('1.8.')) { | ||
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1') | ||
} | ||
} | ||
|
||
// Adds NullAway errorprone checks. | ||
tasks.withType(JavaCompile) { | ||
if (!name.toLowerCase().contains('test')) { | ||
options.errorprone { | ||
check('NullAway', CheckSeverity.ERROR) | ||
option('NullAway:ExcludedFieldAnnotations', 'org.apache.maven.plugins.annotations.Component') | ||
option('NullAway:AnnotatedPackages', 'com.google.cloud.tools') | ||
} | ||
} | ||
} | ||
/* ERROR PRONE */ | ||
|
||
/* GOOGLE JAVA FORMAT */ | ||
googleJavaFormat { | ||
toolVersion = '1.6' | ||
} | ||
check.dependsOn verifyGoogleJavaFormat | ||
/* GOOGLE JAVA FORMAT */ | ||
|
||
/* CHECKSTYLE */ | ||
checkstyle { | ||
toolVersion = '8.29' | ||
|
||
// use google checks from the jar | ||
def googleChecks = resources.text.fromArchiveEntry(configurations.checkstyle[0], 'google_checks.xml').asString() | ||
|
||
// set the location of the suppressions file referenced in google_checks.xml | ||
configProperties['org.checkstyle.google.suppressionfilter.config'] = getConfigDirectory().file('checkstyle-suppressions.xml').get().toString() | ||
|
||
// add in copyright header check on only java files (replace the last </module> in file) | ||
def copyrightChecks = ''' | ||
<module name="RegexpHeader"> | ||
<property name="headerFile" value="${config_loc}/copyright-java.header"/> | ||
<property name="fileExtensions" value="java"/> | ||
<property name="id" value="header"/> | ||
</module> | ||
</module> | ||
''' | ||
googleChecks = googleChecks.substring(0, googleChecks.lastIndexOf('</module>')) + copyrightChecks | ||
|
||
// this is the actual checkstyle config | ||
config = resources.text.fromString(googleChecks) | ||
|
||
maxErrors = 0 | ||
maxWarnings = 0 | ||
} | ||
/* CHECKSTYLE */ | ||
|
||
/* TEST CONFIG */ | ||
tasks.withType(Test) { | ||
reports.html.setDestination file("${reporting.baseDir}/${name}") | ||
} | ||
|
||
test { | ||
testLogging { | ||
showStandardStreams = true | ||
exceptionFormat = 'full' | ||
} | ||
} | ||
|
||
configurations { | ||
tests | ||
} | ||
/* TEST CONFIG */ | ||
|
||
/* INTEGRATION TESTS */ | ||
sourceSets { | ||
integrationTest { | ||
java.srcDir file('src/integration-test/java') | ||
resources.srcDir file('src/integration-test/resources') | ||
} | ||
} | ||
|
||
configurations { | ||
integrationTestImplementation.extendsFrom testImplementation | ||
integrationTestRuntime.extendsFrom testRuntime | ||
} | ||
|
||
dependencies { | ||
integrationTestImplementation sourceSets.main.output | ||
integrationTestImplementation sourceSets.test.output | ||
integrationTestImplementation configurations.compile | ||
integrationTestImplementation configurations.testImplementation | ||
integrationTestImplementation configurations.runtime | ||
integrationTestImplementation configurations.testRuntime | ||
} | ||
|
||
// Integration tests must be run explicitly | ||
task integrationTest(type: Test) { | ||
testClassesDirs = sourceSets.integrationTest.output.classesDirs | ||
classpath = sourceSets.integrationTest.runtimeClasspath | ||
systemProperty '_JIB_DISABLE_USER_AGENT', true | ||
} | ||
|
||
integrationTest.dependsOn test | ||
|
||
configurations { | ||
integrationTests | ||
} | ||
/* INTEGRATION TESTS */ | ||
|
||
/* JAVADOC ENFORCEMENT */ | ||
// Fail build on javadoc warnings | ||
tasks.withType(Javadoc) { | ||
options.addBooleanOption('Xwerror', true) | ||
} | ||
assemble.dependsOn javadoc | ||
/* JAVADOC ENFORCEMENT */ | ||
|
||
/* JAR */ | ||
jar { | ||
manifest { | ||
attributes 'Implementation-Title': project.name, | ||
'Implementation-Version': version, | ||
'Built-By': System.getProperty('user.name'), | ||
'Built-Date': new Date(), | ||
'Built-JDK': System.getProperty('java.version'), | ||
'Built-Gradle': gradle.gradleVersion | ||
} | ||
} | ||
/* JAR */ | ||
|
||
/* MAVEN CENTRAL RELEASES */ | ||
// for projects that release to maven central | ||
project.ext.configureMavenRelease = { | ||
apply plugin: 'maven-publish' | ||
task sourceJar(type: Jar) { | ||
from sourceSets.main.allJava | ||
classifier 'sources' | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
from javadoc.destinationDir | ||
classifier 'javadoc' | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
pom { | ||
// to be filled by subproject after calling configure configureMavenRelease | ||
// name = '' | ||
// description = '' | ||
|
||
url = 'https://github.com/GoogleContainerTools/jib-extensions' | ||
inceptionYear = '2020' | ||
|
||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
distribution = 'repo' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'chanseokoh' | ||
name = 'Chanseok Oh' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'loosebazooka' | ||
name = 'Appu Goundan' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
url = 'https://github.com/GoogleContainerTools/jib-extensions' | ||
connection = 'scm:https://github.com/GoogleContainerTools/jib-extensions.git' | ||
developerConnection = 'scm:git://github.com/GoogleContainerTools/jib-extensions.git' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
generatePomFileForMavenJavaPublication { | ||
destination = file("${project.buildDir}/pom/${project.name}-${project.version}.pom") | ||
} | ||
// define a special install task that handles installing locally for manual testing | ||
task install { | ||
dependsOn publishToMavenLocal | ||
} | ||
|
||
// For kokoro sign and release to maven central | ||
task prepareRelease(type: Copy) { | ||
from jar | ||
from sourceJar | ||
from javadocJar | ||
from generatePomFileForMavenJavaPublication | ||
into "${project.buildDir}/release-artifacts" | ||
dependsOn build | ||
dependsOn cleanPrepareRelease | ||
} | ||
} | ||
/* MAVEN CENTRAL RELEASE */ | ||
} | ||
|
||
|
||
/* LOCAL DEVELOPMENT HELPER TASKS */ | ||
tasks.register('dev') { | ||
subprojects.each { subproject -> | ||
subproject.tasks.classes.dependsOn subproject.tasks.googleJavaFormat | ||
dependsOn subproject.tasks.check | ||
dependsOn subproject.tasks.javadoc | ||
} | ||
} | ||
|
||
tasks.register('devFull') { | ||
dependsOn tasks.dev | ||
subprojects.each { subproject -> | ||
dependsOn subproject.tasks.integrationTest | ||
} | ||
} | ||
/* LOCAL DEVELOPMENT HELPER TASKS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE suppressions PUBLIC | ||
"-//Puppy Crawl//DTD Suppressions 1.1//EN" | ||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> | ||
<suppressions> | ||
<!-- clash with google java format --> | ||
<suppress files=".*\.java" checks="SingleLineJavadoc"/> | ||
<suppress files=".*\.java" checks="Indentation"/> | ||
<suppress files=".*\.java" checks="RightCurly"/> | ||
<suppress files=".*\.java" checks="LineLength"/> | ||
|
||
<!-- leniency for test files --> | ||
<suppress files=".*[\\/]src[\\/]test[\\/].*\.java" checks="MissingJavadocMethod"/> | ||
<suppress files=".*[\\/]src[\\/]test[\\/].*\.java" checks="VariableDeclarationUsageDistance"/> | ||
<suppress files=".*[\\/]src[\\/]integration-test[\\/].*\.java" checks="MissingJavadocMethod"/> | ||
<suppress files=".*[\\/]src[\\/]integration-test[\\/].*\.java" checks="VariableDeclarationUsageDistance"/> | ||
|
||
</suppressions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
^/\*$ | ||
^ \* Copyright 20[12][0-9] Google LLC\.$ | ||
^ \*$ | ||
^ \* 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 | ||
^ \*$ | ||
^ \* http://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\.$ | ||
^ \*/$ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.