概述
- 在看源碼的時候茬暇,不想看Maven下載的jar包中的源碼首昔,因為這個源碼是只讀的糙俗,不能做注釋;
- 想直接用從GitHub上下載的源碼赊颠,讓自己的項目依賴于用這個源碼構(gòu)建成的Maven項目;
一巨税、Gradle 項目轉(zhuǎn) Maven 項目
- 從GitHub上下載的Disruptor源碼是個Gradle項目草添,Gradle不會用,轉(zhuǎn)成Maven項目抄淑;
- 對disruptor-master中的build.gradle做如下修改
group = 'com.lmax.source'
sourceCompatibility = 1.8
targetCompatibility = 1.8
task writeNewPom {
pom {
project {
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("$buildDir/pom.xml")
}
- build 這個 disruptor-master
$ ./gradlew build -x test
- 把 disruptor-master\build\pom.xml 復(fù)制到 disruptor-master\pom.xml 驰后;
二、在自己的項目中添加 Module
- 把 disruptor-master\pom.xml 作為 Module 引入到自己的項目中郑原;
- 引入后犯犁,相應(yīng)的 Sources -> Language level女器,Dependencies -> Module SDK 改成1.8;
- File --> Setting --> Build,Execution,Deployment --> Compiler --> Java Compiler 對應(yīng)的 Target bytecode version 都改成1.8涣澡;
三丧诺、讓自己的項目依賴新添加的 Module
- 在自己的項目的 Dependencies 中添加這個 Module Denpendency;
- 完成后事格,自己的項目中用到的 Disruptor 代碼就直接運行了這個新添加的 Module 中的源碼搞隐,這個源碼是可以自己加注釋的;
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者