Java Code Examples for org.gradle.api.tasks.bundling.Jar#from()
The following examples show how to use
org.gradle.api.tasks.bundling.Jar#from() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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())); }
Example 2
Source File: JavaPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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())); }
Example 3
Source File: JvmComponentPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Task createJarTask(TaskContainer tasks, JarBinarySpecInternal binary) { Jar jar = tasks.create(binary.getNamingScheme().getTaskName("create"), Jar.class); jar.setDescription(String.format("Creates the binary file for %s.", binary.getNamingScheme().getDescription())); jar.from(binary.getClassesDir()); jar.from(binary.getResourcesDir()); jar.setDestinationDir(binary.getJarFile().getParentFile()); jar.setArchiveName(binary.getJarFile().getName()); return jar; }
Example 4
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example 5
Source File: JvmComponentPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Task createJarTask(TaskContainer tasks, JarBinarySpecInternal binary) { Jar jar = tasks.create(binary.getNamingScheme().getTaskName("create"), Jar.class); jar.setDescription(String.format("Creates the binary file for %s.", binary.getNamingScheme().getDescription())); jar.from(binary.getClassesDir()); jar.from(binary.getResourcesDir()); jar.setDestinationDir(binary.getJarFile().getParentFile()); jar.setArchiveName(binary.getJarFile().getName()); return jar; }
Example 6
Source File: JavaPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example 7
Source File: PwtLibPlugin.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 4 votes |
private void includeSourcesToJar(Project project) { Jar jarTask = project.getTasks().withType(Jar.class).getByName("jar"); JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourset = javaConvention.getSourceSets().getByName("main"); jarTask.from(mainSourset.getAllSource()); }