Removed ProjectGWT (it is now a module).

This commit is contained in:
nathan 2017-12-29 09:38:38 +01:00
parent 4cee6c1d34
commit c98ba22a6f
4 changed files with 169 additions and 552 deletions

View File

@ -35,7 +35,6 @@ import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.minlog.Log;
import com.esotericsoftware.wildcard.Paths;
import dorkbox.BuildOptions;
import dorkbox.BuildVersion;
@ -44,6 +43,7 @@ import dorkbox.build.util.BuildLog;
import dorkbox.build.util.Hash;
import dorkbox.build.util.OutputFile;
import dorkbox.build.util.ShutdownHook;
import dorkbox.build.util.wildcard.Paths;
import dorkbox.license.License;
import dorkbox.util.FileUtil;
import dorkbox.util.OS;
@ -213,18 +213,17 @@ class Project<T extends Project<T>> {
protected BuildVersion version;
File stagingDir;
protected File stagingDir;
// if true, we do not delete the older versions during a build
boolean keepOldVersion;
public OutputFile outputFile;
public List<File> sources = new ArrayList<File>();
// could also be called native lib location
private String distLocation;
protected Paths extraFiles = new Paths();
public Paths extraFiles = new Paths();
/** DIRECT dependencies for this project */
protected List<Project<?>> dependencies = new ArrayList<Project<?>>();
@ -232,8 +231,10 @@ class Project<T extends Project<T>> {
/** Dependencies that are just source code files, not a jar. These are converted into a jar when the project is build */
protected Paths sourceDependencies = new Paths();
protected Paths sourcePaths = new Paths();
/** ALL related dependencies for this project (ie: recursively searched) */
transient List<Project<?>> fullDependencyList = null;
protected transient List<Project<?>> fullDependencyList = null;
// used to make sure licenses are called in the correct spot
private transient boolean calledLicenseBefore = false;
@ -246,6 +247,9 @@ class Project<T extends Project<T>> {
// used to suppress certain messages when building deps
protected transient boolean isBuildingDependencies = false;
// used to suppress logging what dependencies are used
private boolean suppressDependencyLog = false;
// Sometimes we don't want to export the build to maven (ie: when running a test, for example)
protected boolean exportToMaven = false;
@ -298,6 +302,7 @@ class Project<T extends Project<T>> {
}
}
/**
* resolves all of the dependencies for this project, since the build order can be specified in ANY order
*/
@ -463,10 +468,11 @@ class Project<T extends Project<T>> {
}
/**
* Checks to see if we already built this project. Also, will automatically build this projects
* Checks to see if we already built this project. Also, will automatically build this project's
* dependencies (if they haven't already been built).
*/
void resolveDependencies() throws IOException {
protected
void resolveDependencies() {
resolveDeps();
if (fullDependencyList == null) {
@ -481,6 +487,87 @@ class Project<T extends Project<T>> {
}
}
/**
* suppress logging what dependencies are used
*/
public
T suppressDependencyLog() {
suppressDependencyLog = true;
return (T) this;
}
/**
* Outputs all of the dependency information for a build
*/
protected
void logDependencies() {
if (!suppressDependencyLog && !fullDependencyList.isEmpty()) {
String[] array2 = new String[fullDependencyList.size() + 1];
array2[0] = "Depends";
int i = 1;
for (Project<?> project : fullDependencyList) {
array2[i] = project.name;
if (project.version != null) {
array2[i] += " " + project.version;
}
if (project instanceof ProjectJar) {
array2[i] += " (jar)";
}
i++;
}
BuildLog.println().println((Object[]) array2).println();
}
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
T sourcePath(Paths sourcePaths) {
if (sourcePaths == null) {
throw new NullPointerException("Source paths cannot be null!");
}
this.sourcePaths.add(sourcePaths);
// ALWAYS add the source paths to be checksumed!
hash.add(sourcePaths);
return (T) this;
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
T sourcePath(String srcDir) {
if (srcDir.endsWith("src")) {
String parent = new File(srcDir).getAbsoluteFile()
.getParent();
hash.add(new Paths(parent));
}
return sourcePath(new Paths(srcDir, "./"));
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
T sourcePath(String dir, String... patterns) {
return sourcePath(new Paths(dir, patterns));
}
/**
* Add a class to the list of sources that are available when compiling the code
*/
public
T sourcePath(final Class<?> sourceClass) {
return sourcePath(Builder.getJavaFile(sourceClass));
}
/**
* requires output file to exist for build to succeed
*/
@ -575,7 +662,18 @@ class Project<T extends Project<T>> {
public
T extraFiles(File file) {
this.extraFiles.add(new Paths(file.getParent(), file.getName()));
Paths paths = new Paths(file.getParent(), file.getName());
Iterator<File> fileIterator = paths.fileIterator();
while (fileIterator.hasNext()) {
File next = fileIterator.next();
if (!next.canRead()) {
BuildLog.title("Error").println("Unable to read specified extra file: '" + file.getAbsolutePath() + "'");
}
}
this.extraFiles.add(paths);
return (T) this;
}
@ -631,17 +729,6 @@ class Project<T extends Project<T>> {
return (T) this;
}
public
T addSrc(String file) {
this.sources.add(FileUtil.normalize(file));
return (T) this;
}
public
T addSrc(File file) {
this.sources.add(file);
return (T) this;
}
public
T dist(String distLocation) {
@ -707,6 +794,11 @@ class Project<T extends Project<T>> {
return (T) this;
}
public
File getStagingDir() {
return stagingDir;
}
public
void copyFiles(String targetLocation) throws IOException {
@ -747,10 +839,6 @@ class Project<T extends Project<T>> {
if (source != null && source.canRead()) {
Builder.copyFile(source, new File(targetLocation, source.getName()));
}
for (File f : this.sources) {
Builder.copyFile(f, new File(targetLocation, f.getName()));
}
}
// now copy out extra files

View File

@ -1,419 +0,0 @@
/*
* Copyright 2012 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.build;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.List;
import java.util.Map.Entry;
import com.esotericsoftware.wildcard.Paths;
import dorkbox.Builder;
import dorkbox.build.util.BuildLog;
import dorkbox.build.util.jar.JarUtil;
import dorkbox.util.FileUtil;
import dorkbox.util.gwt.GwtSymbolMapParser;
import dorkbox.util.process.JvmExecutor;
public
class ProjectGwt extends Project<ProjectGwt> {
public static
ProjectGwt create(String projectName, String projectLocation) {
ProjectGwt project = new ProjectGwt(projectName, projectLocation);
deps.put(projectName, project);
return project;
}
/**
* Parses the relevant data from the symbol map and saves it in the specified file.
*/
public static
void parseAndCopyGwtSymbols(File sourceFile, File destSymbolFile) throws IOException {
GwtSymbolMapParser parser = new GwtSymbolMapParser();
//FileReader always assumes default encoding is OK!
FileInputStream fileInputStream = new FileInputStream(sourceFile);
parser.parse(fileInputStream);
destSymbolFile.getParentFile()
.mkdirs();
Writer output = new BufferedWriter(new FileWriter(destSymbolFile));
try {
// FileWriter always assumes default encoding is OK
output.write("# BUILD-SCRIPT MODIFIED: only relevant symbols are present.\n");
StringBuilder stringBuilder = new StringBuilder();
for (Entry<String, String> entry : parser.getSymbolMap()
.entrySet()) {
stringBuilder.delete(0, stringBuilder.capacity());
// create a "shrunk" version for deployment. This is marginally better than the original version
stringBuilder.append(entry.getKey()) // jsName
.append(",")
.append(entry.getValue()) // java className
.append("\n");
String line = stringBuilder.toString();
// FileWriter always assumes default encoding is OK
output.write(line);
}
} finally {
output.close();
}
}
protected Paths sourcePaths = new Paths();
private String[] extraOptions;
private String projectLocation;
protected
ProjectGwt(String projectName, String projectLocation) {
super(projectName);
this.projectLocation = projectLocation;
}
public
ProjectGwt sourcePath(Paths sourcePaths) {
if (sourcePaths == null) {
throw new NullPointerException("Source paths cannot be null!");
}
this.sourcePaths.add(sourcePaths);
return this;
}
public
ProjectGwt sourcePath(String srcDir) {
if (srcDir.endsWith("src")) {
String parent = new File(srcDir).getAbsoluteFile()
.getParent();
hash.add(parent);
}
return sourcePath(new Paths(srcDir, "./"));
}
public
ProjectGwt sourcePath(String dir, String... patterns) {
return sourcePath(new Paths(dir, patterns));
}
/**
* This uses the same gwt symbol parser as the web-server project.
*
* @return true if this project was built, false otherwise
*/
@Override
public
boolean build(final int targetJavaVersion) throws IOException {
// check dependencies for this project
resolveDependencies();
boolean shouldBuild = false;
try {
// GWT checksum requirements are different than regular java.
shouldBuild = !verifyChecksums();
if (shouldBuild) {
// make sure our dependencies are on the classpath.
if (this.dependencies != null) {
for (Project<?> project : this.dependencies) {
if (project != null) {
this.sourcePaths.addFile(project.outputFile.get().getAbsolutePath());
}
}
}
FileUtil.delete(this.stagingDir);
FileUtil.mkdir(this.stagingDir);
String clientString = "Client";
String stagingWar = Builder.path(STAGING, "war");
String stagingWarWebINF = Builder.path(stagingWar, "WEB-INF");
String stagingWarWebINFDeploy = Builder.path(stagingWarWebINF, "deploy");
String stagingJunk = Builder.path(STAGING, "junk");
String stagingUnitCache = Builder.path(STAGING, "gwt-unitCache");
String stagingSymbols = Builder.path(STAGING, "symbolMaps");
String clientTempLocation = Builder.path(STAGING, clientString + "_javascript");
String srcWarPath = Builder.path("..", this.projectLocation, "war");
// make the output directory
FileUtil.delete(stagingWar);
FileUtil.delete(stagingSymbols);
FileUtil.delete(clientTempLocation);
FileUtil.mkdir(stagingWar);
FileUtil.mkdir(stagingUnitCache);
if (this.buildOptions.compiler.release) {
FileUtil.delete(stagingUnitCache);
}
System.err.println("Compiling GWT modules. This can take a while....");
System.err.println(" Working location: " + FileUtil.normalize(new File("test"))
.getParent());
JvmExecutor builder = new JvmExecutor(System.in, System.out, System.err);
builder.setMaximumHeapSizeInMegabytes(512);
// we want to DEBUG this! (figure out wtf is going on)
// builder.addJvmOption("-Xdebug");
// builder.addJvmOption("-Xrunjdwp:transport=dt_socket,server=y,address=1044");
builder.setMainClass("com.google.gwt.dev.Compiler");
// The Java classpath should include:
// - the Java source code of your application
// - gwt-dev.jar, gwt-user.jar,
// - any compiler-visible resources such as ui.xml and .png files,
// - and the COMPILED versions of any generators and linkers added or used by the build.
// the GWT compiler needs the source/parent directory of the XML files
builder.addJvmClasspaths(this.sourcePaths.getPaths());
// prevent phone-home of google GWT compiler
builder.addArgument("-XdisableUpdateCheck");
// EXPERIMENTAL: Disables some java.lang.Class methods (e.g. getName())
builder.addArgument("-XdisableClassMetadata");
//Logs output in a graphical tree view
builder.addArgument("-treeLogger");
// fail if there are any warnings
builder.addArgument("-strict");
// The directory into which deployable output files will be written (defaults to 'war')
builder.addArgument("-war " + stagingWar);
// we want the compiler to save the symbols map (so we can correctly do the mapping for message-bus de-obfuscation)
builder.addArgument("-deploy " + stagingWarWebINFDeploy);
// The directory into which extra files, not intended for deployment, will be written
builder.addArgument("-extra " + stagingJunk);
// Additional arguments like -style PRETTY/OBFuscated/DETAILED or -logLevel INFO/WARN/ERROR/TRACE/DEBUG/SPAM/ALL
// logLevel is log level during compile.
builder.addArgument("-logLevel INFO");
// builder.addArgument("-logLevel TRACE");
for (String option : this.extraOptions) {
builder.addArgument(option);
}
// DETAILED, PRETTY, OBF[USCATED]
if (this.buildOptions.compiler.debugEnabled) {
// builder.addArgument("-style PRETTY");
builder.addArgument("-style DETAILED");
}
else {
builder.addArgument("-style OBF");
}
if (this.buildOptions.compiler.release) {
// generate the gwt cache files EVERY time
builder.addArgument("-Dgwt.usearchives=false");
}
// must be last
builder.addArgument("hive." + clientString);
builder.start();
// move the symbol maps to the correct spot
FileUtil.mkdir(stagingSymbols);
Paths symbolMapPaths = new Paths(Builder.path(stagingWarWebINFDeploy, clientString, "symbolMaps"), "*.symbolMap");
for (File file : symbolMapPaths.getFiles()) {
// clean up the symbolmaps first!
parseAndCopyGwtSymbols(file, new File(Builder.path(stagingSymbols, file.getName())));
}
// move the client generated javascript to the correct spot
FileUtil.moveDirectory(Builder.path(stagingWar, clientString), clientTempLocation);
// remove directories that are not needed/wanted in the deployment
FileUtil.delete(stagingWar);
FileUtil.delete(stagingJunk);
if (this.buildOptions.compiler.release) {
FileUtil.delete(stagingUnitCache);
}
// create the NEW war directory
FileUtil.mkdir(stagingWar);
// todo: pass in the hive-webclient project name somehow?
Paths warFiles = new Paths(srcWarPath, "*.html", "*.ico");
for (File file : warFiles.getFiles()) {
FileUtil.copyFile(file.getAbsolutePath(), Builder.path(stagingWar, file.getName()));
}
// copy over images
FileUtil.copyDirectory(Builder.path(srcWarPath, "images"), Builder.path(stagingWar, "images"), ".svn");
// make the web-INF directory
FileUtil.mkdir(stagingWarWebINF);
// move the symbolMaps into the correct spot.
FileUtil.moveDirectory(stagingSymbols, Builder.path(stagingWarWebINF, "symbolMaps"));
// add any extra files to the output war dir.
File warDir = new File(stagingWar);
List<String> paths = this.extraFiles.getPaths();
List<String> paths2 = this.extraFiles.getRelativePaths();
for (int i = 0; i < paths.size(); i++) {
String path = paths.get(i);
String dest = paths2.get(i);
FileUtil.copyFile(path, new File(warDir, dest).getPath());
}
// move the client generated javascript to the correct spot
FileUtil.moveDirectory(clientTempLocation, Builder.path(stagingWar, clientString));
// war it up
warFiles = new Paths(stagingWar, "**");
List<String> fullPaths = warFiles.filesOnly()
.getPaths();
List<String> relativePaths = warFiles.filesOnly()
.getRelativePaths();
if (this.outputFile.get().exists()) {
this.outputFile.get().delete();
}
FileUtil.mkdir(this.outputFile.get().getParent());
// make a jar (really a war file)
JarUtil.war(this.outputFile.get().getAbsolutePath(), fullPaths, relativePaths);
// cleanup
FileUtil.delete(stagingWar);
// calculate the hash of all the files in the source path
saveChecksums();
}
else {
BuildLog.println()
.println("Skipped (nothing changed)");
}
} finally {
if (shouldBuild) {
FileUtil.delete(this.stagingDir);
}
}
System.err.println(" Build success: " + this.stagingDir);
return shouldBuild;
}
@Override
public
String getExtension() {
return ".war";
}
/**
* GWT only cares about the output dir (it doesn't make jars for compiling)
*
* @return true if the checksums for path match the saved checksums and the jar file exists
*/
boolean verifyChecksums() throws IOException {
boolean sourceHashesSame = hash.verifyChecksums();
if (!sourceHashesSame) {
return false;
}
// if the sources are the same, check the output dir
if (this.stagingDir.exists()) {
String dirChecksum = hash.generateChecksum(this.stagingDir);
String checkContents = Builder.settings.get(this.stagingDir.getAbsolutePath(), String.class);
return dirChecksum != null && dirChecksum.equals(checkContents);
}
return true;
}
/**
* GWT only cares about the output dir (it doesn't make jars for compiling) Saves the checksums for a given path
*/
void saveChecksums() throws IOException {
// by default, we save the build. When building a 'test' build, we opt to NOT save the build hashes, so that a 'normal' build
// will then compile.
if (!buildOptions.compiler.saveBuild) {
return;
}
hash.saveChecksums();
// hash/save the output files (if there are any)
if (this.stagingDir.exists()) {
String fileChecksum = hash.generateChecksum(this.stagingDir);
Builder.settings.save(this.stagingDir.getAbsolutePath(), fileChecksum);
}
}
public
ProjectGwt options(String... options) {
if (this.extraOptions != null) {
List<String> origList = Arrays.asList(this.extraOptions);
List<String> newList = Arrays.asList(options);
origList.addAll(newList);
this.extraOptions = origList.toArray(new String[0]);
}
else {
this.extraOptions = options;
}
return this;
}
/**
* Take all of the parameters of this project, and convert it to a text file.
*/
@Override
public
void save(final String location) {
}
}

View File

@ -5,7 +5,6 @@ import java.io.IOException;
import dorkbox.BuildVersion;
import dorkbox.build.util.BuildLog;
import dorkbox.build.util.FileNotFoundRuntimeException;
import dorkbox.util.storage.Storage;
import dorkbox.util.storage.StorageKey;
import dorkbox.util.storage.StorageSystem;
@ -29,14 +28,6 @@ public class ProjectJar extends Project<ProjectJar> {
super(projectName);
}
@Override
public
ProjectJar addSrc(String file) {
BuildLog.title("Error")
.println("Cannot specify a source file in this manner for a jar. Please set the source along with the output file");
throw new FileNotFoundRuntimeException("Invalid file: " + file);
}
@Override
public
boolean build(final int targetJavaVersion) throws IOException {
@ -65,14 +56,6 @@ public class ProjectJar extends Project<ProjectJar> {
return outputFileNoWarn(outputFile, outputSourceFile);
}
@Override
public
ProjectJar addSrc(File file) {
BuildLog.title("Error")
.println("Cannot specify a source file in this manner for a jar. Please set the source along with the output file");
throw new FileNotFoundRuntimeException("Invalid file: " + file);
}
@Override
public
ProjectJar dist(String distLocation) {

View File

@ -37,7 +37,6 @@ import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import com.esotericsoftware.wildcard.Paths;
import com.esotericsoftware.yamlbeans.YamlConfig;
import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlWriter;
@ -51,6 +50,7 @@ import dorkbox.build.util.DependencyWalker;
import dorkbox.build.util.FileNotFoundRuntimeException;
import dorkbox.build.util.classloader.ByteClassloader;
import dorkbox.build.util.classloader.JavaMemFileManager;
import dorkbox.build.util.wildcard.Paths;
import dorkbox.license.License;
import dorkbox.license.LicenseType;
import dorkbox.util.FileUtil;
@ -62,7 +62,6 @@ class ProjectJava extends Project<ProjectJava> {
protected ArrayList<String> extraArgs;
protected Paths sourcePaths = new Paths();
public Paths classPaths = new Paths();
private transient ByteClassloader bytesClassloader = null;
@ -82,56 +81,10 @@ class ProjectJava extends Project<ProjectJava> {
return project;
}
private
ProjectJava(String projectName) {
super(projectName);
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
ProjectJava sourcePath(Paths sourcePaths) {
if (sourcePaths == null) {
throw new NullPointerException("Source paths cannot be null!");
}
this.sourcePaths.add(sourcePaths);
// ALWAYS add the source paths to be checksumed!
hash.add(sourcePaths);
return this;
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
ProjectJava sourcePath(String srcDir) {
if (srcDir.endsWith("src")) {
String parent = new File(srcDir).getAbsoluteFile().getParent();
hash.add(new Paths(parent));
}
return sourcePath(new Paths(srcDir, "./"));
}
/**
* Add paths to the list of sources that are available when compiling the code
*/
public
ProjectJava sourcePath(String dir, String... patterns) {
return sourcePath(new Paths(dir, patterns));
}
/**
* Add a class to the list of sources that are available when compiling the code
*/
public
ProjectJava sourcePath(final Class<?> sourceClass) {
return sourcePath(Builder.getJavaFile(sourceClass));
}
public
ProjectJava classPath(ProjectJar project) {
if (project == null) {
@ -213,32 +166,13 @@ class ProjectJava extends Project<ProjectJava> {
// check dependencies for this project
resolveDependencies();
// we want to make sure that we build IF one of our dependencies needs to build too
for (Project<?> project : fullDependencyList) {
if (!shouldBuild && !(project instanceof ProjectJar)) {
// if one of our dependencies has to build, so do we (don't keep checking if we have to build)
// also, we DO NOT check jar versions/etc here (that happens later)
// if true, this means that the files ARE the same and they have not changed
final boolean b = project.hash.verifyChecksums();
shouldBuild |= !b;
}
}
// has our dependencies or their versions changed at all?
final ArrayList<String> depWithVersionInfo = new ArrayList<String>();
for (Project<?> project : fullDependencyList) {
// version can be null, which is OK for our tests here
depWithVersionInfo.add(project.name + ":" + project.version);
}
final String origDepsWithVersion = Builder.settings.get(this.name + ":deps", String.class);
shouldBuild |= !depWithVersionInfo.toString().equals(origDepsWithVersion);
// we should always rebuild if specified
shouldBuild |= forceRebuild;
shouldBuild |= hasDependenciesChanged();
shouldBuild |= !verifyChecksums();
// we should always rebuild if specified
shouldBuild |= forceRebuild;
// exit early if we already built this project, unless we force a rebuild
if (!forceRebuild && buildList.contains(this.name)) {
@ -269,25 +203,7 @@ class ProjectJava extends Project<ProjectJava> {
BuildLog.title("Compiling").println(this.name + " " + version);
}
if (!fullDependencyList.isEmpty()) {
String[] array2 = new String[fullDependencyList.size() + 1];
array2[0] = "Depends";
int i = 1;
for (Project<?> project : fullDependencyList) {
array2[i] = project.name;
if (project.version != null) {
array2[i] += " " + project.version;
}
if (project instanceof ProjectJar) {
array2[i] += " (jar)";
}
i++;
}
BuildLog.println().println((Object[]) array2).println();
}
logDependencies();
if (shouldBuild) {
// We have to make sure that TEMPORARY projects are built - even if that temp project DOES NOT need to build b/c of source code
@ -313,7 +229,7 @@ class ProjectJava extends Project<ProjectJava> {
}
// barf if we don't have source files!
if (this.sourcePaths.getFiles().isEmpty()) {
if (this.sourcePaths.isEmpty()) {
throw new IOException("No source files specified for project: " + this.name);
}
@ -326,10 +242,13 @@ class ProjectJava extends Project<ProjectJava> {
// if this project is a jar project, there might be "extra files", which mean this project IS NOT a
// compile dependency, but a runtime dependency (via the "extra files" section)
Paths extraFiles = project.extraFiles();
if (extraFiles.count() == 0) {
throw new IOException("Dependency for project: '" + this.name + "' does not have a source jar or extra files. " +
if (extraFiles.size() == 0) {
throw new IOException("Dependency " + project + " for project '" + this.name + "' does not have a source jar or extra files. " +
"Something is very wrong. A source jar is a compile dependency, and extra files are runtime" +
" dependencies.");
} else {
// add the extra files to the classpath
this.classPaths.add(extraFiles);
}
}
else {
@ -522,7 +441,7 @@ class ProjectJava extends Project<ProjectJava> {
saveChecksums();
// save our dependencies and their version info
Builder.settings.save(this.name + ":deps", depWithVersionInfo.toString());
saveDependencyVersionInfo();
if (crossCompatBuiltFile != null) {
FileUtil.delete(crossCompatBuiltFile);
@ -541,6 +460,38 @@ class ProjectJava extends Project<ProjectJava> {
return shouldBuild;
}
/**
* @return true if our dependencies have changed and we need to rebuild
*/
private
boolean hasDependenciesChanged() throws IOException {
boolean shouldBuild = false;
// we want to make sure that we build IF one of our dependencies needs to build too
for (Project<?> project : fullDependencyList) {
if (!shouldBuild && !(project instanceof ProjectJar)) {
// if one of our dependencies has to build, so do we (don't keep checking if we have to build)
// also, we DO NOT check jar versions/etc here (that happens later)
// if true, this means that the files ARE the same and they have not changed
final boolean b = project.hash.verifyChecksums();
shouldBuild = !b;
}
}
// has our dependencies or their versions changed at all?
final ArrayList<String> depsWithVersionInfo = new ArrayList<String>(fullDependencyList.size());
for (Project<?> project : fullDependencyList) {
// version can be null, which is OK for our tests here
depsWithVersionInfo.add(project.name + ":" + project.version);
}
final String origDepsWithVersion = Builder.settings.get(this.name + ":deps", String.class);
shouldBuild |= !depsWithVersionInfo.toString().equals(origDepsWithVersion);
return shouldBuild;
}
/**
* Compiles into class files.
*/
@ -1002,4 +953,18 @@ class ProjectJava extends Project<ProjectJava> {
}
}
}
/**
* Saves the dependency + version info (so if the version changes, we update the info)
*/
private
void saveDependencyVersionInfo() {
final ArrayList<String> depsWithVersionInfo = new ArrayList<String>(fullDependencyList.size());
for (Project<?> project : fullDependencyList) {
// version can be null, which is OK for our tests here
depsWithVersionInfo.add(project.name + ":" + project.version);
}
Builder.settings.save(this.name + ":deps", depsWithVersionInfo.toString());
}
}