您的位置:首页 > 编程语言 > Java开发

MONGO JAVA driver源码编译

2015-12-08 17:01 507 查看
文章参考: http://www.cnblogs.com/hoojo/archive/2011/06/02/2068665.html 在线查看源码:https://github.com/mongodb/mongo-java-driver1.先git下来2.使用gradle编译,gradle 安装配置可以看这里,虽然安装了,但实际使用gradlew build的时候还是要进行自动下载gradle,脚本写的好不人性3.编译的好不容易啊,修改后脚本如下
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
def configDir = new File(rootDir, 'config')
ext.nettyVersion = '4.0.26.Final'

buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
jcenter()

}
dependencies {
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
classpath 'com.bmuschko:gradle-nexus-plugin:2.2'
}
}

//////////////////////////////////////////
// Common behavior                      //
//////////////////////////////////////////

configure(subprojects.findAll { it.name != 'util' }) {
apply plugin: 'java'
apply plugin: 'optional-base'

evaluationDependsOn(':util')

group = 'org.mongodb'
version = '3.3.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }

}

dependencies {
compile 'org.slf4j:slf4j-api:1.7.6', optional
}

/* Compiling */
tasks.withType(AbstractCompile) {
options.encoding = 'ISO-8859-1'
options.fork = true
options.debug = true
options.compilerArgs = ['-Xlint:all', '-Xlint:-options']

onlyIf { JavaVersion.current().isJava7Compatible() }
}

project.ext.buildingWith = { propertyName ->
project.hasProperty(propertyName) && project.property(propertyName).toBoolean()
}

}

configure(subprojects.findAll { it.name != 'util' && it.name != 'mongo-java-driver' }) {
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'groovy'
apply plugin: 'codenarc'

dependencies {
testCompile 'org.codehaus.groovy:groovy-all:2.3.9'
testCompile 'org.spockframework:spock-core:1.1-groovy-2.3-SNAPSHOT'
testCompile 'cglib:cglib-nodep:2.2.2'
testCompile 'org.objenesis:objenesis:1.3'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'ch.qos.logback:logback-classic:1.1.1'
testCompile project(':util') //Adding categories to classpath
}

sourceSets {
main {
java.srcDirs = ['src/main']
}
test {
groovy.srcDirs = ['src/test/functional', 'src/test/unit']
java.srcDirs = ['src/test/functional', 'src/test/unit']
}
}

/* Testing */
tasks.withType(Test) {
maxHeapSize = "3g"
maxParallelForks = 1

systemProperties(
'org.mongodb.test.uri': System.getProperty('org.mongodb.test.uri', null),
'org.mongodb.useSocket': System.getProperty('org.mongodb.useSocket', 'false'),
'org.mongodb.disableAsync': System.getProperty('org.mongodb.disableAsync', 'false'),
'org.mongodb.async.type': System.getProperty('org.mongodb.async.type', 'nio2'),

'javax.net.ssl.trustStore': System.getProperty('javax.net.ssl.trustStore', "${System.getProperty('user.home')}/.keystore"),
'javax.net.ssl.keyStore': System.getProperty('javax.net.ssl.keyStore', "${System.getProperty('user.home')}/.keystore"),
'javax.net.ssl.keyStorePassword': System.getProperty('javax.net.ssl.keyStorePassword', 'changeit'),
'javax.net.ssl.trustStorePassword': System.getProperty('javax.net.ssl.trustStorePassword', 'changeit')
)

if (project.buildingWith('ssl.enabled')) {
systemProperties(
'javax.net.ssl.keyStoreType': project.property('ssl.keyStoreType'),
'javax.net.ssl.keyStore': project.property('ssl.keyStore'),
'javax.net.ssl.keyStorePassword': project.property('ssl.keyStorePassword'),
'javax.net.ssl.trustStoreType': project.property('ssl.trustStoreType'),
'javax.net.ssl.trustStore': project.property('ssl.trustStore'),
'javax.net.ssl.trustStorePassword': project.property('ssl.trustStorePassword')
)
}

if (project.buildingWith('gssapi.enabled')) {
systemProperties(
'sun.security.krb5.debug': project.getProperty('sun.security.krb5.debug'),
'javax.security.auth.useSubjectCredsOnly': "false",
'java.security.krb5.kdc': project.getProperty('krb5.kdc'),
'java.security.krb5.realm': project.getProperty('krb5.realm'),
'java.security.auth.login.config': project.getProperty('auth.login.config'),
)
}
/**/
useJUnit {
if (!project.buildingWith('rs.enabled')) {
excludeCategories 'category.ReplicaSet'
}
if (project.buildingWith('quicktest')) {
excludeCategories 'category.SlowUnit'
}
if (project.buildingWith('travistest')) {
excludeCategories 'category.SlowUnit', 'category.Slow'
}
}

jacoco { enabled = false }

beforeTest { descr ->
logger.info("[Test ${descr.className} > ${descr.name}]")
}

afterTest { descr, result ->
def failureStartTime = result.getResultType().toString() == "FAILURE" ? " Started at: ${result.getStartTime()}" : ""
logger.info("[Test ${descr.className} > ${descr.name}] ${result.getResultType()} "
+ "(${result.getEndTime() - result.getStartTime()} ms) ${failureStartTime}")

}

testLogging { exceptionFormat = 'full' }
}
/*
task testSlowUnit(type: Test) {
useJUnit {
includeCategories 'category.SlowUnit'
}
}
*/
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(testCoverage)) {
tasks.withType(Test) { jacoco { enabled = true } }
}
}

task testCoverage(dependsOn: test)

/* Code quality */

checkstyle {
toolVersion = "6.2"
configFile = new File(configDir, 'checkstyle.xml')
configProperties.checkstyleConfigDir = configDir
}

findbugs {
excludeFilter = new File(configDir, 'findbugs-exclude.xml')
sourceSets = [sourceSets.main]
toolVersion = '3.0.1'
}

codenarc {
toolVersion = '0.24'
reportFormat = project.buildingWith('xmlReports.enabled') ? 'xml' : 'html'
}

tasks.withType(FindBugs) {
reports {
xml.enabled = project.buildingWith('xmlReports.enabled')
html.enabled = !project.buildingWith('xmlReports.enabled')
}
}
}
/*
task docs(type: Javadoc) {
source subprojects.grep({ it.name != 'util' }).collect {project -> project.sourceSets.main.allJava }
options = subprojects.first().javadoc.options
dependsOn = subprojects.first().javadoc.dependsOn
excludes =  subprojects.first().javadoc.excludes
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
destinationDir = new File(projectDir, 'build/docs')
}
*/
//////////////////////////////////////////
// Root project configuration           //
//////////////////////////////////////////
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}

gradle.buildFinished { BuildResult result ->
if (result.failure && !JavaVersion.current().isJava7Compatible()) {
gradle.rootProject.logger.error("\n* Warning:\nJDK ${JavaVersion.VERSION_1_7} is minimal requirement for building the driver. " +
"You have ${JavaVersion.current()}.")
}
}

apply from: 'gradle/deploy.gradle'
编译并跳过test 类似mvn   install -Dmaven.test.skipgradlew build -x testPS:报junit的话,就把junit的都注释掉,报生成JAVADOC 有问题的话,就把javadoc的task都删掉,终于Build成了
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: