Java 类org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact 实例源码

项目:Pushjet-Android    文件:JavaPlugin.java   
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()));
}
项目:Reer    文件:EarPlugin.java   
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);
                }
            });
        }
    });
}
项目:Reer    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTypeIdentifier(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
        AbstractArchiveTask task = publishArtifact.getArchiveTask();

        // There is an inheritance hierarchy in play here, so the order
        // of the clauses is very important.

        if (task instanceof War) {
            return WAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Ear) {
            return EAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Jar) {
            return JAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Zip) {
            return ZIP_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Tar) {
            return TAR_ARTIFACT.getTypeIdentifier();
        } else {
            // we don't know about this kind of archive task
            return ARCHIVE_ARTIFACT.getTypeIdentifier();
        }
    } else {
        // This could very well be a zip (or something else we understand), but we can't know for sure.
        // The client may try to infer from the file extension.
        return UNKNOWN_ARTIFACT.getTypeIdentifier();
    }
}
项目:Reer    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTaskPath(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        return ((ArchivePublishArtifact) artifact).getArchiveTask().getPath();
    } else {
        String taskPath = null;
        Set<? extends Task> tasks = artifact.getBuildDependencies().getDependencies(null);
        if (!tasks.isEmpty()) {
            taskPath = tasks.iterator().next().getPath();
        }
        return taskPath;
    }
}
项目:Reer    文件:DistributionPlugin.java   
private <T extends AbstractArchiveTask> Task configureArchiveTask(Project project, String taskName, final Distribution distribution, Class<T> type) {
    final T archiveTask = project.getTasks().create(taskName, type);
    archiveTask.setDescription("Bundles the project as a distribution.");
    archiveTask.setGroup(DISTRIBUTION_GROUP);
    archiveTask.getConventionMapping().map("baseName", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (distribution.getBaseName() == null || distribution.getBaseName().equals("")) {
                throw new GradleException("Distribution baseName must not be null or empty! Check your configuration of the distribution plugin.");
            }
            return distribution.getBaseName();
        }
    });

    Callable<String> baseDir = new Callable<String>() {
        @Override
        public String call() throws Exception {
            // For backwards compatibility, we need to simulate the exact behaviour of the previously uses Groovy minus operator
            String toBeRenamedIfExists = "." + archiveTask.getExtension();
            return archiveTask.getArchiveName().replaceFirst(toBeRenamedIfExists, "");
        }
    };

    CopySpec childSpec = project.copySpec();
    childSpec.into(baseDir);
    childSpec.with(distribution.getContents());
    archiveTask.with(childSpec);
    ArchivePublishArtifact archiveArtifact = new ArchivePublishArtifact(archiveTask);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(archiveArtifact);
    return archiveTask;
}
项目:Reer    文件:JavaPlugin.java   
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()));
}
项目:Reer    文件:WarPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().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);
}
项目:atlas    文件:AndroidComponetCreator.java   
public void createAndroidComponent(Zip bundleTask) {
    //Add a components. Android
    if (atlasExtension.getBundleConfig().isAwbBundle()) {
        Configuration compileConfiguration = project.getConfigurations()
            .getByName(COMPILE_CONFIGURATION_NAME);
        ArchivePublishArtifact bundleArtifact = new ArchivePublishArtifact(bundleTask);
        compileConfiguration.getArtifacts().add(bundleArtifact);
    }
}
项目:Pushjet-Android    文件:EarPlugin.java   
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);
                }
            });
        }
    });
}
项目:Pushjet-Android    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTypeIdentifier(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
        AbstractArchiveTask task = publishArtifact.getArchiveTask();

        // There is an inheritance hierarchy in play here, so the order
        // of the clauses is very important.

        if (task instanceof War) {
            return WAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Ear) {
            return EAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Jar) {
            return JAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Zip) {
            return ZIP_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Tar) {
            return TAR_ARTIFACT.getTypeIdentifier();
        } else {
            // we don't know about this kind of archive task
            return ARCHIVE_ARTIFACT.getTypeIdentifier();
        }
    } else {
        // This could very well be a zip (or something else we understand), but we can't know for sure.
        // The client may try to infer from the file extension.
        return UNKNOWN_ARTIFACT.getTypeIdentifier();
    }
}
项目:Pushjet-Android    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTaskPath(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        return ((ArchivePublishArtifact) artifact).getArchiveTask().getPath();
    } else {
        String taskPath = null;
        Set<? extends Task> tasks = artifact.getBuildDependencies().getDependencies(null);
        if (!tasks.isEmpty()) {
            taskPath = tasks.iterator().next().getPath();
        }
        return taskPath;
    }
}
项目:Pushjet-Android    文件:JavaPlugin.java   
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()));
}
项目:Pushjet-Android    文件:WarPlugin.java   
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);
}
项目:Pushjet-Android    文件:EarPlugin.java   
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);
                }
            });
        }
    });
}
项目:Pushjet-Android    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTypeIdentifier(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
        AbstractArchiveTask task = publishArtifact.getArchiveTask();

        // There is an inheritance hierarchy in play here, so the order
        // of the clauses is very important.

        if (task instanceof War) {
            return WAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Ear) {
            return EAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Jar) {
            return JAR_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Zip) {
            return ZIP_ARTIFACT.getTypeIdentifier();
        } else if (task instanceof Tar) {
            return TAR_ARTIFACT.getTypeIdentifier();
        } else {
            // we don't know about this kind of archive task
            return ARCHIVE_ARTIFACT.getTypeIdentifier();
        }
    } else {
        // This could very well be a zip (or something else we understand), but we can't know for sure.
        // The client may try to infer from the file extension.
        return UNKNOWN_ARTIFACT.getTypeIdentifier();
    }
}
项目:Pushjet-Android    文件:PublishArtifactToFileBuildOutcomeTransformer.java   
private String getTaskPath(PublishArtifact artifact) {
    if (artifact instanceof ArchivePublishArtifact) {
        return ((ArchivePublishArtifact) artifact).getArchiveTask().getPath();
    } else {
        String taskPath = null;
        Set<? extends Task> tasks = artifact.getBuildDependencies().getDependencies(null);
        if (!tasks.isEmpty()) {
            taskPath = tasks.iterator().next().getPath();
        }
        return taskPath;
    }
}
项目:Pushjet-Android    文件:WarPlugin.java   
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);
}
项目:nw-gradle    文件:NWEarPlugin.java   
/**
 * Setup the NW EAR Task.
 * Uses some magic to set up the default archive conventions, using the same name as the task (nwear).
 * For example nwear.archiveName = ''
 */
private NWEar setupEarTask(final Project project, NWEarPluginConvention convention) {
  NWEar ear = project.getTasks().create(NWEAR_TASK_NAME, NWEar.class);
  ear.setDescription(NWEAR_TASK_DESC);
  ear.setGroup(PLUGIN_GROUP);
  project.getExtensions()
  .getByType(DefaultArtifactPublicationSet.class)
  .addCandidate(new ArchivePublishArtifact(ear));
  return ear;
}
项目:Reer    文件:PublishArtifactNotationParserFactory.java   
@Override
protected ConfigurablePublishArtifact parseType(AbstractArchiveTask notation) {
    return instantiator.newInstance(ArchivePublishArtifact.class, notation);
}
项目:Pushjet-Android    文件:PublishArtifactNotationParserFactory.java   
@Override
protected PublishArtifact parseType(AbstractArchiveTask notation) {
    return instantiator.newInstance(ArchivePublishArtifact.class, notation);
}
项目:Pushjet-Android    文件:PublishArtifactNotationParserFactory.java   
@Override
protected PublishArtifact parseType(AbstractArchiveTask notation) {
    return instantiator.newInstance(ArchivePublishArtifact.class, notation);
}