我正在使用这个示例Gradle Plugin项目: https://github.com/AlainODea/gradle-com.example.hello-plugin
当我运行 ./ gradlew publishToMavenLocal 时,它将在M2_HOME中创建以下文件:
当我运行 ./ gradlewarticleoryPublish 时,它会记录:
Deploying artifact: https://artifactory.example.com/artifactory/libs-release-local-maven/com/example/hello/gradle-com.example.hello-plugin/0.1-SNAPSHOT/gradle-com.example.hello-plugin-0.1-SNAPSHOT.jar
Deploying artifact: https://artifactory.example.com/artifactory/libs-release-local-maven/com/example/hello/gradle-com.example.hello-plugin/0.1-SNAPSHOT/gradle-com.example.hello-plugin-0.1-SNAPSHOT.pom
Deploying build descriptor to: https://artifactory.example.com/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under https://artifactory.example.com/artifactory/webapp/builds/gradle-com.example.hello-plugin/1234567890123
尝试从另一个build.gradle加载插件:
plugins {
id 'java'
id 'com.example.hello' version '0.1-SNAPSHOT'
}
使用settings.gradle:
pluginManagement {
repositories {
maven {
url 'https://artifactory.example.com/artifactory/libs-release-local-maven/'
}
}
}
导致此错误:
Plugin [id: 'com.example', version: '0.1-SNAPSHOT'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.example.hello:com.example.hello.gradle.plugin:0.1-SNAPSHOT')
Searched in the following repositories:
maven(https://artifactory.example.com/artifactory/libs-release-local-maven/)
Gradle Central Plugin Repository
我想让publishToMavenLocal创建的所有工件在我运行artisticoryPublish时发布到Artifactory。如果使用错误的工具,我可以使用artifactoryPublish的替代方法。
如何将Gradle插件发布到Artifactory?
答案 0 :(得分:0)
由于您具有 maven-publish 插件,因此 java-gradle-plugin 已经为您声明了发布,因此您可以从自己的列表中删除this explicit publications block构建:
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
}
您可以按以下方式引用your artifactory publish defaults block中所有自动创建的出版物:
invokeMethod("publications", publishing.publications.names.toTypedArray())
为什么不只是 publishing.publications.names ?:
这是完整的,经过纠正的工件块:
artifactory {
setProperty("contextUrl", "https://artifactory.verafin.com/artifactory")
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
setProperty("repoKey", "libs-release-local-maven")
})
defaults(delegateClosureOf<GroovyObject> {
invokeMethod("publications", publishing.publications.names.toTypedArray())
})
})
}
这是您的build.gradle.kts的完整改编版,可以解决该问题:
import groovy.lang.GroovyObject
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
buildscript {
repositories {
jcenter()
}
}
plugins {
`java-gradle-plugin`
`maven-publish`
`kotlin-dsl`
id("com.jfrog.artifactory") version "4.9.0"
kotlin("jvm") version "1.3.11"
id("io.spring.dependency-management") version "1.0.6.RELEASE"
}
group = "com.example.hello"
version = "0.1-SNAPSHOT"
gradlePlugin {
plugins {
create("helloPlugin") {
id = "com.example.hello"
implementationClass = "com.example.HelloPlugin"
}
}
}
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom("org.junit:junit-bom:5.3.2")
}
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit:junit-bom:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("com.natpryce:hamkrest:1.7.0.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
tasks {
withType<JavaExec> {
jvmArgs = listOf("-noverify", "-XX:TieredStopAtLevel=1")
}
withType<KotlinCompile> {
val javaVersion = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
kotlinOptions {
apiVersion = "1.3"
javaParameters = true
jvmTarget = javaVersion
languageVersion = "1.3"
}
}
withType<Test> {
@Suppress("UnstableApiUsage")
useJUnitPlatform()
}
}
artifactory {
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
setProperty("repoKey", "libs-release-local-maven")
})
defaults(delegateClosureOf<GroovyObject> {
invokeMethod("publications", publishing.publications.names.toTypedArray())
})
})
}
以下是显示插件工件成功部署到Artifactory的日志:
Deploying artifact: https://artifactory.example.com/artifactory/libs-release-local-maven/com/example/hello/gradle-com.example.hello-plugin/0.1-SNAPSHOT/gradle-com.example.hello-plugin-0.1-SNAPSHOT.jar
Deploying artifact: https://artifactory.example.com/artifactory/libs-release-local-maven/com/example/hello/gradle-com.example.hello-plugin/0.1-SNAPSHOT/gradle-com.example.hello-plugin-0.1-SNAPSHOT.pom
Deploying artifact: https://artifactory.example.com/artifactory/libs-release-local-maven/com/example/hello/com.example.hello.gradle.plugin/0.1-SNAPSHOT/com.example.hello.gradle.plugin-0.1-SNAPSHOT.pom
Deploying build descriptor to: https://artifactory.example.com/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under https://artifactory.example.com/artifactory/webapp/builds/gradle-com.example.hello-plugin/1234567890123
答案 1 :(得分:0)
从 build-info-extractor-gradle 插件的 4.19 版开始,就有了一个可以使用的 jQuery(".swiper-container li").click(function(){
setTimeout(function(){ window.dispatchEvent(new Event('resize')); }, 1000);
})
常量:
ALL_PUBLICATIONS