build.gradle 2.14 KB
Newer Older
PWF-WK01\pengwufeng committed
1 2 3 4
buildscript {
	if ("local".equals(mavenRepo)) {
		repositories {
			maven {
PWF-WK01\pengwufeng committed
5 6 7 8 9
				credentials {
					username getUsername
					password getPassword
				}
				url mavenPluginRepoUrl
PWF-WK01\pengwufeng committed
10 11 12
			}
		}
		dependencies {
PWF-WK01\pengwufeng committed
13 14 15 16
			if ("true".equals(useEcj)) {
				classpath "com.beecode:ecj-plugin:0.5.1"
			}
			classpath "com.beecode:mk-gradle-plugin:1.1.0"
PWF-WK01\pengwufeng committed
17 18 19 20 21
		}
	}
}

apply plugin: "eclipse"
22
apply plugin: "idea"
PWF-WK01\pengwufeng committed
23 24 25 26

configure(subprojects) { project ->
	apply from: "../common.gradle"
	if ("local".equals(mavenRepo)) {
PWF-WK01\pengwufeng committed
27 28 29 30
		if ("true".equals(useEcj) && "local".equals(mavenRepo)) {
			apply plugin: 'com.beecode.enzyme.ecj-plugin'
		}
		apply plugin: 'com.beecode.mk-plugin'
PWF-WK01\pengwufeng committed
31 32 33 34 35 36 37 38 39 40 41 42 43
	}

	repositories {
		if ("jcenter".equals(mavenRepo)) {
			jcenter()
		} else if ("mavenCentral".equals(mavenRepo)) {
			mavenCentral()
		} else if ("ali".equals(mavenRepo)) {
			maven {
				url aliRepoUrl
			}
		} else if ("local".equals(mavenRepo)) {
			maven {
PWF-WK01\pengwufeng committed
44 45 46 47
				credentials {
					username getUsername
					password getPassword
				}
PWF-WK01\pengwufeng committed
48 49
				url mavenRepoUrl
			}
PWF-WK01\pengwufeng committed
50 51 52
			//maven {
			//	url aliRepoUrl
			//}
PWF-WK01\pengwufeng committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
		} else {
			// default
			jcenter()
		}
	}

	task sourcesJar(type: Jar, dependsOn: classes) {
		// classifier = 'sources'
		// from sourceSets.main.allSource
	}

	task javadocJar(type: Jar, dependsOn: javadoc) {
		classifier = 'javadoc'
		from javadoc.destinationDir
	}

	task buildCopy(type: Copy) {
		from 'build/classes/mk/main'
	    into 'src/main/resources'
	    include '**/*.jmx'
	}
	
	task buildCopy2bin(type: Copy) {
		from 'build/classes/mk/main'
	    into 'bin'
	    include '**/*.jmx'
	}

	publishing {
		publications {
			mavenJava(MavenPublication) {
				from components.java
				// artifact sourcesJar
			}
		}
		repositories {
			maven {
				credentials {
					username publishUsername
					password publishPassword
				}
				if (version.endsWith('-SNAPSHOT')) {
					url publishSnapshotRepo
				} else {
					url publishReleaseRepo
				}
			}
		}
	}

}

task build(type: Zip) {
	subprojects.forEach {
		dependsOn it.getTasksByName("build", false), it.getTasksByName("buildCopy", false), it.getTasksByName("buildCopy2bin", false)
		from it.tasks.jar.archivePath
	}
	destinationDir = new File(buildDir, "archive")
}