org.gradle.api.internal.plugins.DefaultArtifactPublicationSet Java Examples

The following examples show how to use org.gradle.api.internal.plugins.DefaultArtifactPublicationSet. 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: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example #2
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example #3
Source File: JavaPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: JavaPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example #6
Source File: BasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example #7
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example #8
Source File: WarPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(JavaPlugin.class);
    final WarPluginConvention pluginConvention = new WarPluginConvention(project);
    project.getConvention().getPlugins().put("war", pluginConvention);

    project.getTasks().withType(War.class, new Action<War>() {
        public void execute(War task) {
            task.from(new Callable() {
                public Object call() throws Exception {
                    return pluginConvention.getWebAppDir();
                }
            });
            task.dependsOn(new Callable() {
                public Object call() throws Exception {
                    return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(
                            SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                }
            });
            task.classpath(new Object[] {new Callable() {
                public Object call() throws Exception {
                    FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class)
                            .getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                    Configuration providedRuntime = project.getConfigurations().getByName(
                            PROVIDED_RUNTIME_CONFIGURATION_NAME);
                    return runtimeClasspath.minus(providedRuntime);
                }
            }});
        }
    });
    
    War war = project.getTasks().create(WAR_TASK_NAME, War.class);
    war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
    war.setGroup(BasePlugin.BUILD_GROUP);
    ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
    configureConfigurations(project.getConfigurations());
    configureComponent(project, warArtifact);
}
 
Example #9
Source File: EarPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example #10
Source File: EarPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example #11
Source File: WarPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(JavaPlugin.class);
    final WarPluginConvention pluginConvention = new WarPluginConvention(project);
    project.getConvention().getPlugins().put("war", pluginConvention);

    project.getTasks().withType(War.class, new Action<War>() {
        public void execute(War task) {
            task.from(new Callable() {
                public Object call() throws Exception {
                    return pluginConvention.getWebAppDir();
                }
            });
            task.dependsOn(new Callable() {
                public Object call() throws Exception {
                    return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(
                            SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                }
            });
            task.classpath(new Object[] {new Callable() {
                public Object call() throws Exception {
                    FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class)
                            .getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                    Configuration providedRuntime = project.getConfigurations().getByName(
                            PROVIDED_RUNTIME_CONFIGURATION_NAME);
                    return runtimeClasspath.minus(providedRuntime);
                }
            }});
        }
    });
    
    War war = project.getTasks().create(WAR_TASK_NAME, War.class);
    war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
    war.setGroup(BasePlugin.BUILD_GROUP);
    ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
    configureConfigurations(project.getConfigurations());
    configureComponent(project, warArtifact);
}
 
Example #12
Source File: JavaPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #13
Source File: EarPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example #14
Source File: WarPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(JavaPlugin.class);
    final WarPluginConvention pluginConvention = new WarPluginConvention(project);
    project.getConvention().getPlugins().put("war", pluginConvention);

    project.getTasks().withType(War.class, new Action<War>() {
        public void execute(War task) {
            task.from(new Callable() {
                public Object call() throws Exception {
                    return pluginConvention.getWebAppDir();
                }
            });
            task.dependsOn(new Callable() {
                public Object call() throws Exception {
                    return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(
                            SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                }
            });
            task.classpath(new Object[] {new Callable() {
                public Object call() throws Exception {
                    FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class)
                            .getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                    Configuration providedRuntime = project.getConfigurations().getByName(
                            PROVIDED_RUNTIME_CONFIGURATION_NAME);
                    return runtimeClasspath.minus(providedRuntime);
                }
            }});
        }
    });
    
    War war = project.getTasks().create(WAR_TASK_NAME, War.class);
    war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
    war.setGroup(BasePlugin.BUILD_GROUP);
    ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
    configureConfigurations(project.getConfigurations());
    configureComponent(project, warArtifact);
}
 
Example #15
Source File: EarPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example #16
Source File: WarPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(JavaPlugin.class);
    final WarPluginConvention pluginConvention = new WarPluginConvention(project);
    project.getConvention().getPlugins().put("war", pluginConvention);

    project.getTasks().withType(War.class, new Action<War>() {
        public void execute(War task) {
            task.from(new Callable() {
                public Object call() throws Exception {
                    return pluginConvention.getWebAppDir();
                }
            });
            task.dependsOn(new Callable() {
                public Object call() throws Exception {
                    return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(
                            SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                }
            });
            task.classpath(new Object[] {new Callable() {
                public Object call() throws Exception {
                    FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class)
                            .getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
                    Configuration providedRuntime = project.getConfigurations().getByName(
                            PROVIDED_RUNTIME_CONFIGURATION_NAME);
                    return runtimeClasspath.minus(providedRuntime);
                }
            }});
        }
    });
    
    War war = project.getTasks().create(WAR_TASK_NAME, War.class);
    war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
    war.setGroup(BasePlugin.BUILD_GROUP);
    ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
    configureConfigurations(project.getConfigurations());
    configureComponent(project, warArtifact);
}
 
Example #17
Source File: JavaPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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()));
}