dev.jeka.core.tool.ParsedSourceInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jeka-core Show documentation
Show all versions of jeka-core Show documentation
Build and Run Java Code from Everywhere
The newest version!
/*
* Copyright 2014-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.jeka.core.tool;
import dev.jeka.core.api.depmanagement.JkDependency;
import dev.jeka.core.api.depmanagement.JkDependencySet;
import dev.jeka.core.api.utils.JkUtilsIterable;
import java.nio.file.Path;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
final class ParsedSourceInfo {
final LinkedHashSet importedBaseDirs;
final List compileOptions;
private JkDependencySet dependencies;
private JkDependencySet exportedDependencies;
ParsedSourceInfo(
JkDependencySet dependencies,
LinkedHashSet importedBaseDirs,
List compileOptions,
JkDependencySet exportedDependencies) {
this.dependencies = dependencies;
this.importedBaseDirs = importedBaseDirs;
this.compileOptions = compileOptions;
this.exportedDependencies = exportedDependencies;
}
ParsedSourceInfo() {
this(JkDependencySet.of(), new LinkedHashSet<>(), new LinkedList<>(), JkDependencySet.of());
}
ParsedSourceInfo merge(ParsedSourceInfo other) {
if (this.isEmpty()) {
return other;
} else if (other.isEmpty()) {
return this;
}
LinkedHashSet mergedDependencyProjects = new LinkedHashSet<>(this.importedBaseDirs);
mergedDependencyProjects.addAll(other.importedBaseDirs);
return new ParsedSourceInfo(
this.dependencies.and(other.dependencies),
mergedDependencyProjects,
JkUtilsIterable.concatLists(this.compileOptions, other.compileOptions),
this.exportedDependencies.and(other.exportedDependencies));
}
void addDep(boolean exported, JkDependency dependency) {
this.dependencies = dependencies.and(dependency);
if (exported) {
this.exportedDependencies = exportedDependencies.and(dependency);
}
}
JkDependencySet getDependencies() {
return dependencies;
}
JkDependencySet getExportedDependencies() {
return exportedDependencies;
}
boolean hasPrivateDependencies() {
return dependencies.getEntries().size() > exportedDependencies.getEntries().size();
}
private boolean isEmpty() {
return this.compileOptions.isEmpty() &&
this.exportedDependencies.getEntries().isEmpty() &&
this.importedBaseDirs.isEmpty() &&
this.dependencies.getEntries().isEmpty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy