Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame^] | 1 | apply plugin: 'maven-publish' |
| 2 | apply plugin: 'java' |
| 3 | //apply plugin: 'net.ltgt.errorprone' |
| 4 | |
| 5 | def pubVersion |
| 6 | if (project.hasProperty("publishVersion")) { |
| 7 | pubVersion = project.publishVersion |
| 8 | } else { |
| 9 | pubVersion = WPILibVersion.version |
| 10 | } |
| 11 | |
| 12 | def baseArtifactId = project.baseId |
| 13 | def artifactGroupId = project.groupId |
| 14 | def javaBaseName = "_GROUP_edu_wpi_first_${project.baseId}_ID_${project.baseId}-java_CLS" |
| 15 | |
| 16 | def outputsFolder = file("$project.buildDir/outputs") |
| 17 | |
| 18 | task sourcesJar(type: Jar, dependsOn: classes) { |
| 19 | classifier = 'sources' |
| 20 | from sourceSets.main.allSource |
| 21 | } |
| 22 | |
| 23 | task javadocJar(type: Jar, dependsOn: javadoc) { |
| 24 | classifier = 'javadoc' |
| 25 | from javadoc.destinationDir |
| 26 | } |
| 27 | |
| 28 | task outputJar(type: Jar, dependsOn: classes) { |
| 29 | baseName javaBaseName |
| 30 | destinationDir outputsFolder |
| 31 | from sourceSets.main.output |
| 32 | } |
| 33 | |
| 34 | task outputSourcesJar(type: Jar, dependsOn: classes) { |
| 35 | baseName javaBaseName |
| 36 | destinationDir outputsFolder |
| 37 | classifier = 'sources' |
| 38 | from sourceSets.main.allSource |
| 39 | } |
| 40 | |
| 41 | task outputJavadocJar(type: Jar, dependsOn: javadoc) { |
| 42 | baseName javaBaseName |
| 43 | destinationDir outputsFolder |
| 44 | classifier = 'javadoc' |
| 45 | from javadoc.destinationDir |
| 46 | } |
| 47 | |
| 48 | artifacts { |
| 49 | archives sourcesJar |
| 50 | archives javadocJar |
| 51 | archives outputJar |
| 52 | archives outputSourcesJar |
| 53 | archives outputJavadocJar |
| 54 | } |
| 55 | |
| 56 | addTaskToCopyAllOutputs(outputSourcesJar) |
| 57 | addTaskToCopyAllOutputs(outputJavadocJar) |
| 58 | addTaskToCopyAllOutputs(outputJar) |
| 59 | |
| 60 | build.dependsOn outputSourcesJar |
| 61 | build.dependsOn outputJavadocJar |
| 62 | build.dependsOn outputJar |
| 63 | |
| 64 | project(':').libraryBuild.dependsOn build |
| 65 | |
| 66 | publishing { |
| 67 | publications { |
| 68 | |
| 69 | java(MavenPublication) { |
| 70 | artifact jar |
| 71 | artifact sourcesJar |
| 72 | artifact javadocJar |
| 73 | |
| 74 | artifactId = "${baseArtifactId}-java" |
| 75 | groupId artifactGroupId |
| 76 | version pubVersion |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | test { |
| 82 | useJUnitPlatform() |
| 83 | systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' |
| 84 | testLogging { |
| 85 | events "failed" |
| 86 | exceptionFormat "full" |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if (project.hasProperty('onlyAthena') || project.hasProperty('onlyRaspbian')) { |
| 91 | test.enabled = false |
| 92 | } |
| 93 | |
| 94 | repositories { |
| 95 | mavenCentral() |
| 96 | //maven.url "https://oss.sonatype.org/content/repositories/snapshots/" |
| 97 | } |
| 98 | |
| 99 | sourceSets { |
| 100 | dev |
| 101 | } |
| 102 | |
| 103 | tasks.withType(JavaCompile).configureEach { |
| 104 | options.compilerArgs = ['--release', '8'] |
| 105 | } |
| 106 | |
| 107 | dependencies { |
| 108 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0' |
| 109 | testImplementation 'org.junit.jupiter:junit-jupiter-params:5.2.0' |
| 110 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0' |
| 111 | |
| 112 | devCompile sourceSets.main.output |
| 113 | |
| 114 | //errorprone 'com.google.errorprone:error_prone_core:2.3.2-SNAPSHOT' |
| 115 | //errorproneJavac 'com.google.errorprone:error_prone_core:2.3.1' |
| 116 | } |
| 117 | |
| 118 | task run(type: JavaExec) { |
| 119 | classpath = sourceSets.dev.runtimeClasspath |
| 120 | |
| 121 | main = project.devMain |
| 122 | } |
| 123 | |
| 124 | build.dependsOn devClasses |