javascriptmavenartifactorynexusautomotive-grade-linux

Trouble running ./gradlew build


Gradle cannot build to an unknown error

I attempted to build an application by typing the command ./gradelw build on the terminal. It throws an error message that Build file '/home/muhammad/bootcamp-projects/java-app/build.gradle'

line: 28

A problem occurred evaluating root project 'my-app'. Could not get unknown property 'repoUser' for root project 'my-app' of type org.gradle.api.Project.

this is the 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://159.65.23.158: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'                               
}                                                                                                   
                                                                                                                                                                          
    repositories {                                                    
        maven {                                                       
            name 'nexus'                                              
            url "http://159.65.23.158: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-logb
    testImplementation group: 'junit', name: 'junit', version: '4.12' 
}                                                                     
    
`                                                              

please can you help me


Solution

  • You do not say where you defined repoUser and repoPassword .

    If these are defined as environment variables, then you can use:

    username = System.getenv('repoUser')                                                           
    password = System.getenv('repoPassword')