Tôi có một settings.xml maven nằm ở:Đọc tệp settings.xml của maven khi xây dựng bằng gradle?
/home/u123/.m2/settings.xml
nơi tôi chỉ định một kho maven từ xa:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>my.repo</id>
<url>http://myrepo/ </url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
</settings>
Trong repo này tôi đã triển khai một artifact - thực sự là một Plugin gradle của nó.
Bây giờ tôi cố gắng xây dựng một dự án mà cần phải sử dụng plugin này/vật bằng cách sử dụng tập tin build.gradle dưới đây:
apply plugin: 'java'
apply plugin: 'maven'
buildscript {
dependencies {
classpath 'com.test:my-gradle-plugin:1.0.0-SNAPSHOT'
}
}
Nhưng xây dựng thất bại:
...
> Could not find group:com.test, module:my-gradle-plugin, version:1.0.0-SNAPSHOT.
...
Gradle không thể tìm thấy tôi -gradle-plugin mặc dù tôi có tệp settings.xml ở trên trỏ đến kho lưu trữ maven từ xa.
Nếu tôi thay vì chỉ định kho bên nộp build.gradle tôi nó hoạt động:
buildscript {
repositories {
maven {
url "http://myrepo/"
}
}
dependencies {
classpath 'com.test:my-gradle-plugin:1.0.0-SNAPSHOT'
}
}
Dựa trên bài đăng này:
http://forums.gradle.org/gradle/topics/have_mavenlocal_check_m2_home_conf_settings_xml
có vẻ như gradle mà xem xét cài đặt. xml tập tin như vậy những gì là sai?
Đây là câu trả lời tuyệt vời và cũng hữu ích cho thông tin chung (kịch bản trong tệp xây dựng Gradle).Tôi cũng khuyên mọi người nên đọc câu hỏi này để xem câu trả lời của @ PeterKahn dưới đây, điều này không đòi hỏi thêm kịch bản, nhưng yêu cầu bổ sung thêm. – mnd