public static <T extends LanguageSourceSet> T create(Class<? extends LanguageSourceSet> publicType, Class<T> implementationType, ComponentSpecIdentifier componentId, SourceDirectorySetFactory sourceDirectorySetFactory) { NEXT_SOURCE_SET_INFO.set(new SourceSetInfo(componentId, publicType, sourceDirectorySetFactory)); try { try { return DirectInstantiator.INSTANCE.newInstance(implementationType); } catch (ObjectInstantiationException e) { throw new ModelInstantiationException(String.format("Could not create LanguageSourceSet of type %s", publicType.getSimpleName()), e.getCause()); } } finally { NEXT_SOURCE_SET_INFO.set(null); } }
public DefaultScalaSourceSet(String displayName, SourceDirectorySetFactory sourceDirectorySetFactory) { scala = sourceDirectorySetFactory.create(displayName + " Scala source"); scala.getFilter().include("**/*.java", "**/*.scala"); allScala = sourceDirectorySetFactory.create(displayName + " Scala source"); allScala.getFilter().include("**/*.scala"); allScala.source(scala); }
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) { final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class); project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { @Override public void execute(final SourceSet sourceSet) { String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null); Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory); sourceSetConvention.getPlugins().put("scala", scalaSourceSet); final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala(); scalaDirectorySet.srcDir(new Callable<File>() { @Override public File call() throws Exception { return project.file("src/" + sourceSet.getName() + "/scala"); } }); sourceSet.getAllJava().source(scalaDirectorySet); sourceSet.getAllSource().source(scalaDirectorySet); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { @Override public boolean isSatisfiedBy(FileTreeElement element) { return scalaDirectorySet.contains(element.getFile()); } }); configureScalaCompile(project, javaPlugin, sourceSet); } }); }
@Model Repositories repositories(ServiceRegistry serviceRegistry, FlavorContainer flavors, PlatformContainer platforms, BuildTypeContainer buildTypes) { Instantiator instantiator = serviceRegistry.get(Instantiator.class); SourceDirectorySetFactory sourceDirectorySetFactory = serviceRegistry.get(SourceDirectorySetFactory.class); NativePlatforms nativePlatforms = serviceRegistry.get(NativePlatforms.class); FileCollectionFactory fileCollectionFactory = serviceRegistry.get(FileCollectionFactory.class); Action<PrebuiltLibrary> initializer = new PrebuiltLibraryInitializer(instantiator, fileCollectionFactory, nativePlatforms, platforms.withType(NativePlatform.class), buildTypes, flavors); return new DefaultRepositories(instantiator, sourceDirectorySetFactory, initializer); }
private DefaultRepositories(final Instantiator instantiator, final SourceDirectorySetFactory sourceDirectorySetFactory, final Action<PrebuiltLibrary> binaryFactory) { super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer()); registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() { public PrebuiltLibraries create(String name) { return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, sourceDirectorySetFactory, binaryFactory); } }); }
@Override public void addGeneratedScala(LanguageSourceSet input, SourceDirectorySetFactory sourceDirectorySetFactory) { String lssName = input.getName() + "ScalaSources"; // TODO: To get rid of this, we need a `FunctionalSourceSet` instance here, and that's surprisingly difficult to get. ScalaLanguageSourceSet generatedScalaSources = BaseLanguageSourceSet.create(ScalaLanguageSourceSet.class, DefaultScalaLanguageSourceSet.class, getIdentifier().child(lssName), sourceDirectorySetFactory); generatedScalaSources.builtBy(); generatedScala.put(input, generatedScalaSources); }
@Override public void addGeneratedJavaScript(LanguageSourceSet input, SourceDirectorySetFactory sourceDirectorySetFactory) { String lssName = input.getName() + "JavaScript"; JavaScriptSourceSet javaScript = BaseLanguageSourceSet.create(JavaScriptSourceSet.class, DefaultJavaScriptSourceSet.class, getIdentifier().child(lssName), sourceDirectorySetFactory); javaScript.builtBy(); generatedJavaScript.put(input, javaScript); }
@Mutate void createGeneratedJavaScriptSourceSets(@Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> binaries, final SourceDirectorySetFactory sourceDirectorySetFactory) { binaries.all(new Action<PlayApplicationBinarySpecInternal>() { @Override public void execute(PlayApplicationBinarySpecInternal playApplicationBinarySpec) { for (CoffeeScriptSourceSet coffeeScriptSourceSet : playApplicationBinarySpec.getInputs().withType(CoffeeScriptSourceSet.class)) { playApplicationBinarySpec.addGeneratedJavaScript(coffeeScriptSourceSet, sourceDirectorySetFactory); } } }); }
@Mutate void createGeneratedScalaSourceSets(@Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> binaries, final SourceDirectorySetFactory sourceDirectorySetFactory) { binaries.all(new Action<PlayApplicationBinarySpecInternal>() { @Override public void execute(PlayApplicationBinarySpecInternal playApplicationBinarySpec) { for (LanguageSourceSet languageSourceSet : playApplicationBinarySpec.getInputs().withType(RoutesSourceSet.class)) { playApplicationBinarySpec.addGeneratedScala(languageSourceSet, sourceDirectorySetFactory); } } }); }
@Mutate void createGeneratedScalaSourceSets(@Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> binaries, final SourceDirectorySetFactory sourceDirectorySetFactory) { binaries.all(new Action<PlayApplicationBinarySpecInternal>() { @Override public void execute(PlayApplicationBinarySpecInternal playApplicationBinarySpec) { for (LanguageSourceSet languageSourceSet : playApplicationBinarySpec.getInputs().withType(TwirlSourceSet.class)) { playApplicationBinarySpec.addGeneratedScala(languageSourceSet, sourceDirectorySetFactory); } } }); }
public DefaultSourceSetContainer(FileResolver fileResolver, TaskResolver taskResolver, Instantiator classGenerator, SourceDirectorySetFactory sourceDirectorySetFactory) { super(SourceSet.class, classGenerator, new Namer<SourceSet>() { public String determineName(SourceSet ss) { return ss.getName(); } }); this.fileResolver = fileResolver; this.taskResolver = taskResolver; this.instantiator = classGenerator; this.sourceDirectorySetFactory = sourceDirectorySetFactory; }
public DefaultGroovySourceSet(String displayName, SourceDirectorySetFactory sourceDirectorySetFactory) { groovy = sourceDirectorySetFactory.create(displayName + " Groovy source"); groovy.getFilter().include("**/*.java", "**/*.groovy"); allGroovy = sourceDirectorySetFactory.create(displayName + " Groovy source"); allGroovy.source(groovy); allGroovy.getFilter().include("**/*.groovy"); }
public DefaultSourceSet(String name, SourceDirectorySetFactory sourceDirectorySetFactory) { this.name = name; displayName = GUtil.toWords(this.name); namingScheme = new ClassDirectoryBinaryNamingScheme(name); String javaSrcDisplayName = displayName + " Java source"; javaSource = sourceDirectorySetFactory.create(javaSrcDisplayName); javaSource.getFilter().include("**/*.java"); allJavaSource = sourceDirectorySetFactory.create(javaSrcDisplayName); allJavaSource.getFilter().include("**/*.java"); allJavaSource.source(javaSource); String resourcesDisplayName = displayName + " resources"; resources = sourceDirectorySetFactory.create(resourcesDisplayName); resources.getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return javaSource.contains(element.getFile()); } }); String allSourceDisplayName = displayName + " source"; allSource = sourceDirectorySetFactory.create(allSourceDisplayName); allSource.source(resources); allSource.source(javaSource); }
public JavaPluginConvention(ProjectInternal project, Instantiator instantiator) { this.project = project; sourceSets = instantiator.newInstance(DefaultSourceSetContainer.class, project.getFileResolver(), project.getTasks(), instantiator, project.getServices().get(SourceDirectorySetFactory.class)); dependencyCacheDirName = "dependency-cache"; docsDirName = "docs"; testResultsDirName = "test-results"; testReportDirName = "tests"; }
public DefaultLatteSourceSet(String displayName, SourceDirectorySetFactory sourceDirectorySetFactory) { latte = sourceDirectorySetFactory.create(displayName + " Latte source"); latte.getFilter().include("**/*.lt", "**/*.latte"); allLatte = sourceDirectorySetFactory.create(displayName + " Latte source"); allLatte.source(latte); allLatte.getFilter().include("**/*.lt", "**/*.latte"); }
@Hidden @Model ComponentSpecFactory componentSpecFactory(ProjectIdentifier projectIdentifier, Instantiator instantiator, ITaskFactory taskFactory, SourceDirectorySetFactory sourceDirectorySetFactory) { return new ComponentSpecFactory(projectIdentifier, instantiator, taskFactory, sourceDirectorySetFactory); }
private SourceSetInfo(ComponentSpecIdentifier identifier, Class<? extends LanguageSourceSet> publicType, SourceDirectorySetFactory sourceDirectorySetFactory) { this.identifier = identifier; this.publicType = publicType; this.sourceDirectorySetFactory = sourceDirectorySetFactory; }
@Inject public AntlrPlugin(SourceDirectorySetFactory sourceDirectorySetFactory) { this.sourceDirectorySetFactory = sourceDirectorySetFactory; }
public AntlrSourceVirtualDirectoryImpl(String parentDisplayName, SourceDirectorySetFactory sourceDirectorySetFactory) { final String displayName = parentDisplayName + " Antlr source"; antlr = sourceDirectorySetFactory.create(displayName); antlr.getFilter().include("**/*.g"); antlr.getFilter().include("**/*.g4"); }
@Inject public ScalaBasePlugin(SourceDirectorySetFactory sourceDirectorySetFactory) { this.sourceDirectorySetFactory = sourceDirectorySetFactory; }
public DefaultPrebuiltLibrary(String name, SourceDirectorySetFactory sourceDirectorySetFactory) { this.name = name; headers = sourceDirectorySetFactory.create("headers", "headers for prebuilt library '" + name + "'"); binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class); }
public DefaultPrebuiltLibraries(String name, Instantiator instantiator, SourceDirectorySetFactory sourceDirectorySetFactory, Action<PrebuiltLibrary> libraryInitializer) { super(PrebuiltLibrary.class, instantiator); this.name = name; this.sourceDirectorySetFactory = sourceDirectorySetFactory; this.libraryInitializer = libraryInitializer; }
@Hidden @Model SourceDirectorySetFactory sourceDirectorySetFactory(ServiceRegistry serviceRegistry) { return serviceRegistry.get(SourceDirectorySetFactory.class); }
protected SourceDirectorySetFactory createSourceDirectorySetFactory(FileResolver fileResolver, DirectoryFileTreeFactory directoryFileTreeFactory) { return new DefaultSourceDirectorySetFactory(fileResolver, directoryFileTreeFactory); }
@Inject public GroovyBasePlugin(SourceDirectorySetFactory sourceDirectorySetFactory, ModuleRegistry moduleRegistry) { this.sourceDirectorySetFactory = sourceDirectorySetFactory; this.moduleRegistry = moduleRegistry; }
@Inject public ClojureBasePlugin(SourceDirectorySetFactory sourceDirectorySetFactory) { this.sourceDirectorySetFactory = sourceDirectorySetFactory; }
public DefaultClojureSourceSet(String name, SourceDirectorySetFactory sourceDirectorySetFactory) { this.clojure = sourceDirectorySetFactory.create(name); this.clojure.getFilter().include("**/*.clj", "**/*.cljc"); }
void addGeneratedScala(LanguageSourceSet input, SourceDirectorySetFactory sourceDirectorySetFactory);
void addGeneratedJavaScript(LanguageSourceSet input, SourceDirectorySetFactory sourceDirectorySetFactory);