作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在一个使用gradle和jfrog插件发布到 Artifact 的项目。重要的代码片段如下:
plugins {
id "java"
id "idea"
id "groovy"
id "pmd"
id "findbugs"
id "maven-publish"
id "com.jfrog.artifactory" version "3.1.1"
}
dependencies {
compile 'com.google.guava:guava:18.0'
compile 'com.mashape.unirest:unirest-java:1.4.5'
compile 'log4j:log4j:1.2.14'
}
artifactory {
contextUrl = "https://SOME_SERVER/artifactory"
publish {
repository {
repoKey = 'libs-snapshot-local'
username = artifactory_username
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatsoever</groupId>
<artifactId>some-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
最佳答案
从未在practive上尝试过此方法,但是可以尝试使用publication.pom.withXml
配置块在生成的pom中引入更改:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'compile'
}
}
}
}
}
关于gradle - 如何将 Artifactory 运行时范围更改为编译范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31069666/
我是一名优秀的程序员,十分优秀!