Skip to content

Commit

Permalink
Parallelize source set retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur McGibbon committed Jul 10, 2024
1 parent 3b691da commit ff89166
Show file tree
Hide file tree
Showing 27 changed files with 774 additions and 756 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public interface GradleSourceSet extends Serializable {
*/
public String getDisplayName();

/**
* Equivalent to {@code org.gradle.api.Project.getName()}.
*/
public String getProjectName();

/**
* Equivalent to {@code org.gradle.api.Project.getPath()}.
*/
Expand Down Expand Up @@ -81,15 +76,20 @@ public interface GradleSourceSet extends Serializable {
public Set<File> getResourceDirs();

/**
* The output directory of this source set.
* The output directories of this source set.
*/
public File getSourceOutputDir();
Set<File> getSourceOutputDirs();

/**
* The resource output directory of this source set.
*/
public File getResourceOutputDir();

/**
* Any archive files created from the output of this source set to the output dirs.
*/
Map<File, List<File>> getArchiveOutputFiles();

/**
* The compile classpath for this source set.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ public interface JavaExtension extends LanguageExtension {
* The list of compiler arguments.
*/
public List<String> getCompilerArgs();

/**
* The classes directory.
*/
File getClassesDir();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

package com.microsoft.java.bs.gradle.model;

import java.io.File;
import java.io.Serializable;
import java.util.Set;

/**
* Interface representing a language extension.
Expand All @@ -13,6 +15,34 @@
*/
public interface LanguageExtension extends Serializable {

/**
* returns all the source directories for this language.
*
* @return set of source directories
*/
Set<File> getSourceDirs();

/**
* returns all the generated source directories for this language.
*
* @return set of generated source directories
*/
Set<File> getGeneratedSourceDirs();

/**
* returns the output directory for this language.
*
* @return directory containing class files
*/
File getClassesDir();

/**
* returns the name of the Gradle compile task for this language.
*
* @return name of Gradle compile task
*/
String getCompileTaskName();

/**
* Checks if the implementing class is a {@link JavaExtension}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public interface ScalaExtension extends LanguageExtension {
* E.g. scala-library, scala-compiler and scala-reflect.
*/
List<File> getScalaJars();

/**
* The classes directory.
*/
File getClassesDir();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class DefaultGradleSourceSet implements GradleSourceSet {

private String displayName;

private String projectName;

private String projectPath;

private File projectDir;
Expand All @@ -45,12 +43,14 @@ public class DefaultGradleSourceSet implements GradleSourceSet {

private Set<File> generatedSourceDirs;

private File sourceOutputDir;
private Set<File> sourceOutputDirs;

private Set<File> resourceDirs;

private File resourceOutputDir;

private Map<File, List<File>> archiveOutputFiles;

private List<File> compileClasspath;

private Set<GradleModuleDependency> moduleDependencies;
Expand All @@ -71,7 +71,6 @@ public DefaultGradleSourceSet() {}
public DefaultGradleSourceSet(GradleSourceSet gradleSourceSet) {
this.gradleVersion = gradleSourceSet.getGradleVersion();
this.displayName = gradleSourceSet.getDisplayName();
this.projectName = gradleSourceSet.getProjectName();
this.projectPath = gradleSourceSet.getProjectPath();
this.projectDir = gradleSourceSet.getProjectDir();
this.rootDir = gradleSourceSet.getRootDir();
Expand All @@ -81,9 +80,10 @@ public DefaultGradleSourceSet(GradleSourceSet gradleSourceSet) {
this.taskNames = gradleSourceSet.getTaskNames();
this.sourceDirs = gradleSourceSet.getSourceDirs();
this.generatedSourceDirs = gradleSourceSet.getGeneratedSourceDirs();
this.sourceOutputDir = gradleSourceSet.getSourceOutputDir();
this.sourceOutputDirs = gradleSourceSet.getSourceOutputDirs();
this.resourceDirs = gradleSourceSet.getResourceDirs();
this.resourceOutputDir = gradleSourceSet.getResourceOutputDir();
this.archiveOutputFiles = gradleSourceSet.getArchiveOutputFiles();
this.compileClasspath = gradleSourceSet.getCompileClasspath();
this.moduleDependencies = gradleSourceSet.getModuleDependencies().stream()
.map(DefaultGradleModuleDependency::new).collect(Collectors.toSet());
Expand Down Expand Up @@ -125,15 +125,6 @@ public void setDisplayName(String displayName) {
this.displayName = displayName;
}

@Override
public String getProjectName() {
return projectName;
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}

@Override
public String getProjectPath() {
return projectPath;
Expand Down Expand Up @@ -213,12 +204,12 @@ public void setGeneratedSourceDirs(Set<File> generatedSourceDirs) {
}

@Override
public File getSourceOutputDir() {
return sourceOutputDir;
public Set<File> getSourceOutputDirs() {
return sourceOutputDirs;
}

public void setSourceOutputDir(File sourceOutputDir) {
this.sourceOutputDir = sourceOutputDir;
public void setSourceOutputDirs(Set<File> sourceOutputDirs) {
this.sourceOutputDirs = sourceOutputDirs;
}

@Override
Expand All @@ -239,6 +230,15 @@ public void setResourceOutputDir(File resourceOutputDir) {
this.resourceOutputDir = resourceOutputDir;
}

@Override
public Map<File, List<File>> getArchiveOutputFiles() {
return archiveOutputFiles;
}

public void setArchiveOutputFiles(Map<File, List<File>> archiveOutputFiles) {
this.archiveOutputFiles = archiveOutputFiles;
}

@Override
public List<File> getCompileClasspath() {
return compileClasspath;
Expand Down Expand Up @@ -286,9 +286,9 @@ public void setExtensions(Map<String, LanguageExtension> extensions) {

@Override
public int hashCode() {
return Objects.hash(gradleVersion, displayName, projectName, projectPath,
return Objects.hash(gradleVersion, displayName, projectPath,
projectDir, rootDir, sourceSetName, classesTaskName, cleanTaskName, taskNames, sourceDirs,
generatedSourceDirs, sourceOutputDir, resourceDirs, resourceOutputDir,
generatedSourceDirs, sourceOutputDirs, resourceDirs, resourceOutputDir, archiveOutputFiles,
compileClasspath, moduleDependencies, buildTargetDependencies,
hasTests, extensions);
}
Expand All @@ -307,7 +307,6 @@ public boolean equals(Object obj) {
DefaultGradleSourceSet other = (DefaultGradleSourceSet) obj;
return Objects.equals(gradleVersion, other.gradleVersion)
&& Objects.equals(displayName, other.displayName)
&& Objects.equals(projectName, other.projectName)
&& Objects.equals(projectPath, other.projectPath)
&& Objects.equals(projectDir, other.projectDir)
&& Objects.equals(rootDir, other.rootDir)
Expand All @@ -317,9 +316,10 @@ public boolean equals(Object obj) {
&& Objects.equals(taskNames, other.taskNames)
&& Objects.equals(sourceDirs, other.sourceDirs)
&& Objects.equals(generatedSourceDirs, other.generatedSourceDirs)
&& Objects.equals(sourceOutputDir, other.sourceOutputDir)
&& Objects.equals(sourceOutputDirs, other.sourceOutputDirs)
&& Objects.equals(resourceDirs, other.resourceDirs)
&& Objects.equals(resourceOutputDir, other.resourceOutputDir)
&& Objects.equals(archiveOutputFiles, other.archiveOutputFiles)
&& Objects.equals(compileClasspath, other.compileClasspath)
&& Objects.equals(moduleDependencies, other.moduleDependencies)
&& Objects.equals(buildTargetDependencies, other.buildTargetDependencies)
Expand Down

This file was deleted.

Loading

0 comments on commit ff89166

Please sign in to comment.