github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/java/build.gradle (about)

     1  apply plugin: 'idea'
     2  apply plugin: 'eclipse'
     3  apply plugin: 'java'
     4  apply plugin: 'com.diffplug.spotless'
     5  
     6  group = 'io.lakefs'
     7  version = '0.1.0-SNAPSHOT'
     8  
     9  buildscript {
    10      repositories {
    11          mavenCentral()
    12      }
    13      dependencies {
    14          classpath 'com.android.tools.build:gradle:2.3.+'
    15          classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    16          classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0'
    17      }
    18  }
    19  
    20  repositories {
    21      mavenCentral()
    22  }
    23  sourceSets {
    24      main.java.srcDirs = ['src/main/java']
    25  }
    26  
    27  if(hasProperty('target') && target == 'android') {
    28  
    29      apply plugin: 'com.android.library'
    30      apply plugin: 'com.github.dcendents.android-maven'
    31  
    32      android {
    33          compileSdkVersion 25
    34          buildToolsVersion '25.0.2'
    35          defaultConfig {
    36              minSdkVersion 14
    37              targetSdkVersion 25
    38          }
    39          compileOptions {
    40              sourceCompatibility JavaVersion.VERSION_1_8
    41              targetCompatibility JavaVersion.VERSION_1_8
    42          }
    43  
    44          // Rename the aar correctly
    45          libraryVariants.all { variant ->
    46              variant.outputs.each { output ->
    47                  def outputFile = output.outputFile
    48                  if (outputFile != null && outputFile.name.endsWith('.aar')) {
    49                      def fileName = "${project.name}-${variant.baseName}-${version}.aar"
    50                      output.outputFile = new File(outputFile.parent, fileName)
    51                  }
    52              }
    53          }
    54  
    55          dependencies {
    56              provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
    57          }
    58      }
    59  
    60      afterEvaluate {
    61          android.libraryVariants.all { variant ->
    62              def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
    63              task.description = "Create jar artifact for ${variant.name}"
    64              task.dependsOn variant.javaCompile
    65              task.from variant.javaCompile.destinationDir
    66              task.destinationDir = project.file("${project.buildDir}/outputs/jar")
    67              task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
    68              artifacts.add('archives', task)
    69          }
    70      }
    71  
    72      task sourcesJar(type: Jar) {
    73          from android.sourceSets.main.java.srcDirs
    74          classifier = 'sources'
    75      }
    76  
    77      artifacts {
    78          archives sourcesJar
    79      }
    80  
    81  } else {
    82  
    83      apply plugin: 'java'
    84      apply plugin: 'maven-publish'
    85  
    86      sourceCompatibility = JavaVersion.VERSION_1_8
    87      targetCompatibility = JavaVersion.VERSION_1_8
    88  
    89      publishing {
    90          publications {
    91              maven(MavenPublication) {
    92                 artifactId = 'sdk'
    93                 from components.java
    94              }
    95          }
    96      }
    97  
    98      task execute(type:JavaExec) {
    99         main = System.getProperty('mainClass')
   100         classpath = sourceSets.main.runtimeClasspath
   101      }
   102  }
   103  
   104  ext {
   105      jakarta_annotation_version = "1.3.5"
   106  }
   107  
   108  dependencies {
   109      implementation 'io.swagger:swagger-annotations:1.6.8'
   110      implementation "com.google.code.findbugs:jsr305:3.0.2"
   111      implementation 'com.squareup.okhttp3:okhttp:4.10.0'
   112      implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
   113      implementation 'com.google.code.gson:gson:2.9.1'
   114      implementation 'io.gsonfire:gson-fire:1.8.5'
   115      implementation 'javax.ws.rs:jsr311-api:1.1.1'
   116      implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
   117      implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
   118      implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
   119      implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
   120      testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
   121      testImplementation 'org.mockito:mockito-core:3.12.4'
   122      testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
   123  }
   124  
   125  javadoc {
   126      options.tags = [ "http.response.details:a:Http Response Details" ]
   127  }
   128  
   129  // Use spotless plugin to automatically format code, remove unused import, etc
   130  // To apply changes directly to the file, run `gradlew spotlessApply`
   131  // Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
   132  spotless {
   133      // comment out below to run spotless as part of the `check` task
   134      enforceCheck false
   135  
   136      format 'misc', {
   137          // define the files (e.g. '*.gradle', '*.md') to apply `misc` to
   138          target '.gitignore'
   139  
   140          // define the steps to apply to those files
   141          trimTrailingWhitespace()
   142          indentWithSpaces() // Takes an integer argument if you don't like 4
   143          endWithNewline()
   144      }
   145      java {
   146          // don't need to set target, it is inferred from java
   147  
   148          // apply a specific flavor of google-java-format
   149          googleJavaFormat('1.8').aosp().reflowLongStrings()
   150  
   151          removeUnusedImports()
   152          importOrder()
   153      }
   154  }
   155  
   156  test {
   157      // Enable JUnit 5 (Gradle 4.6+).
   158      useJUnitPlatform()
   159  
   160      // Always run tests, even when nothing changed.
   161      dependsOn 'cleanTest'
   162  
   163      // Show test results.
   164      testLogging {
   165          events "passed", "skipped", "failed"
   166      }
   167  
   168  }