我在一个名为parent的插件中有项目范围的设置,它试图应用maven-publish插件,然后以编程方式配置发布扩展.这似乎有效,但是当我在build.gradle脚本中应用此插件时,我无法配置发布扩展以设置项目特定的发布.
我收到错误:
Cannot configure the 'publishing' extension after it has been accessed.
Run Code Online (Sandbox Code Playgroud)
我的目的是在父插件中设置发布存储库,然后让每个build.gradle脚本添加适当的发布.
有没有办法做到这一点?
目前ParentPlugin.groovy看起来像:
def void apply(Project project) {
project.getProject().apply plugin: 'maven-publish'
def publishingExtension = project.extensions.findByName('publishing')
publishingExtension.with {
repositories {
maven {
mavenLocal()
credentials {
username getPropertyWithDefault(project.getProject(), 'publishUserName', 'dummy')
password getPropertyWithDefault(project.getProject(), 'publishPassword', 'dummy')
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的客户端build.gradle在尝试配置发布扩展时失败.
apply plugin: 'parent'
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'agroup'
artifactId 'anartifactid'
version '1.0.0-SNAPSHOT'
from components.java
}
}
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?还有另一种方法我应该接近这个吗?
我想从src中排除src\main和src\test文件
FileCollection files =
project.fileTree(/src/).minus(project.fileTree(/src\main/)).minus(project.fileTree(/src\test/))
Run Code Online (Sandbox Code Playgroud)
如何在没有双减去用法的情况下排除此目录?