Trying to Publish Artifact to Maven Repository

devops

Well-known member
  • Apr 3, 2023
    631
    473
    63
    colombo

    Trying to Publish Artifact to Maven Nexus* Repository​


    help me to fix this errors

    'maven' cannot be applied to '(java.lang.Class<org.gradle.api.publish.maven.MavenPublication>, groovy.lang.Closure)'

    'artifact' cannot be applied to '(groovy.lang.GString, groovy.lang.Closure)'

    'extension' cannot be applied to '(java.lang.String)'

    Dependency maven:junit:junit:4.12 is vulnerable, safe version 4.13.1 CVE-2020-15250 5.5 Incorrect Permission Assignment for Critical Resource vulnerability pending CVSS allocation Results powered by Checkmarx(c)
     

    Attachments

    • Screenshot from 2023-08-15 13-10-13.png
      Screenshot from 2023-08-15 13-10-13.png
      191.5 KB · Views: 91
    Last edited:

    devops

    Well-known member
  • Apr 3, 2023
    631
    473
    63
    colombo
    Code:
    plugins {
        id 'java'
        id 'org.springframework.boot' version '2.2.2.RELEASE'
        id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    }
    
    group 'com.example'
    version '1.0-SNAPSHOT'
    
    sourceCompatibility = 1.8
    
    apply plugin: 'maven-publish'
    
    publishing {
        publications {
            maven(MavenPublication) {
                artifact("build/libs/my-app-$version"+".jar") {
                    extension 'jar'
                }
            }
        }
    
        repositories {
            maven {
                name 'nexus'
                url "http://64.227.133.184:8081/repository/maven-snapshots/"
                credentials {
                    username project.repoUser
                    password project.repoPassword
                }
            }
        }
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web'
        implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '5.2'
        testImplementation group: 'junit', name: 'junit', version: '4.12'
    }