Note that bld builds on top of the foundation that RIFE2 provides and includes the features of
10 | RIFE2/core.
11 |
12 |
17 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/BldVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | import rife.tools.FileUtils;
8 |
9 | /**
10 | * Singleton class that provides access to the current bld version as a string.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.7
14 | */
15 | public class BldVersion {
16 | private final String version_;
17 |
18 | BldVersion() {
19 | version_ = FileUtils.versionFromResource("BLD_VERSION");
20 | }
21 |
22 | private String getVersionString() {
23 | return version_;
24 | }
25 |
26 | public static String getVersion() {
27 | return BldVersionSingleton.INSTANCE.getVersionString();
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/BldVersionSingleton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | /**
8 | * Helper class to avoid Double Check Locking
9 | * and still have a thread-safe singleton pattern
10 | */
11 | class BldVersionSingleton {
12 | static final BldVersion INSTANCE = new BldVersion();
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/BuildCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | import java.lang.annotation.*;
8 |
9 | /**
10 | * Declares a {@link BuildExecutor} method to be used as a build command.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.5
14 | */
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Target({ElementType.METHOD})
17 | @Documented
18 | public @interface BuildCommand {
19 | /**
20 | * When provided, specifies a name for the build command that can be
21 | * different from the method name.
22 | *
23 | * @return a string representing the build command name
24 | * @since 1.5
25 | */
26 | String value() default "";
27 |
28 | /**
29 | * When provided, specifies an alias for the build command that can be
30 | * different from the method name.
31 | *
32 | * @return a string representing an alias for the build command
33 | * @since 1.9
34 | */
35 | String alias() default "";
36 |
37 | /**
38 | * When provided, specifies a short description about the command.
39 | *
40 | * @return the short summary, defaults to {@code ""}
41 | * @since 1.5.12
42 | */
43 | String summary() default "";
44 |
45 | /**
46 | * When provided, specifies the full help description of a command.
47 | *
48 | * @return the full help description, defaults to {@code ""}
49 | * @since 1.5.12
50 | */
51 | String description() default "";
52 |
53 | /**
54 | * When provided, specifies a class that provides help about the
55 | * build command.
56 | *
57 | * @return a class providing help information
58 | * @since 1.5
59 | */
60 | Class extends CommandHelp> help() default CommandHelp.class;
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/CommandAnnotated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | import java.lang.reflect.InvocationTargetException;
8 | import java.lang.reflect.Method;
9 |
10 | class CommandAnnotated implements CommandDefinition {
11 | private final BuildExecutor executor_;
12 | private final Method method_;
13 | private final CommandHelp help_;
14 |
15 | CommandAnnotated(BuildExecutor executor, Method method, CommandHelp help) {
16 | executor_ = executor;
17 | method_ = method;
18 | if (help == null) {
19 | help = new CommandHelp() {};
20 | }
21 | help_ = help;
22 | }
23 |
24 | public void execute()
25 | throws Throwable {
26 | try {
27 | method_.invoke(executor_);
28 | } catch (InvocationTargetException e) {
29 | throw e.getCause();
30 | }
31 | }
32 |
33 | public CommandHelp getHelp() {
34 | return help_;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/CommandDefinition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | /**
8 | * Defines the logic for a build command.
9 | *
10 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
11 | * @since 1.5
12 | */
13 | public interface CommandDefinition {
14 | /**
15 | * Called when a build command is executed.
16 | *
17 | * @throws Throwable when an error occurred during the execution of the build command
18 | * @since 1.5
19 | */
20 | void execute() throws Throwable;
21 |
22 | /**
23 | * Retrieves the help information of a build command.
24 | *
25 | * Defaults to blank help sections.
26 | *
27 | * @return this build command's help information
28 | * @since 1.5
29 | */
30 | default CommandHelp getHelp() {
31 | return new CommandHelp() {};
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/CommandHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | /**
8 | * Interface that provides help texts to display about {@link BuildExecutor} commands.
9 | *
10 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
11 | * @since 1.5
12 | */
13 | public interface CommandHelp {
14 | /**
15 | * Returns a short description about the command.
16 | *
17 | * @return the short summary, defaults to {@code ""}
18 | * @since 1.5
19 | */
20 | default String getSummary() {
21 | return "";
22 | }
23 |
24 | /**
25 | * Returns the full help description of a command.
26 | *
27 | * @return the full help description, defaults to {@code ""}
28 | * @since 1.5
29 | */
30 | default String getDescription(String topic) {
31 | return "";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/NamedFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld;
6 |
7 | import java.io.File;
8 |
9 | /**
10 | * Combines the information of a filesystem file with the name it's intended
11 | * to have.
12 | *
13 | * @param name the intended name of the file
14 | * @param file the location on the filesystem
15 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
16 | * @since 1.5
17 | */
18 | public record NamedFile(String name, File file) {
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/blueprints/AppProjectBlueprint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.blueprints;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.dependencies.VersionNumber;
9 | import rife.tools.StringUtils;
10 |
11 | import java.io.File;
12 | import java.util.List;
13 |
14 | import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
15 | import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
16 | import static rife.bld.dependencies.Scope.test;
17 |
18 | /**
19 | * Provides the dependency information required to create a new app project.
20 | *
21 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
22 | * @since 1.9
23 | */
24 | public class AppProjectBlueprint extends Project {
25 | public AppProjectBlueprint(File work, String packageName, String projectName, String baseName) {
26 | this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
27 | }
28 |
29 | public AppProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
30 | workDirectory = work;
31 |
32 | pkg = packageName;
33 | name = projectName;
34 | mainClass = packageName + "." + baseName;
35 | version = versionNumber;
36 |
37 | downloadSources = true;
38 | repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
39 | scope(test)
40 | .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
41 | .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
42 | }
43 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/blueprints/BaseProjectBlueprint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.blueprints;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.dependencies.VersionNumber;
9 | import rife.tools.StringUtils;
10 |
11 | import java.io.File;
12 | import java.util.List;
13 |
14 | import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
15 | import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
16 |
17 | /**
18 | * Provides the dependency information required to create a new base project.
19 | *
20 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
21 | * @since 1.5.20
22 | */
23 | public class BaseProjectBlueprint extends Project {
24 | public BaseProjectBlueprint(File work, String packageName, String projectName, String baseName) {
25 | this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
26 | }
27 |
28 | public BaseProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
29 | workDirectory = work;
30 |
31 | pkg = packageName;
32 | name = projectName;
33 | mainClass = packageName + "." + baseName;
34 | version = versionNumber;
35 |
36 | downloadSources = true;
37 | repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/blueprints/LibProjectBlueprint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.blueprints;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.dependencies.VersionNumber;
9 | import rife.tools.StringUtils;
10 |
11 | import java.io.File;
12 | import java.util.List;
13 |
14 | import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
15 | import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
16 | import static rife.bld.dependencies.Scope.test;
17 |
18 | /**
19 | * Provides the dependency information required to create a new lib project.
20 | *
21 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
22 | * @since 1.6
23 | */
24 | public class LibProjectBlueprint extends Project {
25 | public LibProjectBlueprint(File work, String packageName, String projectName, String baseName) {
26 | this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
27 | }
28 |
29 | public LibProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
30 | workDirectory = work;
31 |
32 | pkg = packageName;
33 | name = projectName;
34 | mainClass = packageName + "." + baseName;
35 | version = versionNumber;
36 |
37 | downloadSources = true;
38 | repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
39 | scope(test)
40 | .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
41 | .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
42 | }
43 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/blueprints/Rife2ProjectBlueprint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.blueprints;
6 |
7 | import rife.bld.WebProject;
8 | import rife.bld.dependencies.VersionNumber;
9 | import rife.bld.operations.TemplateType;
10 | import rife.tools.StringUtils;
11 |
12 | import java.io.File;
13 | import java.util.List;
14 |
15 | import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
16 | import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
17 | import static rife.bld.dependencies.Scope.*;
18 |
19 | /**
20 | * Provides the dependency information required to create a new RIFE2 project.
21 | *
22 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
23 | * @since 1.5
24 | */
25 | public class Rife2ProjectBlueprint extends WebProject {
26 | public Rife2ProjectBlueprint(File work, String packageName, String projectName, String baseName) {
27 | this(work, packageName, projectName, baseName, new VersionNumber(0,0,1));
28 | }
29 |
30 | public Rife2ProjectBlueprint(File work, String packageName, String projectName, String baseName, VersionNumber versionNumber) {
31 | workDirectory = work;
32 |
33 | pkg = packageName;
34 | name = projectName;
35 | mainClass = packageName + "." + baseName + "Site";
36 | uberJarMainClass = mainClass + "Uber";
37 | version = versionNumber;
38 |
39 | downloadSources = true;
40 | repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
41 | scope(compile)
42 | .include(dependency("com.uwyn.rife2", "rife2", version(1,9,1)));
43 | scope(test)
44 | .include(dependency("org.jsoup", "jsoup", version(1,18,3)))
45 | .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,4)))
46 | .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,4)));
47 | scope(standalone)
48 | .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10", version(12,0,16)))
49 | .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", version(12,0,16)))
50 | .include(dependency("org.slf4j", "slf4j-simple", version(2,0,16)));
51 |
52 | precompileOperation().templateTypes(TemplateType.HTML);
53 | }
54 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/blueprints/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 |
6 | /**
7 | * Provides blueprints for project creation.
8 | * @since 1.5
9 | */
10 | package rife.bld.blueprints;
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/DependencyExclusion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import java.util.Objects;
8 |
9 | /**
10 | * Contains the information to describe a dependency exclusion.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.5
14 | */
15 | public record DependencyExclusion(String groupId, String artifactId) {
16 | public boolean equals(Object o) {
17 | if (this == o) return true;
18 | if (o == null || getClass() != o.getClass()) return false;
19 | DependencyExclusion that = (DependencyExclusion) o;
20 | return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId);
21 | }
22 |
23 | public int hashCode() {
24 | return Objects.hash(groupId, artifactId);
25 | }
26 |
27 | boolean matches(PomDependency dependency) {
28 | return ("*".equals(groupId()) && "*".equals(artifactId())) ||
29 | ("*".equals(groupId()) && artifactId().equals(dependency.artifactId())) ||
30 | (groupId().equals(dependency.groupId()) && "*".equals(artifactId())) ||
31 | (groupId().equals(dependency.groupId()) && dependency.artifactId().equals(artifactId()));
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/ExclusionSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import java.util.LinkedHashSet;
8 |
9 | /**
10 | * Convenience class to handle a set of {@link DependencyExclusion} objects.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.5
14 | */
15 | public class ExclusionSet extends LinkedHashSet {
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/LocalDependency.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | /**
8 | * Contains the information required to describe a local dependency for the build system.
9 | *
10 | * If the local dependency points to a directory, it will be scanned for jar files.
11 | *
12 | * @param path the file system path of the local dependency
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.2
15 | */
16 | public record LocalDependency(String path) {
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/LocalModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | /**
8 | * Contains the information required to describe a local module for the build system.
9 | *
10 | * If the local module points to a directory, it will be scanned for jar files.
11 | *
12 | * @param path the file system path of the local module
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 2.1
15 | */
16 | public record LocalModule(String path) {
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/MavenMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Provides Maven metadata information
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.5.8
14 | */
15 | public interface MavenMetadata {
16 | /**
17 | * Returns latest version in the metadata.
18 | *
19 | * @return the latest version
20 | * @since 1.5.8
21 | */
22 | Version getLatest();
23 |
24 | /**
25 | * Returns release version in the metadata.
26 | *
27 | * @return the release version
28 | * @since 1.5.8
29 | */
30 | Version getRelease();
31 |
32 | /**
33 | * Returns snapshot version in the metadata.
34 | *
35 | * @return the snapshot version
36 | * @since 1.5.8
37 | */
38 | Version getSnapshot();
39 |
40 | /**
41 | * Returns snapshot timestamp in the metadata.
42 | *
43 | * @return the snapshot timestamp
44 | * @since 1.5.8
45 | */
46 | String getSnapshotTimestamp();
47 |
48 | /**
49 | * Returns snapshot build number in the metadata.
50 | *
51 | * @return the snapshot build number
52 | * @since 1.5.8
53 | */
54 | Integer getSnapshotBuildNumber();
55 |
56 | /**
57 | * Returns all the release or snapshot versions in the metadata.
58 | *
59 | * @return the version list
60 | * @since 1.5.8
61 | */
62 | List getVersions();
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import java.util.regex.Pattern;
8 |
9 | /**
10 | * Contains the information required to describe a Java module dependency in the build system.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 2.1
14 | */
15 | public class Module extends Dependency {
16 | public Module(String groupId, String artifactId) {
17 | this(groupId, artifactId, null, null, null, null);
18 | }
19 |
20 | public Module(String groupId, String artifactId, Version version) {
21 | this(groupId, artifactId, version, null, null, null);
22 | }
23 |
24 | public Module(String groupId, String artifactId, Version version, String classifier) {
25 | this(groupId, artifactId, version, classifier, null, null);
26 | }
27 |
28 | public Module(String groupId, String artifactId, Version version, String classifier, ExclusionSet exclusions) {
29 | this(groupId, artifactId, version, classifier, exclusions, null);
30 | }
31 |
32 | public Module(String groupId, String artifactId, Version version, String classifier, ExclusionSet exclusions, Dependency parent) {
33 | super(groupId, artifactId, version, classifier, TYPE_MODULAR_JAR, exclusions, parent);
34 | }
35 |
36 | private static final Pattern MODULE_PATTERN = Pattern.compile("^(?[^:@]+):(?[^:@]+)(?::(?[^:@]+)(?::(?[^:@]+))?)?(?:@modular-jar)?$");
37 |
38 | /**
39 | * Parses a module from a string representation.
40 | * The format is {@code groupId:artifactId:version:classifier}.
41 | * The {@code version} and {@code classifier} are optional.
42 | *
43 | * If the string can't be successfully parsed, {@code null} will be returned.
44 | *
45 | * @param module the module string to parse
46 | * @return a parsed instance of {@code Module}; or
47 | * {@code null} when the string couldn't be parsed
48 | * @since 2.1
49 | */
50 | public static Module parse(String module) {
51 | if (module == null || module.isEmpty()) {
52 | return null;
53 | }
54 |
55 | var matcher = MODULE_PATTERN.matcher(module);
56 | if (!matcher.matches()) {
57 | return null;
58 | }
59 |
60 | var groupId = matcher.group("groupId");
61 | var artifactId = matcher.group("artifactId");
62 | var version = Version.parse(matcher.group("version"));
63 | var classifier = matcher.group("classifier");
64 |
65 | return new Module(groupId, artifactId, version, classifier);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/PomDependency.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import java.util.*;
8 |
9 | /**
10 | * Contains the information required to describe a dependency with all
11 | * the details stored in a Maven POM descriptor.
12 | *
13 | * This is used by the {@linkplain DependencyResolver} while traversing
14 | * the dependency graph, eventually resulting into fully resolved
15 | * {@linkplain Dependency} instances.
16 | *
17 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
18 | * @since 1.5
19 | */
20 | public record PomDependency(String groupId, String artifactId, String version, String classifier, String type,
21 | String scope, String optional, ExclusionSet exclusions, Dependency parent) {
22 | public boolean equals(Object o) {
23 | if (this == o) return true;
24 | if (o == null || getClass() != o.getClass()) return false;
25 | PomDependency that = (PomDependency) o;
26 | return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId) && Objects.equals(classifier, that.classifier) && Objects.equals(type, that.type);
27 | }
28 |
29 | boolean isPomImport() {
30 | return "pom".equals(type()) && "import".equals(scope());
31 | }
32 |
33 | Dependency convertToDependency() {
34 | return new Dependency(
35 | groupId(),
36 | artifactId(),
37 | Version.parse(version()),
38 | classifier(),
39 | type(),
40 | exclusions(),
41 | parent());
42 | }
43 |
44 | public int hashCode() {
45 | return Objects.hash(groupId, artifactId, classifier, type);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/RepositoryArtifact.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | /**
8 | * Represents an artifact location in a repository.
9 | *
10 | * @param repository the repository of the artifact
11 | * @param location the location of the artifact in the repository
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.6
14 | */
15 | public record RepositoryArtifact(Repository repository, String location) {
16 | public RepositoryArtifact appendPath(String path) {
17 | return new RepositoryArtifact(repository, location + path);
18 | }
19 |
20 | public String toString() {
21 | return repository + ":" + location;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/Scope.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | /**
8 | * Provides all the dependency scopes that are supported by
9 | * the bld build system.
10 | *
11 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
12 | * @since 1.5
13 | */
14 | public enum Scope {
15 | /**
16 | * Used for compiling the main source code.
17 | * @since 1.5
18 | */
19 | compile,
20 |
21 | /**
22 | * Used when running the main source code.
23 | * @since 1.5
24 | */
25 | runtime,
26 |
27 | /**
28 | * Used when compiling and running the test source code.
29 | * @since 1.5
30 | */
31 | test,
32 |
33 | /**
34 | * Used when running the main source code without container.
35 | * @since 1.5
36 | */
37 | standalone,
38 |
39 | /**
40 | * Provided by a container when running the main source code.
41 | * @since 1.5
42 | */
43 | provided
44 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/Version.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies;
6 |
7 | import static rife.bld.dependencies.VersionNumber.parseOrNull;
8 |
9 | /**
10 | * Represents the basic functionality of a dependency version.
11 | *
12 | * @since 2.0
13 | */
14 | public interface Version extends Comparable {
15 | /**
16 | * Parses a version from a string representation.
17 | *
18 | * If the string can't be successfully parsed as a semantic {@link VersionNumber},
19 | * it will be parsed as a {@link VersionGeneric}.
20 | *
21 | * @param version the version string to parse
22 | * @return the parsed version instance
23 | * @since 2.0
24 | */
25 | static Version parse(String version) {
26 | if (version == null || version.isEmpty()) {
27 | return VersionNumber.UNKNOWN;
28 | }
29 |
30 | var result = parseOrNull(version);
31 | if (result != null) {
32 | return result;
33 | }
34 |
35 | // bld doesn't support version ranges at this time
36 | if (version.startsWith("[") || version.startsWith("(")) {
37 | return VersionNumber.UNKNOWN;
38 | }
39 |
40 | return new VersionGeneric(version);
41 | }
42 |
43 | /**
44 | * Retrieves the qualifier of the version.
45 | *
46 | * @return this version's qualifier
47 | * @since 2.0
48 | */
49 | String qualifier();
50 |
51 | /**
52 | * Retrieves the version number with a different qualifier.
53 | *
54 | * @return this version number with a different qualifier
55 | * @since 2.0
56 | */
57 | Version withQualifier(String qualifier);
58 |
59 | /**
60 | * Indicates whether this is a snapshot version.
61 | *
62 | * @return {@code true} if this is a snapshot version; or
63 | * {@code false} otherwise
64 | * @since 2.0
65 | */
66 | boolean isSnapshot();
67 |
68 | @Override
69 | int compareTo(Version other);
70 |
71 | @Override
72 | String toString();
73 |
74 | @Override
75 | boolean equals(Object other);
76 |
77 | @Override
78 | int hashCode();
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/ArtifactNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies.exceptions;
6 |
7 | import rife.bld.dependencies.Dependency;
8 |
9 | import java.io.Serial;
10 |
11 | public class ArtifactNotFoundException extends DependencyException {
12 | @Serial private static final long serialVersionUID = 3137804373567469249L;
13 |
14 | private final Dependency dependency_;
15 | private final String location_;
16 |
17 | public ArtifactNotFoundException(Dependency dependency, String location) {
18 | super("Couldn't find artifact for dependency '" + dependency + "' at " + location);
19 |
20 | dependency_ = dependency;
21 | location_ = location;
22 | }
23 |
24 | public Dependency getDependency() {
25 | return dependency_;
26 | }
27 |
28 | public String getLocation() {
29 | return location_;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/ArtifactRetrievalErrorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies.exceptions;
6 |
7 | import rife.bld.dependencies.Dependency;
8 |
9 | import java.io.Serial;
10 |
11 | public class ArtifactRetrievalErrorException extends DependencyException {
12 | @Serial private static final long serialVersionUID = 5570184718213503548L;
13 |
14 | private final Dependency dependency_;
15 | private final String location_;
16 |
17 | public ArtifactRetrievalErrorException(Dependency dependency, String location, Throwable e) {
18 | super("Unexpected error while retrieving artifact for dependency '" + dependency + "' from '" + location + "'", e);
19 |
20 | dependency_ = dependency;
21 | location_ = location;
22 | }
23 |
24 | public Dependency getDependency() {
25 | return dependency_;
26 | }
27 |
28 | public String getLocation() {
29 | return location_;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/DependencyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies.exceptions;
6 |
7 | import java.io.Serial;
8 |
9 | public class DependencyException extends RuntimeException {
10 | @Serial private static final long serialVersionUID = 7683888067001718316L;
11 |
12 | public DependencyException(String message) {
13 | super(message);
14 | }
15 |
16 | public DependencyException(String message, Throwable cause) {
17 | super(message, cause);
18 | }
19 |
20 | public DependencyException(Throwable cause) {
21 | super(cause);
22 | }
23 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/DependencyTransferException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies.exceptions;
6 |
7 | import rife.bld.dependencies.Dependency;
8 |
9 | import java.io.File;
10 | import java.io.Serial;
11 |
12 | public class DependencyTransferException extends DependencyException {
13 | @Serial private static final long serialVersionUID = 2128741620203670830L;
14 |
15 | private final Dependency dependency_;
16 | private final String location_;
17 | private final File destination_;
18 |
19 | public DependencyTransferException(Dependency dependency, String location, File destination, Throwable e) {
20 | super("Unable to transfer dependency '" + dependency + "' from '" + location + "' into '" + destination + "'", e);
21 |
22 | dependency_ = dependency;
23 | location_ = location;
24 | destination_ = destination;
25 | }
26 |
27 | public DependencyTransferException(Dependency dependency, File destination, String message) {
28 | super("Unable to transfer dependency '" + dependency + "' into '" + destination + "': " + message);
29 |
30 | dependency_ = dependency;
31 | location_ = null;
32 | destination_ = destination;
33 | }
34 |
35 | public DependencyTransferException(Dependency dependency, String message) {
36 | super("Unable to transfer dependency '" + dependency + "': " + message);
37 |
38 | dependency_ = dependency;
39 | location_ = null;
40 | destination_ = null;
41 | }
42 |
43 | public Dependency getDependency() {
44 | return dependency_;
45 | }
46 |
47 | public String getLocation() {
48 | return location_;
49 | }
50 |
51 | public File getDestination() {
52 | return destination_;
53 | }
54 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/DependencyXmlParsingErrorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.dependencies.exceptions;
6 |
7 | import rife.bld.dependencies.Dependency;
8 | import rife.tools.StringUtils;
9 |
10 | import java.io.Serial;
11 | import java.util.Set;
12 |
13 | public class DependencyXmlParsingErrorException extends DependencyException {
14 | @Serial private static final long serialVersionUID = -1050469071912675264L;
15 |
16 | private final Dependency dependency_;
17 | private final String location_;
18 | private final Set errors_;
19 |
20 | public DependencyXmlParsingErrorException(Dependency dependency, String location, Set errors) {
21 | super("Unable to parse artifact document for dependency '" + dependency + "' from '" + location + "' :\n" + StringUtils.join(errors, "\n"));
22 |
23 | dependency_ = dependency;
24 | location_ = location;
25 | errors_ = errors;
26 | }
27 |
28 | public Dependency getDependency() {
29 | return dependency_;
30 | }
31 |
32 | public String getLocation() {
33 | return location_;
34 | }
35 |
36 | public Set getErrors() {
37 | return errors_;
38 | }
39 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/exceptions/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 |
6 | /**
7 | * Provides exception classes build system dependency handling.
8 | * @since 1.5
9 | */
10 | package rife.bld.dependencies.exceptions;
--------------------------------------------------------------------------------
/src/main/java/rife/bld/dependencies/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 |
6 | /**
7 | * Provides functionalities to resolve and retrieve dependency artifacts.
8 | * @since 1.5
9 | */
10 | package rife.bld.dependencies;
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CleanHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the clean command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class CleanHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Cleans the build files";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Cleans the build files.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CompileHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the compile command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class CompileHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Compiles the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Compiles the project.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CreateAppHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the create-app command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.9
15 | */
16 | public class CreateAppHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a new Java application project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a new Java application project.
24 |
25 | Usage : ${topic}
26 | package The package of the project to create
27 | name The name of the project to create
28 | base The base name for generated project classes""", "${topic}", topic);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CreateBaseHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the create-base command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.20
15 | */
16 | public class CreateBaseHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a new Java baseline project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a new Java baseline project.
24 |
25 | Usage : ${topic}
26 | package The package of the project to create
27 | name The name of the project to create
28 | base The base name for generated project classes""", "${topic}", topic);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CreateHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the create command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.7
15 | */
16 | public class CreateHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a new project from multiple choice";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a new project from multiple choice.
24 |
25 | Usage : ${topic}
26 | type The type of project to create (app, base, lib, rife2)
27 | package The package of the project to create
28 | name The name of the project to create
29 | base The base name for generated project classes""", "${topic}", topic);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CreateLibHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the create-lib command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.6
15 | */
16 | public class CreateLibHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a new Java library project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a new Java library project.
24 |
25 | Usage : ${topic}
26 | package The package of the project to create
27 | name The name of the project to create
28 | base The base name for generated project classes""", "${topic}", topic);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/CreateRife2Help.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the create-rife2 command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class CreateRife2Help implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a new RIFE2 web application project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a new RIFE2 web application project.
24 |
25 | Usage : ${topic}
26 | package The package of the project to create
27 | name The name of the project to create
28 | base The base name for generated project classes""", "${topic}", topic);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/DependencyTreeHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the dependency tree command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.21
15 | */
16 | public class DependencyTreeHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Outputs the dependency tree of the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Outputs the dependency tree of the project
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/DownloadHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the download command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class DownloadHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Downloads all dependencies of the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Downloads all dependencies of the project
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/HelpHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 |
9 | /**
10 | * Provides help for the help command.
11 | *
12 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
13 | * @since 1.5
14 | */
15 | public class HelpHelp implements CommandHelp {
16 | public String getSummary() {
17 | return "Provides help about any of the other commands";
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/JUnitHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the JUnit test command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.20
15 | */
16 | public class JUnitHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Tests the project with JUnit (takes options)";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Tests the project with JUnit.
24 |
25 | Additional JUnit console launcher options can be
26 | provided after the command.
27 |
28 | These commandline options are provided by this command:
29 | --junit-help see the full list of JUnit launcher options
30 | --junit-clear clear the JUnit launcher options the build uses
31 | (needs to be provided before other options)
32 |
33 | Usage : ${topic} [OPTIONS]""", "${topic}", topic);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/JarHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the jar command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class JarHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a jar archive for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a jar archive for the project.
24 | The standard jar command will automatically also execute
25 | the compile and precompile commands beforehand.
26 |
27 | Usage : ${topic}""", "${topic}", topic);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/JarJavadocHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the jar-javadoc command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.10
15 | */
16 | public class JarJavadocHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a javadoc jar archive for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a javadoc jar archive for the project.
24 | The standard jar-javadoc command will automatically also execute
25 | the compile and javadoc commands beforehand.
26 |
27 | Usage : ${topic}""", "${topic}", topic);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/JarSourcesHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the jar-sources command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.10
15 | */
16 | public class JarSourcesHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a sources jar archive for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a sources jar archive for the project.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/JavadocHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the javadoc command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.10
15 | */
16 | public class JavadocHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Generates javadoc for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Generates javadoc for the project.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/PrecompileHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the precompile command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class PrecompileHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Pre-compiles RIFE2 templates to class files";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Pre-compiles RIFE2 templates to class files
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/PublishHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the publish command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.7
15 | */
16 | public class PublishHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Publishes the artifacts of your project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Publishes the artifacts of the project to the publication
24 | repository.
25 | The standard publish command will automatically also execute
26 | the jar, jar-sources and jar-javadoc commands beforehand.
27 |
28 | Usage : ${topic}""", "${topic}", topic);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/PublishLocalHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the publish-local command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.7
15 | */
16 | public class PublishLocalHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Publishes to the local maven repository";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Publishes the artifacts of the project to local maven repository,
24 | regardless of the repositories that are set up in your publish
25 | operation.
26 |
27 | The standard publish-local command will automatically also execute
28 | the jar, jar-sources and jar-javadoc commands beforehand.
29 |
30 | Usage : ${topic}""", "${topic}", topic);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/PublishWebHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the publish web command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.7
15 | */
16 | public class PublishWebHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Publishes the artifacts of your web project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Publishes the artifacts of the web project to the publication
24 | repository.
25 | The standard web publish command will automatically also execute
26 | the jar, jar-sources, jar-javadoc, uberjar and war commands
27 | beforehand.
28 |
29 | Usage : ${topic}""", "${topic}", topic);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/PurgeHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the purge command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class PurgeHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Purges all unused artifacts from the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Purges all the unused dependency artifacts from the project
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/RunHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.bld.operations.RunOperation;
9 |
10 | /**
11 | * Provides help for the run command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class RunHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Runs the project (take option)";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return String.format("""
23 | Runs the project.
24 |
25 | Usage : %s [%sARG...]""", topic, RunOperation.ARGS_OPTION);
26 | }
27 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/TestHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the test command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class TestHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Tests the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Tests the project.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/UberJarHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the uberjar command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class UberJarHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates an UberJar archive for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates an UberJar archive for the project.
24 | The standard uberjar command will automatically also execute
25 | the jar command beforehand.
26 |
27 | Usage : ${topic}""", "${topic}", topic);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/UpdatesHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the updates command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class UpdatesHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Checks for updates of the project dependencies";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Checks which updates are available for the project dependencies.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/UpgradeHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the upgrade command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class UpgradeHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Upgrades the bld wrapper to the latest version";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Upgrades the bld wrapper to the latest version.
24 | This command should be executed in the root directory of
25 | your project.
26 |
27 | Usage : ${topic}""", "${topic}", topic);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/VersionHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the version command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5.2
15 | */
16 | public class VersionHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Outputs the version of the build system";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Outputs the version of the build system.
24 |
25 | Usage : ${topic}""", "${topic}", topic);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/WarHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.help;
6 |
7 | import rife.bld.CommandHelp;
8 | import rife.tools.StringUtils;
9 |
10 | /**
11 | * Provides help for the war command.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 1.5
15 | */
16 | public class WarHelp implements CommandHelp {
17 | public String getSummary() {
18 | return "Creates a war archive for the project";
19 | }
20 |
21 | public String getDescription(String topic) {
22 | return StringUtils.replace("""
23 | Creates a war archive for the project.
24 | The standard war command will automatically also execute
25 | the jar command beforehand.
26 |
27 | Usage : ${topic}""", "${topic}", topic);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/help/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 |
6 | /**
7 | * Provides help texts for build commands.
8 | * @since 1.5
9 | */
10 | package rife.bld.help;
--------------------------------------------------------------------------------
/src/main/java/rife/bld/instrument/ModuleMainClassAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.instrument;
6 |
7 | import rife.asm.*;
8 |
9 | /**
10 | * This utility class will modify a Java module {@code module-info.class} to add
11 | * a module main class to its attributes.
12 | *
13 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
14 | * @since 2.1
15 | */
16 | public class ModuleMainClassAdapter extends ClassVisitor implements Opcodes {
17 | private final String mainClass_;
18 |
19 | /**
20 | * Performs the actual modification of the module info class's bytecode.
21 | *
22 | * @param origBytes the bytes of the module class that should be modified
23 | * @param mainClass the main class of the module
24 | * @return the modified bytes
25 | * @since 2.1
26 | */
27 | public static byte[] addModuleMainClassToBytes(byte[] origBytes, String mainClass) {
28 | var cw = new ClassWriter(0);
29 | new ClassReader(origBytes).accept(new ModuleMainClassAdapter(mainClass, cw), 0);
30 | return cw.toByteArray();
31 | }
32 |
33 | private ModuleMainClassAdapter(String mainClass, ClassVisitor writer) {
34 | super(ASM9, writer);
35 | mainClass_ = mainClass.replace('.', '/');
36 | }
37 |
38 | @Override
39 | public ModuleVisitor visitModule(String name, int access, String version) {
40 | var module_visitor = super.visitModule(name, access, version);
41 | module_visitor.visitMainClass(mainClass_);
42 | return module_visitor;
43 | }
44 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/instrument/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 |
6 | /**
7 | * Provides functionalities for bytecode instrumentation.
8 | * @since 2.1
9 | */
10 | package rife.bld.instrument;
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/AbstractOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | /**
8 | * Provides common features across all operations
9 | *
10 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
11 | * @since 1.5.2
12 | */
13 | public abstract class AbstractOperation> {
14 | private boolean silent_ = false;
15 | private boolean executed_ = false;
16 |
17 | /**
18 | * Changes whether the operation should be silent or not.
19 | *
20 | * Defaults to not silent.
21 | *
22 | * @param silent {@code true} if the operation should be silent;
23 | * {@code false} otherwise
24 | * @return this operation instance
25 | * @since 1.5.2
26 | */
27 | public T silent(boolean silent) {
28 | silent_ = silent;
29 | return (T) this;
30 | }
31 |
32 | /**
33 | * Indicates whether the operation should be silent or not.
34 | *
35 | * @return {@code true} if the operation should be silent;
36 | * {@code false} otherwise
37 | * @since 1.5.2
38 | */
39 | public boolean silent() {
40 | return silent_;
41 | }
42 |
43 | /**
44 | * Ensures that this operation instance is executed once and only once.
45 | *
46 | * @throws Exception when an exception was thrown by the {@link #execute()} call
47 | * @see #executeOnce(Runnable)
48 | * @since 1.5.17
49 | */
50 | public void executeOnce()
51 | throws Exception {
52 | executeOnce(null);
53 | }
54 |
55 | /**
56 | * Ensures that this operation instance is executed once and only once.
57 | *
58 | * A setup lambda can be provided that is called when the only execution takes place.
59 | *
60 | * @param setup the setup lambda that will be called with the only execution
61 | * @throws Exception when an exception was thrown by the {@link #execute()} call
62 | * @see #executeOnce()
63 | * @since 1.5.17
64 | */
65 | public void executeOnce(Runnable setup)
66 | throws Exception {
67 | if (executed_) {
68 | return;
69 | }
70 | executed_ = true;
71 |
72 | if (setup != null) {
73 | setup.run();
74 | }
75 | execute();
76 | }
77 |
78 | /**
79 | * Performs the operation execution that can be wrapped by the {@code #executeOnce} call.
80 | *
81 | * @throws Exception when an exception occurs during the execution
82 | * @since 1.5.10
83 | */
84 | public abstract void execute()
85 | throws Exception;
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/CleanOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.BaseProject;
8 | import rife.tools.FileUtils;
9 | import rife.tools.exceptions.FileUtilsErrorException;
10 |
11 | import java.io.File;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * Cleans by deleting a list of directories and all their contents.
17 | *
18 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
19 | * @since 1.5
20 | */
21 | public class CleanOperation extends AbstractOperation {
22 | private final List directories_ = new ArrayList<>();
23 |
24 | /**
25 | * Performs the clean operation.
26 | *
27 | * @since 1.5
28 | */
29 | public void execute() {
30 | for (var directory : directories()) {
31 | executeCleanDirectory(directory);
32 | }
33 | if (!silent()) {
34 | System.out.println("Cleaning finished successfully.");
35 | }
36 | }
37 |
38 | /**
39 | * Part of the {@link #execute} operation, cleans an individual directory.
40 | *
41 | * @param directory the directory to clean.
42 | * @since 1.5
43 | */
44 | protected void executeCleanDirectory(File directory) {
45 | try {
46 | FileUtils.deleteDirectory(directory);
47 | } catch (FileUtilsErrorException e) {
48 | // no-op
49 | }
50 | }
51 |
52 | /**
53 | * Configures a clean operation from a {@link BaseProject}.
54 | *
55 | * @param project the project to configure the clean operation from
56 | * @since 1.5
57 | */
58 | public CleanOperation fromProject(BaseProject project) {
59 | return directories(project.buildDirectory()
60 | .listFiles(f -> !f.equals(project.buildBldDirectory())));
61 | }
62 |
63 | /**
64 | * Provides directories to clean.
65 | *
66 | * @param directories directories to clean
67 | * @return this operation instance
68 | * @since 1.5.18
69 | */
70 | public CleanOperation directories(File... directories) {
71 | directories_.addAll(List.of(directories));
72 | return this;
73 | }
74 |
75 | /**
76 | * Provides a list of directories to clean.
77 | *
78 | * A copy will be created to allow this list to be independently modifiable.
79 | *
80 | * @param directories a list of directories to clean
81 | * @return this operation instance
82 | * @since 1.5
83 | */
84 | public CleanOperation directories(List directories) {
85 | directories_.addAll(directories);
86 | return this;
87 | }
88 |
89 | /**
90 | * Retrieves the list of directories to clean.
91 | *
92 | * This is a modifiable list that can be retrieved and changed.
93 | *
94 | * @return the list of directories to clean.
95 | * @since 1.5
96 | */
97 | public List directories() {
98 | return directories_;
99 | }
100 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/CreateAppOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.blueprints.AppProjectBlueprint;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * Creates a new app project structure.
14 | *
15 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
16 | * @since 1.9
17 | */
18 | public class CreateAppOperation extends AbstractCreateOperation {
19 | public CreateAppOperation() {
20 | super("bld.app.");
21 | }
22 |
23 | protected Project createProjectBlueprint() {
24 | return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/CreateBaseOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.blueprints.BaseProjectBlueprint;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * Creates a new base project structure.
14 | *
15 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
16 | * @since 1.5.20
17 | */
18 | public class CreateBaseOperation extends AbstractCreateOperation {
19 | public CreateBaseOperation() {
20 | super("bld.base.");
21 | }
22 |
23 | protected Project createProjectBlueprint() {
24 | return new BaseProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/CreateLibOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.Project;
8 | import rife.bld.blueprints.LibProjectBlueprint;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * Creates a new lib project structure.
14 | *
15 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
16 | * @since 1.6
17 | */
18 | public class CreateLibOperation extends AbstractCreateOperation {
19 | public CreateLibOperation() {
20 | super("bld.lib.");
21 | }
22 |
23 | protected Project createProjectBlueprint() {
24 | return new LibProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), baseName());
25 | }
26 |
27 | protected boolean createIdeaRunMain() {
28 | return false;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/CreateOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.operations.exceptions.OperationOptionException;
8 |
9 | import java.io.File;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * Creates a new project structure
15 | *
16 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
17 | * @since 1.7
18 | */
19 | public class CreateOperation {
20 |
21 | private static final String BASE = "base";
22 | private static final String APP = "app";
23 | private static final String LIB = "lib";
24 | private static final String RIFE2 = "rife2";
25 |
26 | /**
27 | * Configures a creation operation from command-line arguments.
28 | *
29 | * @param arguments the arguments that will be considered
30 | * @return this operation instance
31 | * @since 1.7
32 | */
33 | public AbstractCreateOperation, ?> fromArguments(List arguments) {
34 | String type = null;
35 | String package_name = null;
36 | String project_name = null;
37 | String base_name = null;
38 | if (!arguments.isEmpty()) {
39 | type = arguments.remove(0);
40 | }
41 |
42 | var create_operation_args = new ArrayList();
43 | if (!arguments.isEmpty()) {
44 | package_name = arguments.remove(0);
45 | create_operation_args.add(package_name);
46 | }
47 | if (!arguments.isEmpty()) {
48 | project_name = arguments.remove(0);
49 | create_operation_args.add(project_name);
50 | }
51 | if (!arguments.isEmpty()) {
52 | base_name = arguments.remove(0);
53 | create_operation_args.add(base_name);
54 | }
55 | if ((package_name == null || project_name == null || base_name == null) && System.console() == null) {
56 | throw new OperationOptionException("ERROR: Expecting the package, project and base names as the arguments.");
57 | }
58 |
59 | if (type == null || type.isBlank()) {
60 | System.out.println("Please enter a number for the project type:");
61 | System.out.printf(" 1: %s (Java baseline project)%n", BASE);
62 | System.out.printf(" 2: %s (Java application project)%n", APP);
63 | System.out.printf(" 3: %s (Java library project)%n", LIB);
64 | System.out.printf(" 4: %s (RIFE2 web application)%n", RIFE2);
65 | var number = System.console().readLine();
66 | switch (Integer.parseInt(number)) {
67 | case 1 -> type = BASE;
68 | case 2 -> type = APP;
69 | case 3 -> type = LIB;
70 | case 4 -> type = RIFE2;
71 | }
72 | } else {
73 | System.out.println("Using project type: " + type);
74 | }
75 | if (type == null) {
76 | throw new OperationOptionException("ERROR: Expecting the project type.");
77 | }
78 |
79 | AbstractCreateOperation, ?> create_operation = null;
80 | switch (type) {
81 | case BASE -> create_operation = new CreateBaseOperation();
82 | case APP -> create_operation = new CreateAppOperation();
83 | case LIB -> create_operation = new CreateLibOperation();
84 | case RIFE2 -> create_operation = new CreateRife2Operation();
85 | }
86 | if (create_operation == null) {
87 | throw new OperationOptionException("ERROR: Unsupported project type.");
88 | }
89 |
90 | return create_operation.fromArguments(create_operation_args);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/JlinkOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | /**
12 | * Create run-time images using the jlink tool.
13 | *
14 | * @author Erik C. Thauvin
15 | * @since 2.1.0
16 | */
17 | public class JlinkOperation extends AbstractToolProviderOperation {
18 | private final List disabledPlugins_ = new ArrayList<>();
19 | private final JlinkOptions jlinkOptions_ = new JlinkOptions();
20 |
21 | public JlinkOperation() {
22 | super("jlink");
23 | }
24 |
25 | /**
26 | * Disable the plugin(s) mentioned.
27 | *
28 | * @param plugins the plugin name(s)
29 | * @return this map of options
30 | */
31 | public JlinkOperation disablePlugin(List plugins) {
32 | disabledPlugins_.addAll(plugins);
33 | return this;
34 | }
35 |
36 | /**
37 | * Disable the plugin(s) mentioned.
38 | *
39 | * @param plugins the plugin name(s)
40 | * @return this map of options
41 | */
42 | public JlinkOperation disablePlugin(String... plugins) {
43 | return disablePlugin(List.of(plugins));
44 | }
45 |
46 | @Override
47 | public void execute() throws Exception {
48 | toolArgsFromFiles();
49 | disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
50 | toolArgs(jlinkOptions_);
51 | super.execute();
52 | }
53 |
54 | /**
55 | * Provides a list of options to provide to the jlink tool.
56 | *
57 | * A copy will be created to allow this list to be independently modifiable.
58 | *
59 | * @param options the argument-value pairs
60 | * @return this operation instance
61 | */
62 | public JlinkOperation jlinkOptions(Map options) {
63 | jlinkOptions_.putAll(options);
64 | return this;
65 | }
66 |
67 | /**
68 | * Retrieves the list of options for the jlink tool.
69 | *
70 | * This is a modifiable list that can be retrieved and changed.
71 | *
72 | * @return the map of jlink options
73 | */
74 | public JlinkOptions jlinkOptions() {
75 | return jlinkOptions_;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/TemplateType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import java.io.Serial;
8 | import java.io.Serializable;
9 |
10 | /**
11 | * Allows template types to be specified for pre-compilation.
12 | */
13 | public class TemplateType implements Serializable {
14 | @Serial private static final long serialVersionUID = -2736320275307140837L;
15 |
16 | /**
17 | * The {@code html} template type.
18 | */
19 | public static TemplateType HTML = new TemplateType("html");
20 | /**
21 | * The {@code json} template type.
22 | */
23 | public static TemplateType JSON = new TemplateType("json");
24 | /**
25 | * The {@code svg} template type.
26 | */
27 | public static TemplateType SVG = new TemplateType("svg");
28 | /**
29 | * The {@code xml} template type.
30 | */
31 | public static TemplateType XML = new TemplateType("xml");
32 | /**
33 | * The {@code txt} template type.
34 | */
35 | public static TemplateType TXT = new TemplateType("txt");
36 | /**
37 | * The {@code sql} template type.
38 | */
39 | public static TemplateType SQL = new TemplateType("sql");
40 |
41 | private final String identifier_;
42 |
43 | /**
44 | * Creates a new template type instance.
45 | *
46 | * @param identifier the identifier of this template type
47 | */
48 | public TemplateType(String identifier) {
49 | identifier_ = identifier;
50 | }
51 |
52 | /**
53 | * Retrieves the identifier for this template type
54 | * @return the template type identifier as a string
55 | */
56 | public String identifier() {
57 | return identifier_;
58 | }
59 | }
--------------------------------------------------------------------------------
/src/main/java/rife/bld/operations/TestOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
3 | * Licensed under the Apache License, Version 2.0 (the "License")
4 | */
5 | package rife.bld.operations;
6 |
7 | import rife.bld.BaseProject;
8 | import rife.tools.FileUtils;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * Tests a Java application.
15 | *
16 | * @author Geert Bevin (gbevin[remove] at uwyn dot com)
17 | * @since 1.5
18 | */
19 | public class TestOperation, O extends List> extends AbstractProcessOperation {
20 | protected final O testToolOptions_;
21 |
22 | /**
23 | * Instantiates a new test operation.
24 | * @since 1.5.20
25 | */
26 | public TestOperation() {
27 | testToolOptions_ = createTestToolOptions();
28 | }
29 |
30 | /**
31 | * Creates a new collection of test tool options.
32 | *
33 | * @return the test tool options to use
34 | * @since 1.5.20
35 | */
36 | protected O createTestToolOptions() {
37 | return (O)new ArrayList();
38 | }
39 |
40 | /**
41 | * Part of the {@link #execute} operation, constructs the command list
42 | * to use for building the process.
43 | *
44 | * @since 1.5
45 | */
46 | protected List executeConstructProcessCommandList() {
47 | if (mainClass() == null) {
48 | throw new IllegalArgumentException("ERROR: Missing main class for test execution.");
49 | }
50 |
51 | var args = new ArrayList();
52 | args.add(javaTool());
53 | args.addAll(javaOptions());
54 | if (!classpath().isEmpty()) {
55 | args.add("-cp");
56 | args.add(FileUtils.joinPaths(classpath()));
57 | }
58 | if (!modulePath().isEmpty()) {
59 | args.add("-p");
60 | args.add(FileUtils.joinPaths(modulePath()));
61 | }
62 | args.add(mainClass());
63 | args.addAll(testToolOptions());
64 |
65 | return args;
66 | }
67 |
68 | /**
69 | * Configures a test operation from a {@link BaseProject}.
70 | *
71 | * @param project the project to configure the test operation from
72 | * @since 1.5
73 | */
74 | public T fromProject(BaseProject project) {
75 | var operation = workDirectory(project.workDirectory())
76 | .javaTool(project.javaTool())
77 | .classpath(project.testClasspath())
78 | .modulePath(project.testModulePath());
79 | if (project.usesRife2Agent()) {
80 | operation.javaOptions().javaAgent(project.getRife2AgentFile());
81 | }
82 | return operation;
83 | }
84 |
85 | /**
86 | * Provides options to provide to the test tool.
87 | *
88 | * @param options test tool options
89 | * @return this operation instance
90 | * @since 1.5.18
91 | */
92 | public T testToolOptions(String... options) {
93 | testToolOptions_.addAll(List.of(options));
94 | return (T)this;
95 | }
96 |
97 | /**
98 | * Provides options to provide to the test tool.
99 | *