mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 00:07:12 -07:00
Added bld.sourceDirectories property to allow additional source directories to be added for the build file compilation. Simplified build file by using the AbstractRife2Build file from core as the base.
This commit is contained in:
parent
3503ef3611
commit
ec683311b8
6 changed files with 30 additions and 99 deletions
3
.idea/bld.iml
generated
3
.idea/bld.iml
generated
|
@ -4,6 +4,9 @@
|
|||
<output url="file://$MODULE_DIR$/build/bld" />
|
||||
<output-test url="file://$MODULE_DIR$/build/bld" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/core/src/bld">
|
||||
<sourceFolder url="file://$MODULE_DIR$/core/src/bld/java" isTestSource="false" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/src/bld">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
||||
</content>
|
||||
|
|
2
core
2
core
|
@ -1 +1 @@
|
|||
Subproject commit 840b862d35c193c4b4dc5c82c2f9cebbbd50bf04
|
||||
Subproject commit 0d07c4856946555154afdd26e54d6a855fe3724f
|
Binary file not shown.
|
@ -5,4 +5,5 @@ bld.extension-archive=com.uwyn.rife2:bld-archive:0.4.0-SNAPSHOT
|
|||
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.4.0-SNAPSHOT
|
||||
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES,RIFE2_SNAPSHOTS
|
||||
bld.downloadLocation=
|
||||
bld.sourceDirectories=core/src/bld/java
|
||||
bld.version=1.7.0-SNAPSHOT
|
||||
|
|
|
@ -5,17 +5,13 @@
|
|||
package rife;
|
||||
|
||||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.dependencies.VersionNumber;
|
||||
import rife.bld.extension.Antlr4Operation;
|
||||
import rife.bld.extension.TestsBadgeOperation;
|
||||
import rife.bld.extension.ZipOperation;
|
||||
import rife.bld.operations.*;
|
||||
import rife.bld.publish.*;
|
||||
import rife.bld.wrapper.Wrapper;
|
||||
import rife.tools.DirBuilder;
|
||||
import rife.tools.FileUtils;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
@ -25,44 +21,20 @@ import java.util.regex.Pattern;
|
|||
|
||||
import static rife.bld.dependencies.Repository.*;
|
||||
import static rife.bld.dependencies.Scope.*;
|
||||
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
|
||||
import static rife.bld.operations.TemplateType.*;
|
||||
import static rife.tools.FileUtils.path;
|
||||
|
||||
public class BldBuild extends Project {
|
||||
public class BldBuild extends AbstractRife2Build {
|
||||
public BldBuild()
|
||||
throws Exception {
|
||||
pkg = "rife";
|
||||
name = "bld";
|
||||
mainClass = "rife.bld.Cli";
|
||||
version = version(FileUtils.readString(new File(srcMainResourcesDirectory(), "BLD_VERSION")));
|
||||
|
||||
javaRelease = 17;
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
|
||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
scope(test)
|
||||
.include(dependency("org.slf4j", "slf4j-simple", version(2,0,7)))
|
||||
.include(dependency("net.imagej", "ij", version("1.54d")))
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,9,3)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,9,3)))
|
||||
.include(dependency("com.h2database", "h2", version(2,1,214)))
|
||||
.include(dependency("net.sourceforge.htmlunit", "htmlunit", version(2,70,0)))
|
||||
.include(dependency("org.postgresql", "postgresql", version(42,6,0)))
|
||||
.include(dependency("com.mysql", "mysql-connector-j", version(8,0,33)))
|
||||
.include(dependency("org.mariadb.jdbc", "mariadb-java-client", version(3,1,4)))
|
||||
.include(dependency("org.hsqldb", "hsqldb", version(2,7,1)))
|
||||
.include(dependency("org.apache.derby", "derby", version("10.16.1.1")))
|
||||
.include(dependency("org.apache.derby", "derbytools", version("10.16.1.1")))
|
||||
.include(dependency("com.oracle.database.jdbc", "ojdbc11", version("23.2.0.0")))
|
||||
.include(dependency("org.json", "json", version(20230227)));
|
||||
|
||||
cleanOperation()
|
||||
.directories(
|
||||
new File(workDirectory(), "embedded_dbs"),
|
||||
new File(workDirectory(), "logs"));
|
||||
|
||||
var core_directory = new File(workDirectory(), "core");
|
||||
var core_src_directory = new File(core_directory, "src");
|
||||
var core_src_main_directory = new File(core_src_directory, "main");
|
||||
|
@ -75,9 +47,7 @@ public class BldBuild extends Project {
|
|||
|
||||
antlr4Operation
|
||||
.sourceDirectories(List.of(new File(core_src_main_directory, "antlr")))
|
||||
.outputDirectory(new File(buildDirectory(), "generated/rife/template/antlr"))
|
||||
.visitor()
|
||||
.longMessages();
|
||||
.outputDirectory(new File(buildDirectory(), "generated/rife/template/antlr"));
|
||||
|
||||
precompileOperation()
|
||||
.sourceDirectories(core_src_main_resources_templates_directory)
|
||||
|
@ -101,35 +71,11 @@ public class BldBuild extends Project {
|
|||
testsBadgeOperation
|
||||
.classpath(core_src_main_resources_directory.getAbsolutePath())
|
||||
.classpath(core_src_test_resources_directory.getAbsolutePath());
|
||||
propagateJavaProperties(testsBadgeOperation.javaOptions(),
|
||||
"test.postgres",
|
||||
"test.mysql",
|
||||
"test.mariadb",
|
||||
"test.oracle",
|
||||
"test.oracle-free",
|
||||
"test.derby",
|
||||
"test.hsqldb",
|
||||
"test.h2");
|
||||
|
||||
javadocOperation()
|
||||
.sourceFiles(FileUtils.getJavaFileList(core_src_main_java_directory))
|
||||
.excluded(
|
||||
"rife/antlr/",
|
||||
"rife/asm/",
|
||||
"rife/.*/databasedrivers/",
|
||||
"rife/.*/imagestoredrivers/",
|
||||
"rife/.*/rawstoredrivers/",
|
||||
"rife/.*/textstoredrivers/",
|
||||
"rife/database/capabilities/"
|
||||
)
|
||||
.javadocOptions()
|
||||
.docTitle("<a href=\"https://rife2.com/bld\">bld</a> " + version())
|
||||
.docLint(NO_MISSING)
|
||||
.keywords()
|
||||
.splitIndex()
|
||||
.tag("apiNote", "a", "API Note:")
|
||||
.link("https://jakarta.ee/specifications/servlet/5.0/apidocs/")
|
||||
.link("https://jsoup.org/apidocs/")
|
||||
.overview(new File(srcMainJavaDirectory(), "overview.html"));
|
||||
|
||||
publishOperation()
|
||||
|
@ -159,35 +105,6 @@ public class BldBuild extends Project {
|
|||
new PublishArtifact(zipBldOperation.destinationFile(), "", "zip"));
|
||||
}
|
||||
|
||||
void propagateJavaProperties(JavaOptions options, String... names) {
|
||||
for (var name : names) {
|
||||
if (properties().contains(name)) {
|
||||
options.property(name, properties().getValueString(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Antlr4Operation antlr4Operation = new Antlr4Operation() {
|
||||
@Override
|
||||
public void execute()
|
||||
throws Exception {
|
||||
super.execute();
|
||||
// replace the package name so that it becomes part of RIFE2
|
||||
FileUtils.transformFiles(outputDirectory(), FileUtils.JAVA_FILE_PATTERN, null, s ->
|
||||
StringUtils.replace(s, "org.antlr.v4.runtime", "rife.antlr.v4.runtime"));
|
||||
}
|
||||
};
|
||||
@BuildCommand(summary = "Generates the grammar Java sources")
|
||||
public void generateGrammar()
|
||||
throws Exception {
|
||||
antlr4Operation.executeOnce();
|
||||
}
|
||||
|
||||
public void compile()
|
||||
throws Exception {
|
||||
generateGrammar();
|
||||
super.compile();
|
||||
}
|
||||
|
||||
final ZipOperation zipBldOperation = new ZipOperation();
|
||||
@BuildCommand(value = "zip-bld", summary = "Creates the bld zip archive")
|
||||
|
@ -224,15 +141,6 @@ public class BldBuild extends Project {
|
|||
}
|
||||
}
|
||||
|
||||
private final TestsBadgeOperation testsBadgeOperation = new TestsBadgeOperation();
|
||||
public void test()
|
||||
throws Exception {
|
||||
testsBadgeOperation.executeOnce(() -> testsBadgeOperation
|
||||
.url(property("testsBadgeUrl"))
|
||||
.apiKey(property("testsBadgeApiKey"))
|
||||
.fromProject(this));
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Creates all the distribution artifacts")
|
||||
public void all()
|
||||
throws Exception {
|
||||
|
|
|
@ -49,6 +49,7 @@ public class Wrapper {
|
|||
static final String PROPERTY_EXTENSIONS = "bld.extensions";
|
||||
static final String PROPERTY_DOWNLOAD_EXTENSION_SOURCES = "bld.downloadExtensionSources";
|
||||
static final String PROPERTY_DOWNLOAD_EXTENSION_JAVADOC = "bld.downloadExtensionJavadoc";
|
||||
static final String PROPERTY_SOURCE_DIRECTORIES = "bld.sourceDirectories";
|
||||
static final File BLD_USER_DIR = new File(System.getProperty("user.home"), ".bld");
|
||||
static final File DISTRIBUTIONS_DIR = new File(BLD_USER_DIR, "dist");
|
||||
static final Pattern META_DATA_SNAPSHOT_VERSION = Pattern.compile("<snapshotVersion>.*?<value>([^<]+)</value>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
|
||||
|
@ -164,6 +165,7 @@ public class Wrapper {
|
|||
bld.extensions=
|
||||
bld.repositories=MAVEN_CENTRAL,RIFE2
|
||||
bld.downloadLocation=
|
||||
bld.sourceDirectories=
|
||||
bld.version=${version}
|
||||
"""
|
||||
.replace("${version}", version);
|
||||
|
@ -513,7 +515,7 @@ public class Wrapper {
|
|||
}
|
||||
|
||||
private int launchMainBuild(File jarFile, List<String> arguments)
|
||||
throws FileUtilsErrorException, IOException, InterruptedException {
|
||||
throws IOException, InterruptedException {
|
||||
resolveExtensions();
|
||||
|
||||
arguments.remove(0);
|
||||
|
@ -582,9 +584,26 @@ public class Wrapper {
|
|||
}
|
||||
|
||||
public List<File> bldSourceFiles() {
|
||||
var source_directories = new ArrayList<File>();
|
||||
source_directories.add(srcBldJavaDirectory().getAbsoluteFile());
|
||||
|
||||
// extract wrapper source directories specifications
|
||||
if (wrapperProperties_.containsKey(PROPERTY_SOURCE_DIRECTORIES)) {
|
||||
var source_directories_property = wrapperProperties_.get(PROPERTY_SOURCE_DIRECTORIES).toString();
|
||||
for (var source_directory : source_directories_property.split(",")) {
|
||||
source_directory = source_directory.trim();
|
||||
if (!source_directory.isBlank()) {
|
||||
source_directories.add(new File(source_directory).getAbsoluteFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the bld java sources
|
||||
var src_main_java_dir_abs = srcBldJavaDirectory().getAbsoluteFile();
|
||||
return FileUtils.getFileList(src_main_java_dir_abs, JAVA_FILE_PATTERN, null)
|
||||
.stream().map(file -> new File(src_main_java_dir_abs, file)).toList();
|
||||
var source_files = new ArrayList<File>();
|
||||
for (var source_directory : source_directories) {
|
||||
source_files.addAll(FileUtils.getFileList(source_directory, JAVA_FILE_PATTERN, null)
|
||||
.stream().map(file -> new File(source_directory, file)).toList());
|
||||
}
|
||||
return source_files;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue