How to install a compiled by Gradle jar into the local Gradle Repository files-2.1 instead of the Maven repository?

前端 未结 4 2173
失恋的感觉
失恋的感觉 2021-02-13 04:17

In my build.gradle, I added the plugin:

apply plugin: \'maven\'

Then using “gradle install” I can copy the resulted jar into the maven reposito

4条回答
  •  悲哀的现实
    2021-02-13 04:56

    A build.gradle sample to create a Jar file along with its logback dependencies. using mavenlocale()

    apply plugin: 'java'
    
    apply plugin: 'eclipse'
    
    version = '1.0'
    
    sourceCompatibility = 1.7
    
    target Compatibility = 1.7
    
    //create a single Jar with all dependencies
    
     task fatJar(type: Jar) {
    
         manifest {
    
            attributes 'Implementation-Title': 'Gradle Jar File Example',
    
                'Implementation-Version': version,
    
                'Main-Class': 'com.mkyong.DateUtils'
        }
        baseName = project.name + '-all'
    
        from { configurations.compile.collect { it.isDirectory() ? it : 
    zipTree(it)
    
     } 
    
    }
        with jar
    }
    
    //Get dependencies from Maven central repository
    
    repositories {
    
        mavenCentral()
    }
    
    //Project dependencies
    
    dependencies {
    
        compile 'ch.qos.logback:logback-classic:1.1.2'
    
    }
    

    Reference create a Jar file along with its logback dependencies.

提交回复
热议问题