mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-27 00:38:12 -07:00
Provided scope dependencies are now stored in a separate directory and are only added to compile and test classpaths, but are not included for any runtime or distribution contexts.
This commit is contained in:
parent
6ffd6260b1
commit
af6525acfa
27 changed files with 467 additions and 192 deletions
|
@ -250,6 +250,13 @@ public class BaseProject extends BuildExecutor {
|
|||
* @since 1.5
|
||||
*/
|
||||
protected File libCompileDirectory = null;
|
||||
/**
|
||||
* The provided scope lib directory.
|
||||
*
|
||||
* @see #libProvidedDirectory()
|
||||
* @since 1.8
|
||||
*/
|
||||
protected File libProvidedDirectory = null;
|
||||
/**
|
||||
* The runtime scope lib directory.
|
||||
*
|
||||
|
@ -1010,6 +1017,16 @@ public class BaseProject extends BuildExecutor {
|
|||
return Objects.requireNonNullElseGet(libCompileDirectory, () -> new File(libDirectory(), "compile"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project provided scope lib directory.
|
||||
* Defaults to {@code "provided"} relative to {@link #libDirectory()}.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public File libProvidedDirectory() {
|
||||
return Objects.requireNonNullElseGet(libProvidedDirectory, () -> new File(libDirectory(), "provided"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project runtime scope lib directory.
|
||||
* Defaults to {@code "runtime"} relative to {@link #libDirectory()}.
|
||||
|
@ -1130,6 +1147,7 @@ public class BaseProject extends BuildExecutor {
|
|||
libDirectory().mkdirs();
|
||||
libBldDirectory().mkdirs();
|
||||
libCompileDirectory().mkdirs();
|
||||
libProvidedDirectory().mkdirs();
|
||||
libRuntimeDirectory().mkdirs();
|
||||
if (libStandaloneDirectory() != null) {
|
||||
libStandaloneDirectory().mkdirs();
|
||||
|
@ -1399,6 +1417,24 @@ public class BaseProject extends BuildExecutor {
|
|||
// build the compilation classpath
|
||||
var classpath = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
|
||||
addLocalDependencies(classpath, Scope.compile);
|
||||
return classpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the jar files that are in the provided scope classpath.
|
||||
* <p>
|
||||
* By default, this collects all the jar files in the {@link #libProvidedDirectory()}
|
||||
* and adds all the jar files from the provided scope local dependencies.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public List<File> providedClasspathJars() {
|
||||
// detect the jar files in the provided lib directory
|
||||
var dir_abs = libProvidedDirectory().getAbsoluteFile();
|
||||
var jar_files = FileUtils.getFileList(dir_abs, INCLUDED_JARS, EXCLUDED_JARS);
|
||||
|
||||
// build the compilation classpath
|
||||
var classpath = new ArrayList<>(jar_files.stream().map(file -> new File(dir_abs, file)).toList());
|
||||
addLocalDependencies(classpath, Scope.provided);
|
||||
return classpath;
|
||||
}
|
||||
|
@ -1491,7 +1527,7 @@ public class BaseProject extends BuildExecutor {
|
|||
* @since 1.5
|
||||
*/
|
||||
public List<String> compileMainClasspath() {
|
||||
return FileUtils.combineToAbsolutePaths(compileClasspathJars());
|
||||
return FileUtils.combineToAbsolutePaths(compileClasspathJars(), providedClasspathJars());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1505,7 +1541,7 @@ public class BaseProject extends BuildExecutor {
|
|||
public List<String> compileTestClasspath() {
|
||||
var paths = new ArrayList<String>();
|
||||
paths.add(buildMainDirectory().getAbsolutePath());
|
||||
paths.addAll(FileUtils.combineToAbsolutePaths(compileClasspathJars(), testClasspathJars()));
|
||||
paths.addAll(FileUtils.combineToAbsolutePaths(compileClasspathJars(), providedClasspathJars(), testClasspathJars()));
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
@ -1542,7 +1578,7 @@ public class BaseProject extends BuildExecutor {
|
|||
paths.add(srcTestResourcesDirectory().getAbsolutePath());
|
||||
paths.add(buildMainDirectory().getAbsolutePath());
|
||||
paths.add(buildTestDirectory().getAbsolutePath());
|
||||
paths.addAll(FileUtils.combineToAbsolutePaths(compileClasspathJars(), runtimeClasspathJars(), standaloneClasspathJars(), testClasspathJars()));
|
||||
paths.addAll(FileUtils.combineToAbsolutePaths(compileClasspathJars(), providedClasspathJars(), runtimeClasspathJars(), standaloneClasspathJars(), testClasspathJars()));
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,23 @@ public class DependencyScopes extends LinkedHashMap<Scope, DependencySet> {
|
|||
*/
|
||||
public DependencySet resolveCompileDependencies(ArtifactRetriever retriever, List<Repository> repositories) {
|
||||
return resolveScopedDependencies(retriever, repositories,
|
||||
new Scope[]{Scope.provided, Scope.compile},
|
||||
new Scope[]{Scope.compile},
|
||||
new Scope[]{Scope.compile},
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the transitive set of dependencies that would be used for the provided scope in a project.
|
||||
*
|
||||
* @param retriever the retriever to use to get artifacts
|
||||
* @param repositories the repositories to use for the resolution
|
||||
* @return the provided scope dependency set
|
||||
* @since 1.8
|
||||
*/
|
||||
public DependencySet resolveProvidedDependencies(ArtifactRetriever retriever, List<Repository> repositories) {
|
||||
return resolveScopedDependencies(retriever, repositories,
|
||||
new Scope[]{Scope.provided},
|
||||
new Scope[]{Scope.compile, Scope.runtime},
|
||||
null);
|
||||
}
|
||||
|
||||
|
@ -88,7 +103,7 @@ public class DependencyScopes extends LinkedHashMap<Scope, DependencySet> {
|
|||
*/
|
||||
public DependencySet resolveRuntimeDependencies(ArtifactRetriever retriever, List<Repository> repositories) {
|
||||
return resolveScopedDependencies(retriever, repositories,
|
||||
new Scope[]{Scope.provided, Scope.compile, Scope.runtime},
|
||||
new Scope[]{Scope.compile, Scope.runtime},
|
||||
new Scope[]{Scope.compile, Scope.runtime},
|
||||
resolveCompileDependencies(retriever, repositories));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
private final List<Repository> repositories_ = new ArrayList<>();
|
||||
private final DependencyScopes dependencies_ = new DependencyScopes();
|
||||
private File libCompileDirectory_;
|
||||
private File libProvidedDirectory_;
|
||||
private File libRuntimeDirectory_;
|
||||
private File libStandaloneDirectory_;
|
||||
private File libTestDirectory_;
|
||||
|
@ -41,6 +42,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
*/
|
||||
public void execute() {
|
||||
executeDownloadCompileDependencies();
|
||||
executeDownloadProvidedDependencies();
|
||||
executeDownloadRuntimeDependencies();
|
||||
executeDownloadStandaloneDependencies();
|
||||
executeDownloadTestDependencies();
|
||||
|
@ -58,6 +60,15 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
executeDownloadDependencies(libCompileDirectory(), dependencies().resolveCompileDependencies(artifactRetriever(), repositories()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute} operation, download the {@code provided} scope artifacts.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
protected void executeDownloadProvidedDependencies() {
|
||||
executeDownloadDependencies(libProvidedDirectory(), dependencies().resolveProvidedDependencies(artifactRetriever(), repositories()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute} operation, download the {@code runtime} scope artifacts.
|
||||
*
|
||||
|
@ -123,6 +134,7 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
.repositories(project.repositories())
|
||||
.dependencies(project.dependencies())
|
||||
.libCompileDirectory(project.libCompileDirectory())
|
||||
.libProvidedDirectory(project.libProvidedDirectory())
|
||||
.libRuntimeDirectory(project.libRuntimeDirectory())
|
||||
.libStandaloneDirectory(project.libStandaloneDirectory())
|
||||
.libTestDirectory(project.libTestDirectory())
|
||||
|
@ -180,6 +192,18 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code provided} scope download directory.
|
||||
*
|
||||
* @param directory the directory to download the {@code provided} scope artifacts into
|
||||
* @return this operation instance
|
||||
* @since 1.8
|
||||
*/
|
||||
public DownloadOperation libProvidedDirectory(File directory) {
|
||||
libProvidedDirectory_ = directory;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code runtime} scope download directory.
|
||||
*
|
||||
|
@ -288,6 +312,16 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
return libCompileDirectory_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@code provided} scope download directory.
|
||||
*
|
||||
* @return the {@code provided} scope download directory
|
||||
* @since 1.8
|
||||
*/
|
||||
public File libProvidedDirectory() {
|
||||
return libProvidedDirectory_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@code runtime} scope download directory.
|
||||
*
|
||||
|
|
|
@ -28,6 +28,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
private final List<Repository> repositories_ = new ArrayList<>();
|
||||
private final DependencyScopes dependencies_ = new DependencyScopes();
|
||||
private File libCompileDirectory_;
|
||||
private File libProvidedDirectory_;
|
||||
private File libRuntimeDirectory_;
|
||||
private File libStandaloneDirectory_;
|
||||
private File libTestDirectory_;
|
||||
|
@ -41,6 +42,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
*/
|
||||
public void execute() {
|
||||
executePurgeCompileDependencies();
|
||||
executePurgeProvidedDependencies();
|
||||
executePurgeRuntimeDependencies();
|
||||
executePurgeStandaloneDependencies();
|
||||
executePurgeTestDependencies();
|
||||
|
@ -58,6 +60,15 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
executePurgeDependencies(libCompileDirectory(), dependencies().resolveCompileDependencies(artifactRetriever(), repositories()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute} operation, purge the {@code provided} scope artifacts.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
protected void executePurgeProvidedDependencies() {
|
||||
executePurgeDependencies(libProvidedDirectory(), dependencies().resolveProvidedDependencies(artifactRetriever(), repositories()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute} operation, purge the {@code runtime} scope artifacts.
|
||||
*
|
||||
|
@ -137,6 +148,7 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
.repositories(project.repositories())
|
||||
.dependencies(project.dependencies())
|
||||
.libCompileDirectory(project.libCompileDirectory())
|
||||
.libProvidedDirectory(project.libProvidedDirectory())
|
||||
.libRuntimeDirectory(project.libRuntimeDirectory())
|
||||
.libStandaloneDirectory(project.libStandaloneDirectory())
|
||||
.libTestDirectory(project.libTestDirectory())
|
||||
|
@ -220,6 +232,18 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code provided} scope purge directory.
|
||||
*
|
||||
* @param directory the directory to purge the {@code provided} scope artifacts from
|
||||
* @return this operation instance
|
||||
* @since 1.8
|
||||
*/
|
||||
public PurgeOperation libProvidedDirectory(File directory) {
|
||||
libProvidedDirectory_ = directory;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@code runtime} scope purge directory.
|
||||
*
|
||||
|
@ -302,6 +326,16 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
return libCompileDirectory_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@code provided} scope purge directory.
|
||||
*
|
||||
* @return the {@code provided} scope purge directory
|
||||
* @since 1.8
|
||||
*/
|
||||
public File libProvidedDirectory() {
|
||||
return libProvidedDirectory_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@code runtime} scope purge directory.
|
||||
*
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.7.6-SNAPSHOT
|
||||
1.8.0-SNAPSHOT
|
|
@ -2,12 +2,16 @@
|
|||
<library name="compile">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -2,13 +2,17 @@
|
|||
<library name="test">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -9,6 +9,7 @@
|
|||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/provided/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/test/*.jar"
|
||||
]
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
<library name="compile">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -2,13 +2,17 @@
|
|||
<library name="test">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -9,6 +9,7 @@
|
|||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/provided/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/test/*.jar"
|
||||
]
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
<library name="compile">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -2,13 +2,17 @@
|
|||
<library name="test">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -9,6 +9,7 @@
|
|||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/provided/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/test/*.jar"
|
||||
]
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
<library name="compile">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -2,13 +2,17 @@
|
|||
<library name="test">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||
<root url="file://$PROJECT_DIR$/lib/provided" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/provided" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
|
@ -10,6 +10,7 @@
|
|||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-{{v version/}}.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/provided/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/standalone/*.jar",
|
||||
"lib/test/*.jar"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue