私の会社は最近バニラ設定(リポジトリ、プロジェクト間の共通依存関係など)用のgradleプラグインを作成しました。全体として、これはビルドプロセスを大幅に簡素化し、プロジェクト間でいくつかの矛盾を明らかにしました。最近、sourcesJar
タスクをプラグインに追加しようとしましたが、動作しません。ソースをカスタムGradleプラグインに追加
package com.mycompany.plugins
import org.gradle.api.Project
import org.gradle.api.Plugin
import org.gradle.api.tasks.bundling.Jar
class OurJavaPlugin implements Plugin<Project> {
void apply(Project project) {
def date = com.mycompany.util.UtilityFunctions.getDate()
project.configure(project) {
println('Applying Java properties to: ' + project.name)
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'
version = date
// Use the local repos
repositories {
maven {
url "$externalDependenciesRepo"
}
maven {
url "$internalDependenciesRepo"
}
}
uploadArchives {
repositories {
mavenDeployer {
// Deploy to internal repo
repository(url: "$internalDependenciesRepo")
}
}
}
// Common dependencies
dependencies {
compile group: 'log4j', name: 'log4j', version:'1.2.17'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.6.6'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.6.6'
testCompile "junit:junit:$junit_version"
}
eclipse.project {
natures 'org.springsource.ide.eclipse.gradle.core.nature'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
}
}
}
このプラグインは、sourcesJar
を除いて、素晴らしい作品:
はここで壊れたプラグインです。私は(と私たちの地元のレポに展開/コンパイル)ミックスにあることを追加すると、私はプラグインを使用してプロジェクトをビルドしようとすると、私はこのエラーを取得する:
$ gradle :myProject:clean -x Test
Applying Java properties to: myProject
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\me\Documents\code\root\myProject\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':myProject'.
> Failed to apply plugin [id 'customjava']
> Could not find method sourcesJar() for arguments [{type=class org.gradle.api.tasks.bundling.Jar, dependsOn=task ':analytics-isr:classes'}, com.mycompany.plugins.OurJavaPlugin [email protected]] on project ':myProject'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.352 secs
コードをそのまま追加しても機能しませんか?何が起こっていますか? – Opal
.configureの中にコードを入れればエラーになります。できるだけ早くエラーを更新します。 – fbl
エラーメッセージ – fbl