Delete existing sources jar when re-running jar processors. Fixes #560
This commit is contained in:
		
							parent
							
								
									240a23f52d
								
							
						
					
					
						commit
						6fd3d5d021
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		|  | @ -76,6 +76,7 @@ public abstract class ProcessedNamedMinecraftProvider<M extends MinecraftProvide | ||||||
| 
 | 
 | ||||||
| 			for (Path inputJar : inputJars) { | 			for (Path inputJar : inputJars) { | ||||||
| 				final Path outputJar = getProcessedPath(inputJar); | 				final Path outputJar = getProcessedPath(inputJar); | ||||||
|  | 				deleteSimilarJars(outputJar); | ||||||
| 
 | 
 | ||||||
| 				Files.copy(inputJar, outputJar, StandardCopyOption.REPLACE_EXISTING); | 				Files.copy(inputJar, outputJar, StandardCopyOption.REPLACE_EXISTING); | ||||||
| 				jarProcessorManager.process(outputJar.toFile()); | 				jarProcessorManager.process(outputJar.toFile()); | ||||||
|  | @ -87,6 +88,15 @@ public abstract class ProcessedNamedMinecraftProvider<M extends MinecraftProvide | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	private void deleteSimilarJars(Path jar) throws IOException { | ||||||
|  | 		Files.deleteIfExists(jar); | ||||||
|  | 
 | ||||||
|  | 		for (Path path : Files.list(jar.getParent()).filter(Files::isRegularFile) | ||||||
|  | 				.filter(path -> path.getFileName().startsWith(jar.getFileName().toString().replace(".jar", ""))).toList()) { | ||||||
|  | 			Files.deleteIfExists(path); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	protected String getName(String name) { | 	protected String getName(String name) { | ||||||
| 		return "%s%s-%s".formatted(projectMappedName, name, getTargetNamespace().toString()); | 		return "%s%s-%s".formatted(projectMappedName, name, getTargetNamespace().toString()); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue