本文整理汇总了Java中org.gradle.api.tasks.bundling.Jar类的典型用法代码示例。如果您正苦于以下问题:Java Jar类的具体用法?Java Jar怎么用?Java Jar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Jar类属于org.gradle.api.tasks.bundling包,在下文中一共展示了Jar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的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: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
@Override
public void apply(final ProjectInternal project) {
this.project = project;
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(DistributionPlugin.class);
DefaultDistributionContainer defaultDistributionContainer =
(DefaultDistributionContainer) project.getExtensions().findByName("distributions");
CopySpec contentSpec = defaultDistributionContainer.getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME).getContents();
Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
CopySpec childSpec = project.copySpec();
childSpec.from(jar);
childSpec.from(project.file("src/dist"));
CopySpec libSpec = project.copySpec();
libSpec.into("lib");
libSpec.from(project.getConfigurations().getByName("runtime"));
childSpec.with(libSpec);
contentSpec.with(childSpec);
}
示例3: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的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);
}
});
}
示例4: initialize
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
/**
* @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize()
*/
@Override
protected void initialize() {
getProject().getPluginManager().apply(GroovyPlugin.class);
getProject().getPluginManager().apply(JavaConfigPlugin.class);
DependencyHandler dependencies = getProject().getDependencies();
ExternalDependency spock = (ExternalDependency) dependencies.add("testCompile",
ImmutableMap.of("group", "org.spockframework", "name", "spock-core", "version", "1.0-groovy-2.4"));
spock.exclude(ImmutableMap.of("group", "org.codehaus.groovy", "module", "groovy-all"));
String name = Validate.notNull(getProject().getName());
Configuration archives = getProject().getConfigurations().getByName("archives");
Jar groovydocJar = getProject().getTasks().create("groovydocJar", Jar.class);
PublishArtifact groovydocArtifact = Projects.createJarPublishArtifact(getProject(), name, "groovydoc", "jar",
"jar", groovydocJar);
archives.getArtifacts().add(groovydocArtifact);
}
示例5: execute
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
@Override
public void execute(Jar jarTask) {
if (!RepackageTask.this.isEnabled()) {
getLogger().info("Repackage disabled");
return;
}
Object withJarTask = RepackageTask.this.withJarTask;
if (!isTaskMatch(jarTask, withJarTask)) {
getLogger().info(
"Jar task not repackaged (didn't match withJarTask): " + jarTask);
return;
}
File file = jarTask.getArchivePath();
if (file.exists()) {
repackage(file);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:RepackageTask.java
示例6: isTaskMatch
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
private boolean isTaskMatch(Jar task, Object withJarTask) {
if (withJarTask == null) {
if ("".equals(task.getClassifier())) {
Set<Object> tasksWithCustomRepackaging = new HashSet<Object>();
for (RepackageTask repackageTask : RepackageTask.this.getProject()
.getTasks().withType(RepackageTask.class)) {
if (repackageTask.getWithJarTask() != null) {
tasksWithCustomRepackaging
.add(repackageTask.getWithJarTask());
}
}
return !tasksWithCustomRepackaging.contains(task);
}
return false;
}
return task.equals(withJarTask) || task.getName().equals(withJarTask);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:RepackageTask.java
示例7: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getExtensions().create(SWARM_EXTENSION, SwarmExtension.class, project);
project.afterEvaluate(__ -> {
final TaskContainer tasks = project.getTasks();
final PackageTask packageTask = tasks.create(WILDFLY_SWARM_PACKAGE_TASK_NAME, PackageTask.class);
final Jar archiveTask = getArchiveTask(project);
if (archiveTask == null) {
throw new GradleException("No suitable Archive-Task found to include in Swarm Uber-JAR.");
}
packageTask.jarTask(archiveTask).dependsOn(archiveTask);
tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(packageTask);
});
}
示例8: getArchiveTask
import org.gradle.api.tasks.bundling.Jar; //导入依赖的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;
}
示例9: configureArchivesAndComponent
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) {
Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
jar.getManifest().from(pluginConvention.getManifest());
jar.setDescription("Assembles a jar archive containing the main classes.");
jar.setGroup(BasePlugin.BUILD_GROUP);
jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
jar.getMetaInf().from(new Callable() {
public Object call() throws Exception {
return pluginConvention.getMetaInf();
}
});
ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);
runtimeConfiguration.getArtifacts().add(jarArtifact);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));
}
示例10: inheritManifest
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
/**
* Make the given Jar task inherit its manifest from the "main" "thin" Jar task. Also set the build timestamp.
*
* @param pTask the executing task
* @param pDepConfig the dependency configuration for which the Jar task is intended
*/
public void inheritManifest(@Nonnull final Jar pTask, @Nonnull final DependencyConfig pDepConfig)
{
pTask.doFirst(new Closure<Void>(pTask)
{
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public Void call()
{
final Jar jarTask = (Jar) getTask(TaskNames.jar, pDepConfig);
pTask.setManifest(jarTask.getManifest());
addBuildTimestamp(pTask.getManifest().getAttributes());
return null;
}
});
}
示例11: configureJarTask
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
private void configureJarTask(Project project, GradlePluginDevelopmentExtension extension) {
Jar jarTask = (Jar) project.getTasks().findByName(JAR_TASK);
List<PluginDescriptor> descriptors = new ArrayList<PluginDescriptor>();
Set<String> classList = new HashSet<String>();
PluginDescriptorCollectorAction pluginDescriptorCollector = new PluginDescriptorCollectorAction(descriptors);
ClassManifestCollectorAction classManifestCollector = new ClassManifestCollectorAction(classList);
PluginValidationAction pluginValidationAction = new PluginValidationAction(extension.getPlugins(), descriptors, classList);
jarTask.filesMatching(PLUGIN_DESCRIPTOR_PATTERN, pluginDescriptorCollector);
jarTask.filesMatching(CLASSES_PATTERN, classManifestCollector);
jarTask.appendParallelSafeAction(pluginValidationAction);
}
示例12: configureArchivesAndComponent
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) {
Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class);
jar.setDescription("Assembles a jar archive containing the main classes.");
jar.setGroup(BasePlugin.BUILD_GROUP);
jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar);
Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME);
runtimeConfiguration.getArtifacts().add(jarArtifact);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact);
project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies()));
}
示例13: defaultAttributesUsingDetailsFrom
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
/**
* Resolve default values to be used in manifest.
*
* @param project Context the default values should be resolved from.
*/
private void defaultAttributesUsingDetailsFrom(Project project) {
Object projectGroup = project.getGroup();
String projectName = project.getName();
if (projectGroup != null) {
capsuleManifest.defaultApplicationIdTo(projectGroup + "." + projectName);
}
Jar jarTask = (Jar) project.getTasks().getAt("jar");
capsuleManifest.defaultApplicationClassTo((String) jarTask.getManifest().getAttributes().get("Main-Class"));
}
示例14: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
@Override
public void apply(Project project) {
this.project = project;
jarTask = project.getTasks().create(getTaskName(), Jar.class);
jarTask.setClassifier(getClassifier());
jarTask.setGroup(BasePlugin.BUILD_GROUP);
project.getPluginManager().apply(BasePlugin.class);
project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, getJarTask());
}
示例15: apply
import org.gradle.api.tasks.bundling.Jar; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getTasks().withType(War.class, war -> {
WarArchiveClassesConvention archiveClassesConvention = new WarArchiveClassesConvention();
war.getConvention().getPlugins().put("archiveClasses", archiveClassesConvention);
Jar warClassesJar = project.getTasks().create(war.getName() + "ClassesJar", Jar.class);
warClassesJar.getConventionMapping().map("baseName", war::getBaseName);
warClassesJar.getConventionMapping().map("appendix", war::getAppendix);
warClassesJar.getConventionMapping().map("version", war::getVersion);
warClassesJar.getConventionMapping().map("classifier", war::getClassifier);
project.afterEvaluate(p -> {
warClassesJar.setEnabled(archiveClassesConvention.isArchiveClasses());
if (archiveClassesConvention.isArchiveClasses()) {
FileCollection warClasspath = war.getClasspath();
warClassesJar.from(warClasspath != null ? warClasspath.filter(File::isDirectory) : Collections.emptyList());
war.setClasspath(warClasspath == null ? null : warClasspath.filter(File::isFile).plus(project.files(warClassesJar)));
}
});
});
}