diff --git a/gradle.properties b/gradle.properties index 703ab64b4a..0d019e1375 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,7 @@ dependencyJREVersion=jdk-11.0.18+10-jre specVersion=2023R1 slf4jVersion=1.7.30 balstdlibBranch=master +devIdpUrl=https://dev.api.asgardeo.io/oauth2/token/.well-known/openid-configuration # Stdlib Level 01 stdlibConstraintVersion=1.3.0-20230620-195700-ca941bc diff --git a/project-api-tests/build.gradle b/project-api-tests/build.gradle index a6b152fb35..0be4c140e5 100644 --- a/project-api-tests/build.gradle +++ b/project-api-tests/build.gradle @@ -48,7 +48,6 @@ task centralTests { dependsOn configurations.jBallerinaDistribution dependsOn configurations.ballerinaDistribution dependsOn configurations.ballerinaLinuxDistribution - dependsOn configurations.ballerinaLinuxDistribution dependsOn configurations.ballerinaWindowsDistribution test { systemProperty "distributions.dir", "$buildDir/../../ballerina/build/distributions" @@ -69,4 +68,41 @@ task centralTests { } } -test.dependsOn centralTests + + task checkURL { + doLast { + try { + URL url = new URL("${devIdpUrl}") + HttpURLConnection connection = (HttpURLConnection) url.openConnection() + connection.setRequestMethod("GET") + connection.connect() + + int code = connection.getResponseCode() + if (code == 200) { + logger.lifecycle("Connection to ${devIdpUrl} is successful. Running tests...") + ext.isURLAvailable = true + } else { + logger.lifecycle("Connection to ${devIdpUrl} is not successful. Skipping tests...") + logger.lifecycle("-----------------------------------------") + logger.lifecycle(" WARNING: Skipping the project api tests") + logger.lifecycle("-----------------------------------------") + ext.isURLAvailable = false + } + } catch(Exception ex) { + logger.lifecycle("Connection to ${devIdpUrl} is not successful. Exception while connecting to " + + "${devIdpUrl}. Skipping tests...") + logger.lifecycle("-----------------------------------------") + logger.lifecycle(" WARNING: Skipping the project api tests") + logger.lifecycle("-----------------------------------------") + ext.isURLAvailable = false + } + } + } + + test { + dependsOn checkURL + onlyIf { + checkURL.isURLAvailable + } + dependsOn centralTests + }