---
title: "gradle打包依赖jar"
author: "aaa110110"
date: "2014-11-04T15:45:59Z"
tags: []
categories: ["编程语言"]
slug: "gradle-jar"
draft: false
lastmod: "2014-11-04T15:46:25Z"
id: 2152295
url: "https://aaa110110.iteye.com/blog/2152295"
---

```
apply plugin: 'java'
apply plugin: 'maven'

sourceSets {
    main {
        java {
            srcDir 'src/java'
        }
        resources {
            srcDir 'src/resources'
        }
    }
}

repositories {
	mavenCentral()
}

dependencies {
	compile (
	    	"org.eclipse.jetty.websocket:websocket-client:9.3.0.M1"	
	) 
}

jar {
	manifest {
		attributes 'Main-Class': 'com.xxx.screenshot.WebSocketClientTest'
	}
	from {
		configurations.compile.collect {
		    it.isDirectory() ? it : zipTree(it)
		}
		configurations.runtime.collect {
		    it.isDirectory() ? it : zipTree(it)
		}
	}
}
```