org.gradle.api.internal.ConventionMapping Java Examples

The following examples show how to use org.gradle.api.internal.ConventionMapping. 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: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 7 votes vote down vote up
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #2
Source File: MavenPublishTaskModelRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class);
    generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
    generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    generatePomTask.setPom(publication.getPom());

    ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
    descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
        }
    });

    // Wire the generated pom into the publication.
    publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
 
Example #3
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void createCompileJavaTaskForBinary(final SourceSet sourceSet, SourceDirectorySet javaSourceSet, Project target) {
    JavaCompile compileTask = target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
    compileTask.setDescription("Compiles " + javaSourceSet + ".");
    compileTask.setSource(javaSourceSet);
    ConventionMapping conventionMapping = compileTask.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #4
Source File: LegacyJavaComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinarySpec binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
Example #5
Source File: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #6
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription("Compiles the " + sourceSet.getJava() + ".");
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #7
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #8
Source File: MavenPublishTaskModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class);
    generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
    generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    generatePomTask.setPom(publication.getPom());

    ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
    descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
        }
    });

    // Wire the generated pom into the publication.
    publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
 
Example #9
Source File: JavaLanguagePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinary binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
Example #10
Source File: OsgiPluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #11
Source File: OsgiPluginConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #12
Source File: OsgiPluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #13
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
Example #14
Source File: LegacyJavaComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinarySpec binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
Example #15
Source File: JavaLanguagePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinary binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
Example #16
Source File: MavenPublishPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
        public void execute(final GenerateMavenPom generatePomTask) {
            generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
            generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            generatePomTask.setPom(publication.getPom());

            ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
            descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
                }
            });

            // Wire the generated pom into the publication.
            publication.setPomFile(generatePomTask.getOutputs().getFiles());
        }
    });
}
 
Example #17
Source File: OsgiPluginConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #18
Source File: MavenPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
        public void execute(final GenerateMavenPom generatePomTask) {
            generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
            generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            generatePomTask.setPom(publication.getPom());

            ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
            descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
                }
            });

            // Wire the generated pom into the publication.
            publication.setPomFile(generatePomTask.getOutputs().getFiles());
        }
    });
}
 
Example #19
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #20
Source File: JGivenPlugin.java    From JGiven with Apache License 2.0 5 votes vote down vote up
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask,
        final ReportingExtension reportingExtension ){
    ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping();
    mapping.map( "results", (Callable<File>) () -> test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir() );
    mapping.getConventionValue( reportTask.getReports(), "reports", false )
            .all( (Action<Report>) report -> {
                ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping();
                reportMapping.map( "destination",
                        (Callable<File>) () -> reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() ) );
            } );
}
 
Example #21
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example #22
Source File: LegacyJavaComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setClassesDirConvention(ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    ConventionMapping conventionMapping = new DslObject(binary).getConventionMapping();
    conventionMapping.map("classesDir", new Callable<File>() {
        public File call() throws Exception {
            return new File(new File(target.getBuildDir(), "classes"), namingScheme.getOutputDirectoryBase());
        }
    });
}
 
Example #23
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #24
Source File: IvyPublicationTasksModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example #25
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureArchiveDefaults(final Project project, final BasePluginConvention pluginConvention) {
    project.getTasks().withType(AbstractArchiveTask.class, new Action<AbstractArchiveTask>() {
        public void execute(AbstractArchiveTask task) {
            ConventionMapping taskConventionMapping = task.getConventionMapping();

            Callable<File> destinationDir;
            if (task instanceof Jar) {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getLibsDir();
                    }
                };
            } else {
                destinationDir = new Callable<File>() {
                    public File call() throws Exception {
                        return pluginConvention.getDistsDir();
                    }
                };
            }
            taskConventionMapping.map("destinationDir", destinationDir);

            taskConventionMapping.map("version", new Callable<String>() {
                public String call() throws Exception {
                    return project.getVersion() == Project.DEFAULT_VERSION ? null : project.getVersion().toString();
                }
            });

            taskConventionMapping.map("baseName", new Callable<String>() {
                public String call() throws Exception {
                    return pluginConvention.getArchivesBaseName();
                }
            });
        }
    });
}
 
Example #26
Source File: CpdPlugin.java    From gradle-cpd-plugin with Apache License 2.0 5 votes vote down vote up
/** Set up task defaults for every created {@link Cpd} task. */
private void setupTaskDefaults(Project project, CpdExtension extension) {
    project.getTasks().withType(Cpd.class).configureEach(task -> {
        ConventionMapping taskMapping = task.getConventionMapping();
        taskMapping.map("encoding", extension::getEncoding);
        taskMapping.map("ignoreAnnotations", extension::isIgnoreAnnotations);
        taskMapping.map("ignoreIdentifiers", extension::isIgnoreIdentifiers);
        taskMapping.map("ignoreFailures", extension::isIgnoreFailures);
        taskMapping.map("ignoreLiterals", extension::isIgnoreLiterals);
        taskMapping.map("language", extension::getLanguage);
        taskMapping.map("minimumTokenCount", extension::getMinimumTokenCount);
        taskMapping.map("pmdClasspath", () -> project.getConfigurations().findByName("cpd"));
        taskMapping.map("skipDuplicateFiles", extension::isSkipDuplicateFiles);
        taskMapping.map("skipLexicalErrors", extension::isSkipLexicalErrors);
        taskMapping.map("skipBlocks", extension::isSkipBlocks);
        taskMapping.map("skipBlocksPattern", extension::getSkipBlocksPattern);

        ConventionMapping extensionMapping = ((IConventionAware) extension).getConventionMapping();
        extensionMapping.map("reportsDir", () -> project.getExtensions().getByType(ReportingExtension.class).file("cpd"));

        task.getReports().all(report -> {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            reportMapping.map("enabled", () -> "xml".equals(report.getName()));
            reportMapping.map("destination", () -> new File(extension.getReportsDir(), task.getName() + "." + report.getName()));
        });
    });
}
 
Example #27
Source File: GwtCompileTask.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void configure(final Project project, final PutnamiExtension extention) {
	final CompilerOption options = extention.getCompile();
	options.init(project);
	options.setLocalWorkers(evalWorkers(options));

	final ConfigurableFileCollection sources = project.files();
	addSourceSet(sources, project, SourceSet.MAIN_SOURCE_SET_NAME);

	final Configuration compileClasspath = project.getConfigurations().getByName(
		JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
	compileClasspath.getDependencies().withType(ProjectDependency.class, new Action<ProjectDependency>() {
		@Override
		public void execute(ProjectDependency dep) {
			addSourceSet(sources, dep.getDependencyProject(), SourceSet.MAIN_SOURCE_SET_NAME);
		}
	});

	ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

	mapping.map("modules", new Callable<List<String>>() {
		@Override
		public List<String> call()  {
			return extention.getModule();
		}
	});
	mapping.map("war", new Callable<File>() {
		@Override
		public File call()  {
			return options.getWar();
		}
	});
	mapping.map("src", new Callable<FileCollection>() {
		@Override
		public FileCollection call()  {
			return sources;
		}
	});
}
 
Example #28
Source File: GwtSetUpTask.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void configure(final PutnamiExtension extension) {
	ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

	mapping.map("modules", new Callable<List<String>>() {
		@Override
		public List<String> call()  {
			return extension.getModule();
		}
	});
}
 
Example #29
Source File: GwtDevTask.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void configureCodeServer(final Project project, final PutnamiExtension extention) {
	final DevOption options = extention.getDev();
	options.init(project);

	ConventionMapping convention = ((IConventionAware) this).getConventionMapping();
	convention.map("modules", new Callable<List<String>>() {
		@Override
		public List<String> call()  {
			return extention.getModule();
		}
	});
}
 
Example #30
Source File: GwtCheckTask.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void configure(final Project project, final PutnamiExtension extention) {
	final CompilerOption options = extention.getCompile();

	options.init(getProject());

	JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
	SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
	final FileCollection sources = getProject()
		.files(project.files(mainSourceSet.getOutput().getResourcesDir()))
		.plus(project.files(mainSourceSet.getOutput().getClassesDirs()))
		.plus(getProject().files(mainSourceSet.getAllSource().getSrcDirs()));

	ConventionMapping mapping = ((IConventionAware) this).getConventionMapping();

	mapping.map("modules", new Callable<List<String>>() {
		@Override
		public List<String> call() {
			return extention.getModule();
		}
	});
	mapping.map("war", new Callable<File>() {
		@Override
		public File call()  {
			return new File(getProject().getBuildDir(), "out");
		}
	});
	mapping.map("src", new Callable<FileCollection>() {
		@Override
		public FileCollection call()  {
			return sources;
		}
	});
}