Skip to content

Commit

Permalink
SONARGRADL-97 Moving to Java 11 from Java 8
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Jarocki <[email protected]>
Co-authored-by: Marco Kaufmann <[email protected]>
Co-authored-by: Irina Batinic <[email protected]>
  • Loading branch information
4 people authored May 26, 2023
1 parent 51f0683 commit 45ff1ee
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 329 deletions.
26 changes: 2 additions & 24 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,6 @@ build_task:
path: "**/test-results/**/*.xml"
format: junit

gradle_qa_java8_task:
depends_on:
- build
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
cpu: 2
memory: 2G
env:
matrix:
- GRADLE_VERSION: 6.8.3
ANDROID_GRADLE_VERSION: 4.2.0
- GRADLE_VERSION: 6.8.3
ANDROID_GRADLE_VERSION: 4.1.3
- GRADLE_VERSION: 5.6.4
ANDROID_GRADLE_VERSION: 3.3.2
gradle_cache:
folder: ~/.gradle/caches
script:
- ./cirrus/cirrus-qa.sh
cleanup_before_cache_script:
- ./cirrus/cleanup-gradle-cache.sh

gradle_qa_java11_task:
depends_on:
- build
Expand All @@ -125,6 +102,8 @@ gradle_qa_java11_task:
ANDROID_GRADLE_VERSION: 7.1.0
- GRADLE_VERSION: 6.8.3
ANDROID_GRADLE_VERSION: 4.2.0
- GRADLE_VERSION: 5.6.4
ANDROID_GRADLE_VERSION: 3.5.4
gradle_cache:
folder: ~/.gradle/caches
script:
Expand Down Expand Up @@ -155,7 +134,6 @@ gradle_qa_java17_task:
promote_task:
depends_on:
- build
- gradle_qa_java8
- gradle_qa_java11
- gradle_qa_java17
<<: *ONLY_SONARSOURCE_QA
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ val docUrl = "http://redirect.sonarsource.com/doc/gradle.html"
val githubUrl = "https://github.com/SonarSource/sonar-scanner-gradle"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
Expand Down
6 changes: 3 additions & 3 deletions integrationTests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<properties>
<!-- Default version when running ITs on dev machines. Value overridden in .cirrus.yml -->
<gradle.version>6.8.3</gradle.version>
<androidGradle.version>4.2.0</androidGradle.version>
<jdk.min.version>1.8</jdk.min.version>
<gradle.version>7.5.1</gradle.version>
<androidGradle.version>7.1.0</androidGradle.version>
<jdk.min.version>11</jdk.min.version>
</properties>

<build>
Expand Down
303 changes: 41 additions & 262 deletions integrationTests/src/test/java/org/sonarqube/gradle/AndroidTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
apply plugin: 'java'
apply plugin: 'jacoco' // Apply the jacoco plugin to generate test coverage reports.

// In case Java 8+ is the default JDK, force Java 7 as this module will be used from Android.
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
// Dependencies for local unit tests
testImplementation 'junit:junit:' + rootProject.ext.junitVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
}

android {
compileSdkVersion 23
compileSdkVersion 30
buildTypes {
release {
testCoverageEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dynamicFeatures = [':mydynamicfeature']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ dependencies {
}

android {
compileSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 30
}

android.variantFilter { variant ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
}

android {
compileSdkVersion 23
compileSdkVersion 30
buildTypes {
release {
testCoverageEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ buildscript {
dependencies {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${version}'
classpath 'com.android.tools.build:gradle:${androidGradle.version}'
classpath 'me.tatarka:gradle-retrolambda:3.7.1'
}
}

apply plugin: 'jacoco'
apply plugin: 'com.android.application'
apply plugin: 'org.sonarqube'
apply plugin: 'me.tatarka.retrolambda'

repositories {
google()
Expand All @@ -27,11 +25,7 @@ dependencies {
}

android {
compileSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 30
}

sonar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
compileSdkVersion 30

defaultConfig {
applicationId "com.example.test.myapplication"
minSdkVersion 19
targetSdkVersion 19
minSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
Expand All @@ -19,14 +19,12 @@ android {
testCoverageEnabled = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.support:appcompat-v7:24.2.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
android.useAndroidX=true
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package com.example.test.myapplication;

import android.app.Application;
import android.test.ApplicationTestCase;
import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.myapplication", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ allprojects {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

sourceCompatibility = 11
targetCompatibility = 11

sonar {

properties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.useAndroidX=true

0 comments on commit 45ff1ee

Please sign in to comment.