我有我自己的gradle插件,其中包含带有其他插件版本的文件。当前,每当我创建一个新项目时,都必须将它们复制过来,因为我无法使用插件中的版本。
反正有没有加载我的插件,应用它,然后再加载其他插件的方法?目前,我只能在创建名为#include <stdio.h>
#include <string.h>
char line[1001]; // The line supports up to a 1000 characters
char lines[11][1001]; // An array of lines (up to 10 lines where each line is a 1000 characters max)
char info[100]; // Holds extra info provided by user
char * extra_info(
char string_1[],
char string_2[],
char string_3[],
char string_4[],
char string_5[]
);
int main(){
int
i, // Line number
j; // Length of the line
char result[100], text[100];
FILE *file;
strcpy(text, "String No."); // The default text
file = fopen("test.txt", "w+"); // Open the file for reading and writing
for(i = 0; i < 10; i++){ // Loop to create a line.
if(i != 9){ // If the line is NOT at the 10th string
sprintf(result, "%s%d, ", text, i); // Format the text and store it in result
}
else{
sprintf(result, "%s%d ", text, i); // Format the text and store it in result
}
strncat(line, info, 100); // Append the extra info at the end of each line
strncat(line, result, 15); // Concatenate all strings in one line
}
extra_info(
"st",
"nd",
"rd",
"th",
"th"
);
strncat(line, "\n\n", 2); // Add a new-line character at the end of each line
for(j = 0; j < 10; j++){ // Now loop to change the line
strcpy(lines[i], line); // Copy the line of text into each line of the array
fputs(lines[i], file); // Put each line into the file
}
fclose(file);
}
char * extra_info( // Append user defined and predefined info at the end of a line
char string_1[],
char string_2[],
char string_3[],
char string_4[],
char string_5[]
){
char text[100]; // A variable to hold the text
/* Append a default text into each strings
and concatenate them into one line */
sprintf(text, " 1%s", string_1);
strncat(line, text, 100);
sprintf(text, ", 2%s", string_2);
strncat(line, text, 100);
sprintf(text, ", 3%s", string_3);
strncat(line, text, 100);
sprintf(text, ", 4%s", string_4);
strncat(line, text, 100);
sprintf(text, ", 5%s.", string_5);
strncat(line, text, 100);
return line;
}
的插件模型时亲自为项目执行此操作,因为它会自动将其添加到其他模块中。
我要实现的示例:
buildSrc
以及在主项目中将插件作为模块时的外观:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "ca.allanwang:kau:$kau_version"
}
// Apply plugin before other dependencies so I can use it
apply plugin: "ca.allanwang.kau"
dependencies {
classpath kauPlugin.android
classpath kauPlugin.kotlin
classpath kauPlugin.androidMaven
classpath kauPlugin.playPublisher
classpath kauPlugin.dexCount
classpath kauPlugin.gitVersion
classpath kauPlugin.spotless
}
wrapper.setDistributionType(Wrapper.DistributionType.ALL)
}
答案 0 :(得分:1)
通过组合不同的东西,您应该能够实现想要的目标:
Settings
object为Plugin<Settings>
的事实,在您要应用的settings.gradle(.kts)
中定义ExtensionAware
的版本pluginManagement
中定义插件类路径pluginManagement
定义版本的简单版本示例:https://github.com/ljacomet/setttings-plugin-props,其插件位于buildSrc
中,但可以发布,并且可以用作二进制插件。