This commit is contained in:
Greg DiCristofaro 2023-09-01 12:46:11 -04:00
parent d8869c689f
commit da37197a03
3 changed files with 31 additions and 8 deletions

View File

@ -1,6 +1,20 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
* Autopsy Forensic Browser
*
* Copyright 2023 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* 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 org.sleuthkit.autopsy.apiupdate;
@ -26,6 +40,7 @@ import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -126,6 +141,8 @@ public class APIDiff {
PublicApiChangeType changeType = getChangeType(jApiClasses);
Options options = Options.newDefault();
options.setOldArchives(Arrays.asList(new JApiCmpArchive(prevJar, prevVersion)));
options.setNewArchives(Arrays.asList(new JApiCmpArchive(curJar, curVersion)));
options.setOutputOnlyModifications(true);
StdoutOutputGenerator stdoutOutputGenerator = new StdoutOutputGenerator(options, jApiClasses);

View File

@ -38,7 +38,7 @@ public class Main {
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
public static void main(String[] args) {
args = "-c C:\\Users\\gregd\\Desktop\\apidiff\\new -p C:\\Users\\gregd\\Desktop\\apidiff\\old -cv 4.21.0 -pv 4.20.0 -s C:\\Users\\gregd\\Documents\\Source\\autopsy".split(" ");
args = "-p C:\\Users\\gregd\\Desktop\\apidiff\\old -s C:\\Users\\gregd\\Documents\\Source\\autopsy".split(" ");
CLIArgs cliArgs;
try {
cliArgs = CLIProcessor.parseCli(args);
@ -68,7 +68,7 @@ public class Main {
outputDiff(commonJarFileName, record, prevVersionNums, projectedVersionNums);
newVersionNumMapping.put(commonJarFileName, projectedVersionNums);
newVersionNumMapping.put(projectedVersionNums.getRelease().getModuleName(), projectedVersionNums);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}

View File

@ -25,8 +25,10 @@ import java.io.StringWriter;
import java.nio.file.Files;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -61,10 +63,6 @@ public class ModuleUpdates {
private static final Logger LOGGER = Logger.getLogger(ModuleUpdates.class.getName());
static {
LOGGER.addHandler(new StreamHandler(System.out, new SimpleFormatter()));
}
private static final Pattern SPEC_REGEX = Pattern.compile("^\\s*((?<major>\\d*)\\.)?(?<minor>\\d*)(\\.(?<patch>\\d*))?\\s*$");
private static final Pattern PROJECT_PROPS_SPEC_REGEX = Pattern.compile("^\\s*spec\\.version\\.base\\s*=.*$", Pattern.MULTILINE);
@ -236,6 +234,14 @@ public class ModuleUpdates {
return;
}
Set<String> notFoundModules = new HashSet<>(versNums.keySet());
notFoundModules.removeAll(moduleDirs.keySet());
if (!notFoundModules.isEmpty()) {
LOGGER.log(Level.SEVERE, MessageFormat.format("The following modules were not found in {0}: {1}. Aborting...", srcDir, notFoundModules));
return;
}
for (Entry<String, File> moduleNameDir : moduleDirs.entrySet()) {
String moduleName = moduleNameDir.getKey();
File moduleDir = moduleNameDir.getValue();