|
@@ -1,116 +1,116 @@ |
1 |
|
- |
import java.io.*; |
2 |
|
- |
import org.litesoft.core.typeutils.Objects; |
3 |
|
- |
import java.util.*; |
4 |
|
- |
|
5 |
|
- |
import com.esotericsoftware.scar.*; |
6 |
|
- |
|
7 |
|
- |
import static com.esotericsoftware.minlog.Log.*; |
8 |
|
- |
|
9 |
|
- |
public class Builder |
10 |
|
- |
{ |
11 |
|
- |
// Magic Property Values: |
12 |
|
- |
|
13 |
|
- |
private static final String NAME = "name"; //. . . . . . . . . The name of the project. Used to name the JAR. Default: The name of the directory containing the project YAML file. |
14 |
|
- |
private static final String TARGET = "target"; //. . . . . . . The directory to output build artifacts. Default: The directory containing the project YAML file, plus "../target/name". |
15 |
|
- |
private static final String VERSION = "version"; //. . . . . . The version of the project. If available, used to name the JAR. Default: blank |
16 |
|
- |
private static final String RESOURCES = "resources"; //. . . . Wildcard patterns for the files to include in the JAR. Default: resources and src/main/resources. |
17 |
|
- |
private static final String DIST = "dist"; //. . . . . . . . . Wildcard patterns for the files to include in the distribution, outside the JAR. Default: dist. |
18 |
|
- |
private static final String SOURCE = "source"; //. . . . . . . Wildcard patterns for the Java files to compile. Default: src **/*.java and src/main/java **/*.java. |
19 |
|
- |
private static final String CLASSPATH = "classpath"; //. . . . Wildcard patterns for the files to include on the classpath. Default: lib **/*.jar. |
20 |
|
- |
private static final String DEPENDENCIES = "dependencies"; //. Relative or absolute paths to dependency project directories or YAML files. Default: blank |
21 |
|
- |
private static final String INCLUDE = "include"; //. . . . . . Relative or absolute paths to project files to inherit properties from. Default: blank |
22 |
|
- |
private static final String MAIN = "main"; //. . . . . . . . . Name of the main class. Default: blank |
23 |
|
- |
|
24 |
|
- |
private static final String DEPENDS = "depends"; //. . . . . . List of "Functional" dependencies (e.g. litesoft). Default: blank |
25 |
|
- |
private static final String DEV_ROOT_DIR = "DevRootDir"; //. . Relative Path to the Dev Root Dir (where litesoft and zGlobal) can be found. Default: blank Only required if "depends"="litesoft" / mode="GWT" is specified. |
26 |
|
- |
private static final String MODE = "mode"; //. . . . . . . . . Mode of this Project. Default: JAR for options, see below... |
27 |
|
- |
// Mode options are (case ignored): |
28 |
|
- |
// JAR - package this project into a regular JAR |
29 |
|
- |
// 1JAR - package this project into a Single JAR (including the contents of all the dependant JARs) |
30 |
|
- |
// Web - package this project into a WAR folder |
31 |
|
- |
// War - package this project into a WAR file (Web implied) |
32 |
|
- |
// GWT(xxx) - package this project into a WAR file, AND include the GWT support code. The "xxx" indicates the path and name of the xxx.gwt.xml file. |
33 |
|
- |
// After the closing ')' you can optionally specify one from each (comma separated) of the following groups (first listed is the default): |
34 |
|
- |
// LogLevel: Style: |
35 |
|
- |
// WARN OBF |
36 |
|
- |
// DEBUG PRETTY |
37 |
|
- |
// DETAIL |
38 |
|
- |
// a full GWT example: |
39 |
|
- |
// |
40 |
|
- |
// mode=GWT(org.sample.MyGwtApplication)Debug,Detail |
41 |
|
- |
|
42 |
|
- |
private boolean mBuilt = false; |
43 |
|
- |
private Builder mParent = null; |
44 |
|
- |
private List<Builder> mDependents = new ArrayList<Builder>(); |
45 |
|
- |
private Project mProject = new Project(); |
46 |
|
- |
private String mName; |
47 |
|
- |
|
48 |
|
- |
public Builder( Builder pParent, String pYamlPath ) |
49 |
|
- |
throws IOException |
50 |
|
- |
{ |
51 |
|
- |
mParent = pParent; |
52 |
|
- |
mProject.load( pYamlPath ); |
53 |
|
- |
mName = forceName(); |
54 |
|
- |
processProject(); |
55 |
|
- |
} |
56 |
|
- |
|
57 |
|
- |
private void processProject() |
58 |
|
- |
{ |
59 |
|
- |
//To change body of created methods use File | Settings | File Templates. |
60 |
|
- |
} |
61 |
|
- |
|
62 |
|
- |
private String forceName() |
63 |
|
- |
{ |
64 |
|
- |
String zName = mProject.get( NAME, "" ).trim(); |
65 |
|
- |
if ( zName.length() == 0 ) |
66 |
|
- |
{ |
67 |
|
- |
zName = new File( mProject.getDirectory() ).getName(); |
68 |
|
- |
mProject.set( NAME, zName ); |
69 |
|
- |
} |
70 |
|
- |
return zName; |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
public void build() |
74 |
|
- |
{ |
75 |
|
- |
for ( Builder zDependent : mDependents ) |
76 |
|
- |
{ |
77 |
|
- |
zDependent.build(); |
78 |
|
- |
} |
79 |
|
- |
System.out.println( "build: " + mName ); |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
public static void main( String[] args ) |
83 |
|
- |
throws IOException |
84 |
|
- |
{ |
85 |
|
- |
Scar.args = new Arguments( args ); |
86 |
|
- |
|
87 |
|
- |
if ( Scar.args.has( "trace" ) ) |
88 |
|
- |
{ |
89 |
|
- |
TRACE(); |
90 |
|
- |
} |
91 |
|
- |
else if ( Scar.args.has( "debug" ) ) |
92 |
|
- |
{ |
93 |
|
- |
DEBUG(); |
94 |
|
- |
} |
95 |
|
- |
else if ( Scar.args.has( "info" ) ) |
96 |
|
- |
{ |
97 |
|
- |
INFO(); |
98 |
|
- |
} |
99 |
|
- |
else if ( Scar.args.has( "warn" ) ) |
100 |
|
- |
{ |
101 |
|
- |
WARN(); |
102 |
|
- |
} |
103 |
|
- |
else if ( Scar.args.has( "error" ) ) // |
104 |
|
- |
{ |
105 |
|
- |
ERROR(); |
106 |
|
- |
} |
107 |
|
- |
|
108 |
|
- |
new Builder( null, Scar.args.get( "file", "." ) ).build(); |
109 |
|
- |
} |
110 |
|
- |
|
111 |
|
- |
@Override |
112 |
|
- |
public String toString() |
113 |
|
- |
{ |
114 |
|
- |
return "Project: " + mName; |
115 |
|
- |
} |
116 |
|
- |
} |
|
1 |
+ |
import java.io.*; |
|
2 |
+ |
import org.litesoft.core.typeutils.Objects; |
|
3 |
+ |
import java.util.*; |
|
4 |
+ |
|
|
5 |
+ |
import com.esotericsoftware.scar.*; |
|
6 |
+ |
|
|
7 |
+ |
import static com.esotericsoftware.minlog.Log.*; |
|
8 |
+ |
|
|
9 |
+ |
public class Builder |
|
10 |
+ |
{ |
|
11 |
+ |
// Magic Property Values: |
|
12 |
+ |
|
|
13 |
+ |
private static final String NAME = "name"; //. . . . . . . . . The name of the project. Used to name the JAR. Default: The name of the directory containing the project YAML file. |
|
14 |
+ |
private static final String TARGET = "target"; //. . . . . . . The directory to output build artifacts. Default: The directory containing the project YAML file, plus "../target/name". |
|
15 |
+ |
private static final String VERSION = "version"; //. . . . . . The version of the project. If available, used to name the JAR. Default: blank |
|
16 |
+ |
private static final String RESOURCES = "resources"; //. . . . Wildcard patterns for the files to include in the JAR. Default: resources and src/main/resources. |
|
17 |
+ |
private static final String DIST = "dist"; //. . . . . . . . . Wildcard patterns for the files to include in the distribution, outside the JAR. Default: dist. |
|
18 |
+ |
private static final String SOURCE = "source"; //. . . . . . . Wildcard patterns for the Java files to compile. Default: src **/*.java and src/main/java **/*.java. |
|
19 |
+ |
private static final String CLASSPATH = "classpath"; //. . . . Wildcard patterns for the files to include on the classpath. Default: lib **/*.jar. |
|
20 |
+ |
private static final String DEPENDENCIES = "dependencies"; //. Relative or absolute paths to dependency project directories or YAML files. Default: blank |
|
21 |
+ |
private static final String INCLUDE = "include"; //. . . . . . Relative or absolute paths to project files to inherit properties from. Default: blank |
|
22 |
+ |
private static final String MAIN = "main"; //. . . . . . . . . Name of the main class. Default: blank |
|
23 |
+ |
|
|
24 |
+ |
private static final String DEPENDS = "depends"; //. . . . . . List of "Functional" dependencies (e.g. litesoft). Default: blank |
|
25 |
+ |
private static final String DEV_ROOT_DIR = "DevRootDir"; //. . Relative Path to the Dev Root Dir (where litesoft and zGlobal) can be found. Default: blank Only required if "depends"="litesoft" / mode="GWT" is specified. |
|
26 |
+ |
private static final String MODE = "mode"; //. . . . . . . . . Mode of this Project. Default: JAR for options, see below... |
|
27 |
+ |
// Mode options are (case ignored): |
|
28 |
+ |
// JAR - package this project into a regular JAR |
|
29 |
+ |
// 1JAR - package this project into a Single JAR (including the contents of all the dependant JARs) |
|
30 |
+ |
// Web - package this project into a WAR folder |
|
31 |
+ |
// War - package this project into a WAR file (Web implied) |
|
32 |
+ |
// GWT(xxx) - package this project into a WAR file, AND include the GWT support code. The "xxx" indicates the path and name of the xxx.gwt.xml file. |
|
33 |
+ |
// After the closing ')' you can optionally specify one from each (comma separated) of the following groups (first listed is the default): |
|
34 |
+ |
// LogLevel: Style: |
|
35 |
+ |
// WARN OBF |
|
36 |
+ |
// DEBUG PRETTY |
|
37 |
+ |
// DETAIL |
|
38 |
+ |
// a full GWT example: |
|
39 |
+ |
// |
|
40 |
+ |
// mode=GWT(org.sample.MyGwtApplication)Debug,Detail |
|
41 |
+ |
|
|
42 |
+ |
private boolean mBuilt = false; |
|
43 |
+ |
private Builder mParent = null; |
|
44 |
+ |
private List<Builder> mDependents = new ArrayList<Builder>(); |
|
45 |
+ |
private Project mProject = new Project(); |
|
46 |
+ |
private String mName; |
|
47 |
+ |
|
|
48 |
+ |
public Builder( Builder pParent, String pYamlPath ) |
|
49 |
+ |
throws IOException |
|
50 |
+ |
{ |
|
51 |
+ |
mParent = pParent; |
|
52 |
+ |
mProject.load( pYamlPath ); |
|
53 |
+ |
mName = forceName(); |
|
54 |
+ |
processProject(); |
|
55 |
+ |
} |
|
56 |
+ |
|
|
57 |
+ |
private void processProject() |
|
58 |
+ |
{ |
|
59 |
+ |
//To change body of created methods use File | Settings | File Templates. |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
private String forceName() |
|
63 |
+ |
{ |
|
64 |
+ |
String zName = mProject.get( NAME, "" ).trim(); |
|
65 |
+ |
if ( zName.length() == 0 ) |
|
66 |
+ |
{ |
|
67 |
+ |
zName = new File( mProject.getDirectory() ).getName(); |
|
68 |
+ |
mProject.set( NAME, zName ); |
|
69 |
+ |
} |
|
70 |
+ |
return zName; |
|
71 |
+ |
} |
|
72 |
+ |
|
|
73 |
+ |
public void build() |
|
74 |
+ |
{ |
|
75 |
+ |
for ( Builder zDependent : mDependents ) |
|
76 |
+ |
{ |
|
77 |
+ |
zDependent.build(); |
|
78 |
+ |
} |
|
79 |
+ |
System.out.println( "build: " + mName ); |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
public static void main( String[] args ) |
|
83 |
+ |
throws IOException |
|
84 |
+ |
{ |
|
85 |
+ |
Scar.args = new Arguments( args ); |
|
86 |
+ |
|
|
87 |
+ |
if ( Scar.args.has( "trace" ) ) |
|
88 |
+ |
{ |
|
89 |
+ |
TRACE(); |
|
90 |
+ |
} |
|
91 |
+ |
else if ( Scar.args.has( "debug" ) ) |
|
92 |
+ |
{ |
|
93 |
+ |
DEBUG(); |
|
94 |
+ |
} |
|
95 |
+ |
else if ( Scar.args.has( "info" ) ) |
|
96 |
+ |
{ |
|
97 |
+ |
INFO(); |
|
98 |
+ |
} |
|
99 |
+ |
else if ( Scar.args.has( "warn" ) ) |
|
100 |
+ |
{ |
|
101 |
+ |
WARN(); |
|
102 |
+ |
} |
|
103 |
+ |
else if ( Scar.args.has( "error" ) ) // |
|
104 |
+ |
{ |
|
105 |
+ |
ERROR(); |
|
106 |
+ |
} |
|
107 |
+ |
|
|
108 |
+ |
new Builder( null, Scar.args.get( "file", "." ) ).build(); |
|
109 |
+ |
} |
|
110 |
+ |
|
|
111 |
+ |
@Override |
|
112 |
+ |
public String toString() |
|
113 |
+ |
{ |
|
114 |
+ |
return "Project: " + mName; |
|
115 |
+ |
} |
|
116 |
+ |
} |