java安卓寫文件路徑,如何使用gradle作為構建系統,平臺Android配置Protobuf(Java)文件的輸出路徑?...

我正在努力解決以下問題:

我有2個基于maven的java項目和1個基于gradle的Android項目 . 布局如下:

Workspace/

├── MavenProj1/

├── MavenProj2/

├── AndroidGradleProject1/

├── Protos/

所有這些的包結構很常見,比方說 com.example.* 所以,maven項目配置為:

從 Protos 項目獲取protoc文件,生成Java源代碼到 com.example.protos .

通過gradle我實現了以下目標:

從 Protos 項目獲取protoc文件,生成JavaLite代碼到 com.example.protos . But! Javalite插件生成自己的子文件夾 . 結果如下:

AndroidGradleProject1/

├── app/

└──src/main/java/com/example/

└── protos/

└── debug/

└── lite/

└── com/example/protos/

所以,最后我的build.gradle文件:

apply plugin: 'com.android.application'

apply plugin: 'com.google.protobuf'

android {

compileSdkVersion 26

defaultConfig {

applicationId "com.example"

minSdkVersion 24

targetSdkVersion 26

multiDexEnabled true

versionCode 1

versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

sourceSets {

main {

proto {

srcDir '../../../protos'

}

java {

srcDir 'src/main/java'

}

}

}

}

protobuf {

protoc {

artifact = "com.google.protobuf:protoc:3.5.0"

}

generatedFilesBaseDir = "$projectDir/src/main/java/com/example/protos"

plugins {

lite {

// The codegen for lite comes as a separate artifact

artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'

}

}

generateProtoTasks {

all().each {

task ->

task.builtins {

remove java

}

task.plugins {

lite {}

}

}

}

}

clean {

delete protobuf.generatedFilesBaseDir

}

dependencies {

protobuf files('../../protos')

implementation 'com.google.protobuf:protobuf-lite:3.0.0'

implementation 'com.google.protobuf:protobuf-java:3.5.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:26.1.0'

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

implementation 'com.android.support:support-v4:26.1.0'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.1'

androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378529.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378529.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378529.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java System類exit()方法及示例

系統類exit()方法 (System class exit() method) exit() method is available in java.lang package. exit()方法在java.lang包中可用。 exit() method is used to exit the currently running JVM (Java Virtual Machine). exit()方法用于退出當前正在運行的JVM(Java虛擬機)。…

基于圖像處理的數碼印花噴墨墨滴形狀規范的研究(Python+OpenCV+Mysql)

大體思路:由于墨滴的不同參數會對墨滴的形態產生一定的影響,故如果通過研究墨滴的形態則通過海量的數據就可以大概確定墨滴的各項參數指標的范圍。通過OpenCV對墨滴的噴出的形狀進行圖像處理,對墨滴圖像進行一系列的分析,通過一系…

ASP.NET 主題(Themes)FAQ

1、主題是什么 主題由一組元素組成:外觀、級聯樣式表 (CSS)、圖像和其他資源。主題將至少包含外觀。主題是在網站或 Web 服務器上的特殊目錄中定義的。主題是一組Web Control的屬性設置的集合,提供一種簡單的方法設置控件的樣式屬性。 主題只在Web Contr…

Head First HTML與CSS、XHTML++筆記(第四章 WEB鎮之旅 第五章 認識媒體)

第四章 鏈接&#xff08;詳解<a>元素&#xff09; 目標錨 在目標位置 <h2><a id"chai">contentTest</a></h2> 在需要鏈接位置 <a href"index.html#chai">See</a> 鏈接到自身的目標錨 <a href"#top"…

Opencv實戰【4】——圖片動漫化處理

博主聯系方式&#xff1a; QQ:1540984562 微信&#xff1a;wxid_nz49532kbh9u22 QQ交流群&#xff1a;750313950 目錄動漫化風格的特點處理手段代碼實現效果總結動漫化風格的特點 &#xff08;1&#xff09;動漫中的細節相對少&#xff1b; &#xff08;2&#xff09;動漫中的邊…

nextshort_Java掃描儀的nextShort()方法與示例

nextshort掃描器類的nextShort()方法 (Scanner Class nextShort() method) Syntax: 句法&#xff1a; public short nextShort();public short nextShort(int rad);nextShort() method is available in java.util package. nextShort()方法在java.util包中可用。 nextShort() …

php 生成css文件怎么打開,php生成html文件的多種步驟介紹

//定義日期函數functiongetdatetime(){$datetimegetdate();$strReturn$datetime["year"]."-";$strReturn$strReturn.$datetime["mon"]."-";$strReturn$strReturn.$datetime["mday"];return$strReturn;}//定義時間函數(文件名…

08-KNN手寫數字識別

標簽下載地址 文件內容備注train-images-idx3-ubyte.gz訓練集圖片&#xff1a;55000張訓練圖片&#xff0c;5000張驗證圖片train-labels-idx1-ubyte.gz訓練集圖片對應的數字標簽t10k-images-idx3-ubyte.gz測試集圖片&#xff1a;10000張圖片t表示test&#xff0c;測試圖片&…

MFC odbc訪問遠程數據庫

首先&#xff0c;MFC通過ODBC訪問數據庫&#xff0c;主要使用兩個類&#xff0c;一個是CDataBase&#xff0c;一個是CRecordset。第一個是用于建立數據庫連接的&#xff0c;第二個是數據集&#xff0c;用來查詢的。步驟如下&#xff1a;1.實例化一個CDataBase對象&#xff0c;并…

微機原理——擴展存儲器設計

目錄【1】存儲器的層次結構【2】存儲器的分類【3】SRAM1、基本原理&#xff1a;2、結構&#xff1a;3、芯片參數與引腳解讀&#xff1a;4、CPU與SRAM的連接方式【4】DRAM1、基本原理&#xff1a;2、結構3、芯片引腳解讀&#xff1a;【5】存儲器系統設計【6】存儲器擴展設計&…

floatvalue 重寫_Java Number floatValue()方法與示例

floatvalue 重寫Number類floatValue()方法 (Number Class floatValue() method) floatValue() method is available in java.lang package. floatValue()方法在java.lang包中可用。 floatValue() method is used to return the value denoted by this Number object converted …

array_column php什么版本可以用,array_column兼容php5.5以下版本

gistfile1.txt// ----------------------------------------------------------------------// |獲取二維數組中指定的一列&#xff0c;PHP5.5以后有專用函數array_column()// ----------------------------------------------------------------------// |param array $arr// …

。net學習之控件的使用注意點

jQuery使用 1、自定義屬性的使用<script>$(#xwjj_i_main br[brinfoPd_KangQiao_Subject_Xwjj_br_1]).hide();</script> 2、ready代碼塊$(document).ready(function(){ //你的代碼}); 3、簡單的特效hide&#xff08;&#xff09;$("a").click(function()…

09-CNN手寫數字識別

CNN卷積神經網絡的本質就是卷積運算 維度的調整&#xff1a; tf.reshape(imageInput,[-1,28,28,1]) imageInput為[None,784]&#xff0c;N行* 784維 調整為 M28行28列*1通道 即&#xff1a;二維轉化為四維數據 參數一&#xff1a;等價于運算結果M 參數二&#xff1a;28 28 表示…

【轉】左值與右值

出處&#xff1a;http://www.embedded.com/electronics-blogs/programming-pointers/4023341/Lvalues-and-Rvalues C and C enforce subtle differences on the expressions to the left and right of the assignment operator If youve been programming in either C or C for…

Opencv將處理后的視頻保存出現的問題

問題描述&#xff1a; 代碼運行過程中&#xff0c;imshow出來的每幀的效果圖是正確的&#xff0c;但是按照網上的方法保存下來卻是0kb&#xff0c;打開不了。 參考的網上的一些方法&#xff0c;均是失敗的&#xff0c;具體原因我也不清楚&#xff1a; 1、例如我這樣設置&#x…

Java Number shortValue()方法與示例

Number類shortValue()方法 (Number Class shortValue() method) shortValue() method is available in java.lang package. shortValue()方法在java.lang包中可用。 shortValue() method is used to return the value denoted by this Number object converted to type short (…

MATLAB可以打開gms文件嗎,gms文件擴展名,gms文件怎么打開?

.gms文件類型&#xff1a;Gesture and Motion Signal File擴展名為.gms的文件是一個數據文件。文件說明&#xff1a;Low-level, binary, minimal but generic format used to organize and store Gesture and Motion Signals in a flexible and optimized way; gesture-related…

黑白圖片顏色反轉并保存

將圖像的黑白顏色反轉并保存 import cv2 # opencv讀取圖像 img cv2.imread(rE:\Python-workspace\OpenCV\OpenCV/YY.png, 1) cv2.imshow(img, img) img_shape img.shape # 圖像大小(565, 650, 3) print(img_shape) h img_shape[0] w img_shape[1] # 彩色圖像轉換為灰度圖…

家貓WEB系統

現在只放源碼在些.為它寫應用很簡單有空整理文檔演示地址:jiamaocode.com/os/ 源碼&#xff1a;http://jiamaocode.com/ProCts/2011/04/14/1918/1918.html轉載于:https://www.cnblogs.com/jiamao/archive/2011/04/16/2018339.html