Hello everybody, I have the following build.gradle file.
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
group 'org.example'
version '2.0'
sourceCompatibility = 1.8
publishing {
publications {
maven(MavenPublication){
artifact ("build/libs/my_maven_app-$version"+".jar"){
extension "jar"
}
}
}
repositories {
maven {
name 'nexus'
url 'nexus(http://167.71.41.177:8081/repository/maven-snapshots/)'
// credentials {
// username project.repoUser
// password project.repoPassword
// }
}
}
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
implementation group: 'com.cisco.oss.foundation', name: 'configuration-api', version: '1.1.0-1'
implementation group: 'org.codehaus.sonar-plugins.python', name: 'python-squid', version: '1.5'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
}
test {
useJUnitPlatform()
}
and I am trying to push it to the maven repository on Nexus.
I can execute command ./gradlew publish and it gives the following result on the terminal of Intellij IDEA.
\King Julien$ ./gradlew publish
BUILD SUCCESSFUL in 630ms
2 actionable tasks: 2 executed
and also I can see that directory is being created on Intellij with my remote destination address of the Maven repo. ( Screenshot attached)
Meanwhile, when I go to the root directory of my code and execute the same command I receive the following.
\King Julien$ ./gradlew publish
FAILURE: Build failed with an exception.
- What went wrong:
Task ‘publish’ not found in root project ‘java-app-master’.
- Try:
Run gradlew tasks to get a list of available tasks.
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
- Get more help at https://help.gradle.org
BUILD FAILED in 575ms