本文整理汇总了Java中org.gradle.api.plugins.JavaPlugin类的典型用法代码示例。如果您正苦于以下问题:Java JavaPlugin类的具体用法?Java JavaPlugin怎么用?Java JavaPlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaPlugin类属于org.gradle.api.plugins包,在下文中一共展示了JavaPlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
public void apply(final Project project) {
project.getPluginManager().apply(JavaBasePlugin.class);
final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
project.getConvention().getPlugins().put("osgi", osgiConvention);
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
OsgiManifest osgiManifest = osgiConvention.osgiManifest();
osgiManifest.setClassesDir(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDir());
osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
Jar jarTask = (Jar) project.getTasks().getByName("jar");
jarTask.setManifest(osgiManifest);
}
});
}
示例2: addDefaultReportTasks
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
/**
* Adds report tasks for specific default test tasks.
*
* @param extension the extension describing the test task names
*/
private void addDefaultReportTasks(final JacocoPluginExtension extension) {
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
project.getTasks().withType(Test.class, new Action<Test>() {
@Override
public void execute(Test task) {
if (task.getName().equals(JavaPlugin.TEST_TASK_NAME)) {
addDefaultReportTask(extension, task);
}
}
});
}
});
}
示例3: configureEclipseProject
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private void configureEclipseProject(final Project project) {
Action<Object> action = new Action<Object>() {
@Override
public void execute(Object ignored) {
project.getTasks().withType(GenerateEclipseProject.class, new Action<GenerateEclipseProject>() {
@Override
public void execute(GenerateEclipseProject task) {
task.getProjectModel().buildCommand("org.eclipse.wst.common.project.facet.core.builder");
task.getProjectModel().buildCommand("org.eclipse.wst.validation.validationbuilder");
task.getProjectModel().natures("org.eclipse.wst.common.project.facet.core.nature");
task.getProjectModel().natures("org.eclipse.wst.common.modulecore.ModuleCoreNature");
task.getProjectModel().natures("org.eclipse.jem.workbench.JavaEMFNature");
}
});
}
};
project.getPlugins().withType(JavaPlugin.class, action);
project.getPlugins().withType(EarPlugin.class, action);
}
示例4: apply
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
@Override public void apply(Project project) {
project.getPluginManager().apply(JavaPlugin.class);
project.getConfigurations().create("capsule").defaultDependencies(dependencySet -> {
dependencySet.add(project.getDependencies().create("co.paralleluniverse:capsule:1.0.3"));
});
project.getTasks().withType(Capsule.class).all(task -> task.executesInside(project));
Capsule capsuleTask = project.getTasks().create("capsule", Capsule.class);
capsuleTask.setGroup(BUILD_GROUP);
capsuleTask.setDescription("Assembles a jar archive containing Capsule, caplets, and necessary jars to run an application.");
Task assembleTask = project.getTasks().findByName("assemble");
assembleTask.dependsOn(capsuleTask);
Task jarTask = project.getTasks().findByName("jar");
capsuleTask.dependsOn(jarTask);
}
示例5: configureCompileTestJavaTask
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private void configureCompileTestJavaTask(final Project project) {
final JavaCompile compileTestJava = (JavaCompile) project.getTasks()
.findByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME);
final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
compileTestJava.getInputs().property("moduleName", module.geName());
compileTestJava.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
List<String> args = new ArrayList<>();
args.add("--module-path");
args.add(compileTestJava.getClasspath().getAsPath());
args.add("--add-modules");
args.add("junit");
args.add("--add-reads");
args.add(module.geName() + "=junit");
args.add("--patch-module");
args.add(module.geName() + "=" + test.getJava().getSourceDirectories().getAsPath());
compileTestJava.getOptions().setCompilerArgs(args);
compileTestJava.setClasspath(project.files());
}
});
}
示例6: configureTestTask
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private void configureTestTask(final Project project) {
final Test testTask = (Test) project.getTasks().findByName(JavaPlugin.TEST_TASK_NAME);
final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
testTask.getInputs().property("moduleName", module.geName());
testTask.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
List<String> args = new ArrayList<>();
args.add("--module-path");
args.add(testTask.getClasspath().getAsPath());
args.add("--add-modules");
args.add("ALL-MODULE-PATH");
args.add("--add-reads");
args.add(module.geName() + "=junit");
args.add("--patch-module");
args.add(module.geName() + "=" + test.getJava().getOutputDir());
testTask.setJvmArgs(args);
testTask.setClasspath(project.files());
}
});
}
示例7: checkTaskProperties
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
@Test
public void checkTaskProperties() throws IOException {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName());
testProjectDir.newFolder("src", "main", "java");
File outputDir = testProjectDir.getRoot();
Project project = ProjectBuilder.builder().withName("crnk-gen-typescript-test").withProjectDir(outputDir).build();
project.setVersion("0.0.1");
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(TSGeneratorPlugin.class);
TSGeneratorExtension extension = project.getExtensions().getByType(TSGeneratorExtension.class);
extension.getRuntime().setConfiguration(null);
TSGeneratorPlugin plugin = project.getPlugins().getPlugin(TSGeneratorPlugin.class);
plugin.init(project);
PublishTypescriptStubsTask task = (PublishTypescriptStubsTask) project.getTasks().getByName("publishTypescript");
Assert.assertEquals("publish", task.getGroup());
Assert.assertNotNull(task.getDescription());
Assert.assertFalse(task.getInputs().getFiles().isEmpty());
Assert.assertFalse(task.getOutputs().getFiles().isEmpty());
}
示例8: setup
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
@Before
public void setup() throws IOException {
// Deltaspike sometimes really wants to have a retarded JNDI context
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName());
testProjectDir.newFolder("src", "main", "java");
File outputDir = testProjectDir.getRoot();
Project project = ProjectBuilder.builder().withName("crnk-gen-typescript-test").withProjectDir(outputDir).build();
project.setVersion("0.0.1");
project.getPluginManager().apply("com.moowork.node");
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(TSGeneratorPlugin.class);
TSGeneratorExtension config = project.getExtensions().getByType(TSGeneratorExtension.class);
config.getRuntime().setConfiguration("test");
factory = new RuntimeClassLoaderFactory(project);
ClassLoader parentClassLoader = getClass().getClassLoader();
classLoader = factory.createClassLoader(parentClassLoader);
sharedClassLoader = (RuntimeClassLoaderFactory.SharedClassLoader) classLoader.getParent();
}
示例9: addStandardJavaTestDependencies
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private static void addStandardJavaTestDependencies(Project project) {
Configuration testConfiguration =
project.getPlugins().hasPlugin(JavaLibraryPlugin.class)
? project
.getConfigurations()
.getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME)
: project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
DependencyHandler dependencies = project.getDependencies();
dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305");
dependencies.add(testConfiguration.getName(), "org.curioswitch.curiostack:curio-testing-framework");
dependencies.add(testConfiguration.getName(), "org.assertj:assertj-core");
dependencies.add(testConfiguration.getName(), "org.awaitility:awaitility");
dependencies.add(testConfiguration.getName(), "junit:junit");
dependencies.add(testConfiguration.getName(), "org.mockito:mockito-core");
dependencies.add(testConfiguration.getName(), "info.solidsoft.mockito:mockito-java8");
}
示例10: apply
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getPlugins().apply(WarPlugin.class);
WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();
War war = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
war.getConvention().getPlugins().put("attachClasses", attachClassesConvention);
project.afterEvaluate(p -> {
if (attachClassesConvention.isAttachClasses()) {
Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
jar.setClassifier(attachClassesConvention.getClassesClassifier());
project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
}
});
}
示例11: initializeMavenConfig
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
/**
* Initialize the Maven configuration
*
* @param mavenConfig Maven configuration to initialize
* @param projectContext Project context
* @param configurations Configuration container
*/
@Defaults
public void initializeMavenConfig(MavenConfig mavenConfig, ProjectContext projectContext,
ConfigurationContainer configurations) {
mavenConfig.getPublications().create(SourceSet.MAIN_SOURCE_SET_NAME, p -> {
p.setArtifactId(projectContext.getName());
p.setArchivesConfiguration(Dependency.ARCHIVES_CONFIGURATION);
p.setAddProjectArtifacts(false);
p.setCompileConfigurations(Collections.singletonList(JavaPlugin.COMPILE_CONFIGURATION_NAME));
p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.RUNTIME_CONFIGURATION_NAME));
});
if (configurations.findByName("testArchives") != null) {
mavenConfig.getPublications().create(SourceSet.TEST_SOURCE_SET_NAME, p -> {
p.setArtifactId(projectContext.getName() + "-" + SourceSet.TEST_SOURCE_SET_NAME);
p.setArchivesConfiguration(Names.formatName("", Dependency.ARCHIVES_CONFIGURATION,
SourceSet.TEST_SOURCE_SET_NAME));
p.setAddProjectArtifacts(true);
p.setCompileConfigurations(
Collections.singletonList(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME));
p.setRuntimeConfigurations(
Collections.singletonList(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME));
});
}
}
示例12: setUpTestProject
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private Project setUpTestProject(String buildFileName) throws IOException {
Path buildFile = testProjectDir.getRoot().toPath().resolve("build.gradle");
InputStream buildFileContent =
getClass()
.getClassLoader()
.getResourceAsStream(
"projects/AppEnginePluginTest/Extension/" + buildFileName + ".gradle");
Files.copy(buildFileContent, buildFile);
Path webInf = testProjectDir.getRoot().toPath().resolve("src/main/webapp/WEB-INF");
Files.createDirectories(webInf);
File appengineWebXml = Files.createFile(webInf.resolve("appengine-web.xml")).toFile();
Files.write(appengineWebXml.toPath(), "<appengine-web-app/>".getBytes(Charsets.UTF_8));
Project p = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
p.getPluginManager().apply(JavaPlugin.class);
p.getPluginManager().apply(WarPlugin.class);
p.getPluginManager().apply(AppEngineStandardPlugin.class);
((ProjectInternal) p).evaluate();
return p;
}
示例13: testDefaultConfiguration
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
@Test
public void testDefaultConfiguration() throws IOException {
File appengineWebXml =
new File(testProjectDir.getRoot(), "src/main/webapp/WEB-INF/appengine-web.xml");
appengineWebXml.getParentFile().mkdirs();
appengineWebXml.createNewFile();
Files.write(appengineWebXml.toPath(), "<web-app/>".getBytes());
Project project = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(WarPlugin.class);
project.getPluginManager().apply(AppEngineStandardPlugin.class);
project.getPluginManager().apply(SourceContextPlugin.class);
((ProjectInternal) project).evaluate();
ExtensionAware ext =
(ExtensionAware) project.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
GenRepoInfoFileExtension genRepoInfoExt =
new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION);
Assert.assertEquals(
new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory());
}
示例14: addRepackageTask
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
private void addRepackageTask(Project project) {
RepackageTask task = project.getTasks().create(REPACKAGE_TASK_NAME,
RepackageTask.class);
task.setDescription("Repackage existing JAR and WAR "
+ "archives so that they can be executed from the command "
+ "line using 'java -jar'");
task.setGroup(BasePlugin.BUILD_GROUP);
Configuration runtimeConfiguration = project.getConfigurations()
.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
.getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
task.dependsOn(
project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
.getAllArtifacts().getBuildDependencies(),
runtimeProjectDependencyJarTasks);
registerOutput(project, task);
ensureTaskRunsOnAssembly(project, task);
ensureMainClassHasBeenFound(project, task);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:RepackagePluginFeatures.java
示例15: getArchiveTask
import org.gradle.api.plugins.JavaPlugin; //导入依赖的package包/类
/**
* Returns the most suitable Archive-Task for wrapping in the swarm jar - in the following order:
*
* 1. Custom-JAR-Task defined in SwarmExtension 'archiveTask'
* 2. WAR-Task
* 3. JAR-Task
*/
private Jar getArchiveTask(Project project) {
TaskCollection<Jar> existingArchiveTasks = project.getTasks().withType(Jar.class);
Jar customArchiveTask = project.getExtensions().getByType(SwarmExtension.class).getArchiveTask();
if (customArchiveTask != null) {
return existingArchiveTasks.getByName(customArchiveTask.getName());
} else if (existingArchiveTasks.findByName(WarPlugin.WAR_TASK_NAME) != null) {
return existingArchiveTasks.getByName(WarPlugin.WAR_TASK_NAME);
} else if (existingArchiveTasks.findByName(JavaPlugin.JAR_TASK_NAME) != null) {
return existingArchiveTasks.getByName(JavaPlugin.JAR_TASK_NAME);
}
return null;
}