Package org.gradle.api.internal

Examples of org.gradle.api.internal.ConventionMapping$MappedProperty


     */
    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();
            }
        });
    }
View Full Code Here


        final Project project = pluginConvention.getProject();
        final ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);

        pluginConvention.getSourceSets().all(new Action<SourceSet>() {
            public void execute(final SourceSet sourceSet) {
                ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

                ConfigurationContainer configurations = project.getConfigurations();

                Configuration compileConfiguration = configurations.findByName(sourceSet.getCompileConfigurationName());
                if (compileConfiguration == null) {
                    compileConfiguration = configurations.create(sourceSet.getCompileConfigurationName());
                }
                compileConfiguration.setVisible(false);
                compileConfiguration.setDescription(String.format("Compile classpath for %s.", sourceSet));

                Configuration runtimeConfiguration = configurations.findByName(sourceSet.getRuntimeConfigurationName());
                if (runtimeConfiguration == null) {
                    runtimeConfiguration = configurations.create(sourceSet.getRuntimeConfigurationName());
                }
                runtimeConfiguration.setVisible(false);
                runtimeConfiguration.extendsFrom(compileConfiguration);
                runtimeConfiguration.setDescription(String.format("Runtime classpath for %s.", sourceSet));

                sourceSet.setCompileClasspath(compileConfiguration);
                sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration));

                outputConventionMapping.map("classesDir", new Callable<Object>() {
                    public Object call() throws Exception {
                        String classesDirName = String.format("classes/%s", sourceSet.getName());
                        return new File(project.getBuildDir(), classesDirName);
                    }
                });
                outputConventionMapping.map("resourcesDir", new Callable<Object>() {
                    public Object call() throws Exception {
                        String classesDirName = String.format("resources/%s", sourceSet.getName());
                        return new File(project.getBuildDir(), classesDirName);
                    }
                });

                sourceSet.getJava().srcDir(String.format("src/%s/java", sourceSet.getName()));
                sourceSet.getResources().srcDir(String.format("src/%s/resources", sourceSet.getName()));
                sourceSet.compiledBy(sourceSet.getClassesTaskName());

                FunctionalSourceSet functionalSourceSet = projectSourceSet.create(sourceSet.getName());
                Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
                DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, "java", sourceSet.getJava(), compileClasspath, functionalSourceSet);
                functionalSourceSet.add(javaSourceSet);
                JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, "resources", sourceSet.getResources(), functionalSourceSet);
                functionalSourceSet.add(resourceSet);

                BinaryContainer binaryContainer = project.getExtensions().getByType(BinaryContainer.class);
                ClassDirectoryBinarySpec binary = binaryContainer.create(String.format("%sClasses", sourceSet.getName()), ClassDirectoryBinarySpec.class);
                ConventionMapping conventionMapping = new DslObject(binary).getConventionMapping();
                conventionMapping.map("classesDir", new Callable<File>() {
                    public File call() throws Exception {
                        return sourceSet.getOutput().getClassesDir();
                    }
                });
                conventionMapping.map("resourcesDir", new Callable<File>() {
                    public File call() throws Exception {
                        return sourceSet.getOutput().getResourcesDir();
                    }
                });
View Full Code Here

            }
        });
    }

    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();
            }
        });
    }
View Full Code Here

    }

    private void configureCompileDefaults(final Project project, final JavaPluginConvention javaConvention) {
        project.getTasks().withType(AbstractCompile.class, new Action<AbstractCompile>() {
            public void execute(final AbstractCompile compile) {
                ConventionMapping conventionMapping = compile.getConventionMapping();
                conventionMapping.map("sourceCompatibility", new Callable<Object>() {
                    public Object call() throws Exception {
                        return javaConvention.getSourceCompatibility().toString();
                    }
                });
                conventionMapping.map("targetCompatibility", new Callable<Object>() {
                    public Object call() throws Exception {
                        return javaConvention.getTargetCompatibility().toString();
                    }
                });
            }
        });
        project.getTasks().withType(JavaCompile.class, new Action<JavaCompile>() {
            public void execute(final JavaCompile compile) {
                ConventionMapping conventionMapping = compile.getConventionMapping();
                conventionMapping.map("dependencyCacheDir", new Callable<Object>() {
                    public Object call() throws Exception {
                        return javaConvention.getDependencyCacheDir();
                    }
                });
            }
View Full Code Here

    }

    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();
                    }
                });
            }
View Full Code Here

TOP

Related Classes of org.gradle.api.internal.ConventionMapping$MappedProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.