2013-07-17 15 views
2

我試圖強制checkstyle插件使用xml配置存儲在不同的jar文件(作爲依賴項)。gradle - checkstyle配置文件在單獨的jar

我創建了一個只包含該配置文件的包。

在的build.gradle我有以下配置:

apply plugin: 'checkstyle' 

checkstyle { 
    checkstyleMain { 
     classpath += configurations.checkstyleDep 
    } 
    checkstyleTest { 
     classpath += configurations.checkstyleDep 
    } 
    configFile = new File(getClass().getResource("/checkstyle.xml").toURI()) 
    println(configFile) 
} 

configurations { 
    checkstyleDep 
} 

dependencies { 
    checkstyleDep "com.example:checkstyle-common:1.0" 
} 

不幸的是這不會導致gradle這個看的依賴。

我的代碼有什麼問題?有一個更好的方法嗎?

+0

是對的 'com。示例:CheckStyle的,常見的有:1.0' 在你的倉庫罐子可用? – ssindelar

+0

是的,它是 - 我已經把它放到本地maven倉庫中,並正確下載。 –

+0

你試過把它作爲buildscript的依賴嗎? – mtrovo

回答

0

由於gradle 2.2可以將config xml設置爲字符串。

我做

checkstyle { 
    config = getClass().getResource("checkstyle.xml").text 
}