Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | apply plugin: 'maven-publish' |
| 2 | apply plugin: 'java-library' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 3 | apply plugin: 'jacoco' |
| 4 | |
| 5 | def baseArtifactId = project.baseId |
| 6 | def artifactGroupId = project.groupId |
| 7 | def javaBaseName = "_GROUP_edu_wpi_first_${project.baseId}_ID_${project.baseId}-java_CLS" |
| 8 | |
| 9 | def outputsFolder = file("$project.buildDir/outputs") |
| 10 | |
| 11 | task sourcesJar(type: Jar, dependsOn: classes) { |
| 12 | classifier = 'sources' |
| 13 | from sourceSets.main.allSource |
| 14 | } |
| 15 | |
| 16 | task javadocJar(type: Jar, dependsOn: javadoc) { |
| 17 | classifier = 'javadoc' |
| 18 | from javadoc.destinationDir |
| 19 | } |
| 20 | |
| 21 | task outputJar(type: Jar, dependsOn: classes) { |
| 22 | archiveBaseName = javaBaseName |
| 23 | destinationDirectory = outputsFolder |
| 24 | from sourceSets.main.output |
| 25 | } |
| 26 | |
| 27 | task outputSourcesJar(type: Jar, dependsOn: classes) { |
| 28 | archiveBaseName = javaBaseName |
| 29 | destinationDirectory = outputsFolder |
| 30 | classifier = 'sources' |
| 31 | from sourceSets.main.allSource |
| 32 | } |
| 33 | |
| 34 | task outputJavadocJar(type: Jar, dependsOn: javadoc) { |
| 35 | archiveBaseName = javaBaseName |
| 36 | destinationDirectory = outputsFolder |
| 37 | classifier = 'javadoc' |
| 38 | from javadoc.destinationDir |
| 39 | } |
| 40 | |
| 41 | artifacts { |
| 42 | archives sourcesJar |
| 43 | archives javadocJar |
| 44 | archives outputJar |
| 45 | archives outputSourcesJar |
| 46 | archives outputJavadocJar |
| 47 | } |
| 48 | |
| 49 | addTaskToCopyAllOutputs(outputSourcesJar) |
| 50 | addTaskToCopyAllOutputs(outputJavadocJar) |
| 51 | addTaskToCopyAllOutputs(outputJar) |
| 52 | |
| 53 | build.dependsOn outputSourcesJar |
| 54 | build.dependsOn outputJavadocJar |
| 55 | build.dependsOn outputJar |
| 56 | |
| 57 | project(':').libraryBuild.dependsOn build |
| 58 | |
| 59 | publishing { |
| 60 | publications { |
| 61 | |
| 62 | java(MavenPublication) { |
| 63 | artifact jar |
| 64 | artifact sourcesJar |
| 65 | artifact javadocJar |
| 66 | |
| 67 | artifactId = "${baseArtifactId}-java" |
| 68 | groupId artifactGroupId |
| 69 | version wpilibVersioning.version.get() |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | test { |
| 75 | useJUnitPlatform() |
| 76 | systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' |
| 77 | testLogging { |
| 78 | events "failed" |
| 79 | exceptionFormat "full" |
| 80 | } |
| 81 | finalizedBy jacocoTestReport |
| 82 | } |
| 83 | |
| 84 | if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxraspbian') || project.hasProperty('onlylinuxaarch64bionic')) { |
| 85 | test.enabled = false |
| 86 | } |
| 87 | |
| 88 | repositories { |
| 89 | mavenCentral() |
| 90 | //maven.url "https://oss.sonatype.org/content/repositories/snapshots/" |
| 91 | } |
| 92 | |
| 93 | sourceSets { |
| 94 | dev |
| 95 | } |
| 96 | |
| 97 | tasks.withType(JavaCompile).configureEach { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 98 | options.compilerArgs = [ |
| 99 | '--release', |
| 100 | '11', |
| 101 | '-encoding', |
| 102 | 'UTF8' |
| 103 | ] |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | dependencies { |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame^] | 107 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' |
| 108 | testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' |
| 109 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 110 | |
| 111 | devImplementation sourceSets.main.output |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | task run(type: JavaExec) { |
| 115 | classpath = sourceSets.dev.runtimeClasspath |
| 116 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 117 | mainClass = project.devMain |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | build.dependsOn devClasses |
| 121 | |
| 122 | jacoco { |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame^] | 123 | toolVersion = "0.8.7" |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | jacocoTestReport { |
| 127 | reports { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 128 | xml.required = true |
| 129 | html.required = true |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 130 | } |
| 131 | } |