org.gradle.api.internal.IConventionAware Java Examples

The following examples show how to use org.gradle.api.internal.IConventionAware. 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: 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 #2
Source File: JGivenPlugin.java    From JGiven with Apache License 2.0 6 votes vote down vote up
private void applyTo( Test test ){
    final String testName = test.getName();
    final JGivenTaskExtension extension = test.getExtensions().create( "jgiven", JGivenTaskExtension.class );
    final Project project = test.getProject();
    ( (IConventionAware) extension ).getConventionMapping().map( "resultsDir",
            (Callable<File>) () -> project.file( project.getBuildDir() + "/jgiven-results/" + testName ) );

    File resultsDir = extension.getResultsDir();
    if( resultsDir != null ) {
        test.getOutputs().dir( resultsDir ).withPropertyName( "jgiven.resultsDir" );
    }

    // Java lambda classes are created at runtime with a non-deterministic classname.
    // Therefore, the class name does not identify the implementation of the lambda and changes between different Gradle runs.
    // https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:how_does_it_work
    test.prependParallelSafeAction( new Action<Task>() {
        @Override
        public void execute( Task task ){
            ((Test) task).systemProperty( Config.JGIVEN_REPORT_DIR, extension.getResultsDir().getAbsolutePath() );
        }
    } );
}
 
Example #3
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 #4
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 #5
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 #6
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;
		}
	});
}
 
Example #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList();
    pluginConvention.getSourceSets().all(new Action<SourceSet>() {
        public void execute(final SourceSet sourceSet) {
            ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

            ConfigurationContainer configurations = project.getConfigurations();

            defineConfigurationsForSourceSet(sourceSet, configurations);
            definePathsForSourceSet(sourceSet, outputConventionMapping, project);

            createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project);
            createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project);
            createBinaryLifecycleTask(sourceSet, project);

            DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName());
            ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory);

            Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
            DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath);
            JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources());

            binary.addSourceSet(javaSourceSet);
            binary.addSourceSet(resourceSet);

            attachTasksToBinary(binary, sourceSet, project);
            binaries.add(binary);
        }
    });
    return new BridgedBinaries(binaries);
}
 
Example #13
Source File: JGivenPlugin.java    From JGiven with Apache License 2.0 4 votes vote down vote up
private void configureJGivenReportDefaults( Project project ){
    project.getTasks().withType( JGivenReportTask.class, reportTask -> reportTask.getReports().all( (Action<Report>) report -> {
        ConventionMapping mapping = ( (IConventionAware) report ).getConventionMapping();
        mapping.map( "enabled", (Callable<Boolean>) () -> report.getName().equals( JGivenHtmlReportImpl.NAME ) );
    } ) );
}
 
Example #14
Source File: ConventionValue.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);
 
Example #15
Source File: ConventionValue.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);
 
Example #16
Source File: ConventionValue.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);
 
Example #17
Source File: ConventionValue.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns some object.
 *
 * @param convention The convention object belonging to the task's project
 * @param conventionAwareObject The convention aware object
 */
Object getValue(Convention convention, IConventionAware conventionAwareObject);