当前位置: 首页>>代码示例>>Java>>正文


Java SourceSet类代码示例

本文整理汇总了Java中org.gradle.api.tasks.SourceSet的典型用法代码示例。如果您正苦于以下问题:Java SourceSet类的具体用法?Java SourceSet怎么用?Java SourceSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SourceSet类属于org.gradle.api.tasks包,在下文中一共展示了SourceSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureForSourceSet

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
@Override
protected void configureForSourceSet(final SourceSet sourceSet, FindBugs task) {
    task.setDescription("Run FindBugs analysis for " + sourceSet.getName() + " classes");
    task.setSource(sourceSet.getAllJava());
    ConventionMapping taskMapping = task.getConventionMapping();
    taskMapping.map("classes", new Callable<FileCollection>() {
        @Override
        public FileCollection call() {
            // the simple "classes = sourceSet.output" may lead to non-existing resources directory
            // being passed to FindBugs Ant task, resulting in an error
            return project.fileTree(sourceSet.getOutput().getClassesDir()).builtBy(sourceSet.getOutput());
        }
    });
    taskMapping.map("classpath", new Callable<FileCollection>() {
        @Override
        public FileCollection call() {
            return sourceSet.getCompileClasspath();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:FindBugsPlugin.java

示例2: getExternalSourceFolders

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
/**
 * see {@link #getRegularSourceFolders}
 *
 * @return source folders that live outside of the project
 */
public List<SourceFolder> getExternalSourceFolders(Iterable<SourceSet> sourceSets, Function<File, String> provideRelativePath) {
    List<SourceFolder> sourceFolders = projectRelativeFolders(sourceSets, provideRelativePath);
    List<SourceFolder> externalSourceFolders = CollectionUtils.filter(sourceFolders, new Spec<SourceFolder>() {
        @Override
        public boolean isSatisfiedBy(SourceFolder element) {
            return element.getPath().contains("..");
        }
    });
    List<SourceFolder> regularSourceFolders = getRegularSourceFolders(sourceSets, provideRelativePath);
    List<String> sources = Lists.newArrayList(Lists.transform(regularSourceFolders, new Function<SourceFolder, String>() {
        @Override
        public String apply(SourceFolder sourceFolder) {
            return sourceFolder.getName();
        }
    }));
    return trimAndDedup(externalSourceFolders, sources);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:SourceFoldersCreator.java

示例3: projectRelativeFolders

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private List<SourceFolder> projectRelativeFolders(Iterable<SourceSet> sourceSets, Function<File, String> provideRelativePath) {
    ArrayList<SourceFolder> entries = Lists.newArrayList();
    List<SourceSet> sortedSourceSets = sortSourceSetsAsPerUsualConvention(sourceSets);
    for (SourceSet sourceSet : sortedSourceSets) {
        List<DirectoryTree> sortedSourceDirs = sortSourceDirsAsPerUsualConvention(sourceSet.getAllSource().getSrcDirTrees());
        for (DirectoryTree tree : sortedSourceDirs) {
            File dir = tree.getDir();
            if (dir.isDirectory()) {
                String relativePath = provideRelativePath.apply(dir);
                SourceFolder folder = new SourceFolder(relativePath, null);
                folder.setDir(dir);
                folder.setName(dir.getName());
                folder.setIncludes(getIncludesForTree(sourceSet, tree));
                folder.setExcludes(getExcludesForTree(sourceSet, tree));
                entries.add(folder);
            }
        }
    }
    return entries;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:SourceFoldersCreator.java

示例4: configureSourceSets

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void configureSourceSets(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();

    SourceSet main = pluginConvention.getSourceSets().create(SourceSet.MAIN_SOURCE_SET_NAME);

    SourceSet test = pluginConvention.getSourceSets().create(SourceSet.TEST_SOURCE_SET_NAME);
    test.setCompileClasspath(project.files(main.getOutput(), project.getConfigurations().getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
    test.setRuntimeClasspath(project.files(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(TEST_RUNTIME_CONFIGURATION_NAME)));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:JavaPlugin.java

示例5: configureSourceSetDefaults

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
        public void execute(SourceSet sourceSet) {
            final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory);
            new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);

            groovySourceSet.getGroovy().srcDir("src/" + sourceSet.getName() + "/groovy");
            sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
                public boolean isSatisfiedBy(FileTreeElement element) {
                    return groovySourceSet.getGroovy().contains(element.getFile());
                }
            });
            sourceSet.getAllJava().source(groovySourceSet.getGroovy());
            sourceSet.getAllSource().source(groovySourceSet.getGroovy());

            String compileTaskName = sourceSet.getCompileTaskName("groovy");
            GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
            javaBasePlugin.configureForSourceSet(sourceSet, compile);
            compile.dependsOn(sourceSet.getCompileJavaTaskName());
            compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source.");
            compile.setSource(groovySourceSet.getGroovy());

            project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:GroovyBasePlugin.java

示例6: addRunTask

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void addRunTask() {
    JavaExec run = project.getTasks().create(TASK_RUN_NAME, JavaExec.class);
    run.setDescription("Runs this project as a JVM application");
    run.setGroup(APPLICATION_GROUP);

    JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    run.setClasspath(javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath());
    run.getConventionMapping().map("main", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            return pluginConvention.getMainClassName();
        }
    });
    run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            return pluginConvention.getApplicationDefaultJvmArgs();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:ApplicationPlugin.java

示例7: createCompileJavaTaskForBinary

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:JavaBasePlugin.java

示例8: defineConfigurationsForSourceSet

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void defineConfigurationsForSourceSet(SourceSet sourceSet, ConfigurationContainer configurations) {
    Configuration compileConfiguration = configurations.maybeCreate(sourceSet.getCompileConfigurationName());
    compileConfiguration.setVisible(false);
    compileConfiguration.setDescription("Dependencies for " + sourceSet + ".");

    Configuration runtimeConfiguration = configurations.maybeCreate(sourceSet.getRuntimeConfigurationName());
    runtimeConfiguration.setVisible(false);
    runtimeConfiguration.extendsFrom(compileConfiguration);
    runtimeConfiguration.setDescription("Runtime dependencies for " + sourceSet + ".");

    Configuration compileOnlyConfiguration = configurations.maybeCreate(sourceSet.getCompileOnlyConfigurationName());
    compileOnlyConfiguration.setVisible(false);
    compileOnlyConfiguration.extendsFrom(compileConfiguration);
    compileOnlyConfiguration.setDescription("Compile dependencies for " + sourceSet + ".");

    Configuration compileClasspathConfiguration = configurations.maybeCreate(sourceSet.getCompileClasspathConfigurationName());
    compileClasspathConfiguration.setVisible(false);
    compileClasspathConfiguration.extendsFrom(compileOnlyConfiguration);
    compileClasspathConfiguration.setDescription("Compile classpath for " + sourceSet + ".");

    sourceSet.setCompileClasspath(compileClasspathConfiguration);
    sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:JavaBasePlugin.java

示例9: configureForSourceSet

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:JavaBasePlugin.java

示例10: configureDev

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void configureDev(Project project, JavaPluginConvention javaConvention) {
  SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
  SourceSet test = javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
  SourceSet dev = javaConvention.getSourceSets().create(DEV_SOURCE_SET_NAME);
  dev.setCompileClasspath(project.files(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(dev.getCompileClasspathConfigurationName())));
  dev.setRuntimeClasspath(project.files(dev.getAllSource().getSourceDirectories(), test.getAllSource().getSourceDirectories(), main.getAllSource().getSourceDirectories(), project.getConfigurations().getByName(dev.getRuntimeClasspathConfigurationName())));

  Stream.<Function<SourceSet, String>>of(SourceSet::getCompileConfigurationName, SourceSet::getImplementationConfigurationName, SourceSet::getRuntimeConfigurationName, SourceSet::getRuntimeOnlyConfigurationName).forEach(getter -> {
    Configuration devConf = project.getConfigurations().getByName(getter.apply(dev));
    Configuration testConf = project.getConfigurations().getByName(getter.apply(test));
    devConf.extendsFrom(testConf);
  });

  project.getTasks().create("clojureRepl", ClojureNRepl.class, task -> {
    task.setGroup("run");
    task.setDescription("Starts an nREPL server.");
    task.setClasspath(dev.getRuntimeClasspath());
  });
}
 
开发者ID:gradle-clojure,项目名称:gradle-clojure,代码行数:20,代码来源:ClojurePlugin.java

示例11: configureCompileTestJavaTask

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void configureCompileTestJavaTask(final Project project) {
    final JavaCompile compileTestJava = (JavaCompile) project.getTasks()
            .findByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    compileTestJava.getInputs().property("moduleName", module.geName());
    compileTestJava.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(compileTestJava.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("junit");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getSourceDirectories().getAsPath());
            compileTestJava.getOptions().setCompilerArgs(args);
            compileTestJava.setClasspath(project.files());
        }
    });
}
 
开发者ID:gradle,项目名称:gradle-java-modules,代码行数:24,代码来源:JigsawPlugin.java

示例12: configureTestTask

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void configureTestTask(final Project project) {
    final Test testTask = (Test) project.getTasks().findByName(JavaPlugin.TEST_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    testTask.getInputs().property("moduleName", module.geName());
    testTask.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(testTask.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("ALL-MODULE-PATH");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getOutputDir());
            testTask.setJvmArgs(args);
            testTask.setClasspath(project.files());
        }
    });
}
 
开发者ID:gradle,项目名称:gradle-java-modules,代码行数:23,代码来源:JigsawPlugin.java

示例13: initializeMavenConfig

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
/**
 * Initialize the Maven configuration
 *
 * @param mavenConfig Maven configuration to initialize
 * @param projectContext Project context
 * @param configurations Configuration container
 */
@Defaults
public void initializeMavenConfig(MavenConfig mavenConfig, ProjectContext projectContext,
        ConfigurationContainer configurations) {
    mavenConfig.getPublications().create(SourceSet.MAIN_SOURCE_SET_NAME, p -> {
        p.setArtifactId(projectContext.getName());
        p.setArchivesConfiguration(Dependency.ARCHIVES_CONFIGURATION);
        p.setAddProjectArtifacts(false);
        p.setCompileConfigurations(Collections.singletonList(JavaPlugin.COMPILE_CONFIGURATION_NAME));
        p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.RUNTIME_CONFIGURATION_NAME));
    });

    if (configurations.findByName("testArchives") != null) {
        mavenConfig.getPublications().create(SourceSet.TEST_SOURCE_SET_NAME, p -> {
            p.setArtifactId(projectContext.getName() + "-" + SourceSet.TEST_SOURCE_SET_NAME);
            p.setArchivesConfiguration(Names.formatName("", Dependency.ARCHIVES_CONFIGURATION,
                    SourceSet.TEST_SOURCE_SET_NAME));
            p.setAddProjectArtifacts(true);
            p.setCompileConfigurations(
                    Collections.singletonList(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME));
            p.setRuntimeConfigurations(
                    Collections.singletonList(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME));
        });
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:32,代码来源:MavenConfigPlugin.java

示例14: formatName

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
/**
 * Create a name derived from a source set
 *
 * @param prefix Name prefix
 * @param suffix Name suffix
 * @param name Source set name
 * @return Derived name
 */
public static String formatName(String prefix, String suffix, String name) {
    StringBuilder result = new StringBuilder();

    result.append(prefix);

    if (!name.equalsIgnoreCase(SourceSet.MAIN_SOURCE_SET_NAME)) {
        if (result.length() > 0) {
            result.append(NAME_FORMATTER.convert(name));
        }
        else {
            result.append(name);
        }
    }

    if (result.length() > 0) {
        result.append(NAME_FORMATTER.convert(suffix));
    }
    else {
        result.append(suffix);
    }

    return result.toString();
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:32,代码来源:Names.java

示例15: mainClassNameFinder

import org.gradle.api.tasks.SourceSet; //导入依赖的package包/类
private void mainClassNameFinder(Project project) {
	FindMainClassTask findMainClassTask = project.getTasks()
			.create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class);
	SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
	if (mainSourceSet != null) {
		findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput());
	}
	project.getTasks().all(new Action<Task>() {
		@Override
		public void execute(Task task) {
			if (task instanceof BootRunTask || task instanceof CreateStartScripts) {
				task.dependsOn(FIND_MAIN_CLASS_TASK_NAME);
			}
		}
	});
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:RunPluginFeatures.java


注:本文中的org.gradle.api.tasks.SourceSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。