diff --git a/common-gradle-scripts/java.gradle b/common-gradle-scripts/java.gradle index 7da251277f..750c53a7d8 100644 --- a/common-gradle-scripts/java.gradle +++ b/common-gradle-scripts/java.gradle @@ -20,6 +20,7 @@ // apply plugin: 'com.github.spotbugs' apply plugin: 'jacoco' apply plugin: 'java' +apply plugin: 'maven-publish' java.sourceCompatibility = JavaVersion.VERSION_11 repositories { @@ -30,3 +31,34 @@ repositories { } } +jar { + into("META-INF/maven/$project.group/$project.name") { + from { generatePomFileForMavenPublication } + rename ".*", "pom.xml" + } +} + +publishing { + publications { + maven(MavenPublication) { + from components.java + } + } + + repositories { + maven { + name 'nexus' + // TODO: define public nexus repositories + url = "https://maven.wso2.org/nexus/service/local/staging/deploy/maven2/" + credentials { + username rootProject.hasProperty("nexus_username") ? nexus_username : System.getenv("NEXUS_USERNAME") + password rootProject.hasProperty("nexus_password") ? nexus_password : System.getenv("NEXUS_PASSWORD") + } + allowInsecureProtocol = false + } + } +} + +tasks.named('build').configure { + finalizedBy publishToMavenLocal +} diff --git a/gateway/enforcer/Dockerfile b/gateway/enforcer/Dockerfile index 62ed13dfb7..9b3008d578 100644 --- a/gateway/enforcer/Dockerfile +++ b/gateway/enforcer/Dockerfile @@ -68,7 +68,7 @@ ARG APK_USER_GROUP_ID=10001 ARG APK_USER_HOME=/home/${APK_USER} ARG GRPC_HEALTH_PROBE_PATH=/bin/grpc_health_probe ARG TARGETARCH -ARG APK_VERSION=1.1.0-SNAPSHOT +ARG APK_VERSION=1.0-SNAPSHOT ENV VERSION=${APK_VERSION} ENV JAVA_OPTS="" @@ -127,4 +127,5 @@ COPY resources/check_health.sh . #todo add applicationinsights.json file and point it to the appInsightsAgent jar #Add the agent using JVM arg -javaagent:/home/wso2/conf/applicationinsights-agent-3.1.1.jar #Add the config file using System property -Dapplicationinsights.configuration.file=/home/wso2/conf/applicationinsights.json -CMD java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="${ENFORCER_HOME}/logs/heap-dump.hprof" $JAVA_OPTS -Dlog4j.configurationFile="${ENFORCER_HOME}/conf/log4j2.properties" -DtracingEnabled="true" -jar lib/enforcer-${VERSION}.jar + +CMD java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="${ENFORCER_HOME}/logs/heap-dump.hprof" $JAVA_OPTS -Dlog4j.configurationFile="${ENFORCER_HOME}/conf/log4j2.properties" -DtracingEnabled="true" -cp "lib/*:lib/dropins/*" org.wso2.apk.enforcer.server.AuthServer diff --git a/gateway/enforcer/build.gradle b/gateway/enforcer/build.gradle index 79a1ae4ea3..f29997056a 100644 --- a/gateway/enforcer/build.gradle +++ b/gateway/enforcer/build.gradle @@ -34,7 +34,7 @@ release { } task build{ - dependsOn("org.wso2.apk.enforcer:build_enforcer") + dependsOn("resources:build") finalizedBy docker_build } @@ -45,6 +45,7 @@ allprojects { subprojects { apply from: "$rootDir/../../common-gradle-scripts/java.gradle" + afterReleaseBuild.dependsOn publish } tasks.named("afterReleaseBuild").configure { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/build.gradle b/gateway/enforcer/org.wso2.apk.enforcer/build.gradle index 21fdfe75ce..5a7bc193a7 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/build.gradle +++ b/gateway/enforcer/org.wso2.apk.enforcer/build.gradle @@ -15,10 +15,6 @@ * */ -plugins { - id 'com.github.johnrengelman.shadow' version '7.1.0' -} - description = 'WSO2 APK Enforcer' sourceSets { @@ -99,21 +95,3 @@ dependencies { implementation libs.mockito.inline } } -shadowJar { - baseName = 'enforcer' - version = project.version - classifier = '' - - manifest { - attributes 'Main-Class': 'org.wso2.apk.enforcer.server.AuthServer' - } - mergeServiceFiles() -} -tasks.register("copyJar", Copy) { - from shadowJar.archivePath - into "../resources/lib" -} -tasks.register("build_enforcer"){ - dependsOn("shadowJar") - finalizedBy("copyJar") -} \ No newline at end of file diff --git a/gateway/enforcer/resources/build.gradle b/gateway/enforcer/resources/build.gradle new file mode 100644 index 0000000000..5eff7d1496 --- /dev/null +++ b/gateway/enforcer/resources/build.gradle @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +description = 'WSO2 Enforcer Distribution Resources' + +dependencies { + implementation project(':org.wso2.apk.enforcer') + implementation project(':org.wso2.apk.enforcer.commons') +} +tasks.register('copy_dependencies', Copy) { + dependsOn create_lib + from configurations.default + into "$projectDir/lib" + finalizedBy build +} + +tasks.register('create_lib') { + dependsOn delete_lib + finalizedBy copy_dependencies +} + +tasks.register('delete_lib', Delete) { + delete "$projectDir/lib" + finalizedBy create_lib +} + +tasks.named('build').configure { + dependsOn copy_dependencies +} + +configurations.implementation { + exclude group: 'jline' + exclude group: 'org.slf4j', module: 'slf4j-log4j12' + exclude group: 'org.apache.logging' + exclude group: 'log4j' + exclude group: 'org.ops4j.pax.logging' +} \ No newline at end of file diff --git a/gateway/enforcer/settings.gradle b/gateway/enforcer/settings.gradle index 07edaabf9f..f838896316 100644 --- a/gateway/enforcer/settings.gradle +++ b/gateway/enforcer/settings.gradle @@ -18,6 +18,7 @@ rootProject.name = 'enforcer-parent' include(':org.wso2.apk.enforcer') include(':org.wso2.apk.enforcer.commons') + include(':resources') include(':org.wso2.apk.enforcer.analytics.publishers') dependencyResolutionManagement {