Initial gradle 6.0 rc1 fixes, ugly but works. Closes #131
This commit is contained in:
		
							parent
							
								
									40d895095f
								
							
						
					
					
						commit
						13ae0ae263
					
				
					 3 changed files with 62 additions and 4 deletions
				
			
		|  | @ -26,6 +26,7 @@ package net.fabricmc.loom.task; | ||||||
| 
 | 
 | ||||||
| import net.fabricmc.loom.LoomGradleExtension; | import net.fabricmc.loom.LoomGradleExtension; | ||||||
| import net.fabricmc.loom.providers.MappingsProvider; | import net.fabricmc.loom.providers.MappingsProvider; | ||||||
|  | import net.fabricmc.loom.util.GradleSupport; | ||||||
| import net.fabricmc.loom.util.MixinRefmapHelper; | import net.fabricmc.loom.util.MixinRefmapHelper; | ||||||
| import net.fabricmc.loom.util.NestedJars; | import net.fabricmc.loom.util.NestedJars; | ||||||
| import net.fabricmc.loom.util.TinyRemapperMappingsHelper; | import net.fabricmc.loom.util.TinyRemapperMappingsHelper; | ||||||
|  | @ -54,7 +55,7 @@ public class RemapJarTask extends Jar { | ||||||
| 
 | 
 | ||||||
| 	public RemapJarTask() { | 	public RemapJarTask() { | ||||||
| 		super(); | 		super(); | ||||||
| 		input = getProject().getLayout().fileProperty(); | 		input = GradleSupport.getfileProperty(getProject()); | ||||||
| 		addNestedDependencies = getProject().getObjects().property(Boolean.class); | 		addNestedDependencies = getProject().getObjects().property(Boolean.class); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										57
									
								
								src/main/java/net/fabricmc/loom/util/GradleSupport.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/main/java/net/fabricmc/loom/util/GradleSupport.java
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,57 @@ | ||||||
|  | /* | ||||||
|  |  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||||
|  |  * | ||||||
|  |  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||||
|  |  * | ||||||
|  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  |  * of this software and associated documentation files (the "Software"), to deal | ||||||
|  |  * in the Software without restriction, including without limitation the rights | ||||||
|  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||
|  |  * copies of the Software, and to permit persons to whom the Software is | ||||||
|  |  * furnished to do so, subject to the following conditions: | ||||||
|  |  * | ||||||
|  |  * The above copyright notice and this permission notice shall be included in all | ||||||
|  |  * copies or substantial portions of the Software. | ||||||
|  |  * | ||||||
|  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||
|  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||
|  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||
|  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||
|  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||
|  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  |  * SOFTWARE. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package net.fabricmc.loom.util; | ||||||
|  | 
 | ||||||
|  | import org.gradle.api.Project; | ||||||
|  | import org.gradle.api.file.RegularFileProperty; | ||||||
|  | import org.gradle.api.model.ObjectFactory; | ||||||
|  | 
 | ||||||
|  | import java.lang.reflect.InvocationTargetException; | ||||||
|  | import java.lang.reflect.Method; | ||||||
|  | 
 | ||||||
|  | //This is used to bridge the gap over large gradle api changes. | ||||||
|  | public class GradleSupport { | ||||||
|  | 
 | ||||||
|  | 	public static RegularFileProperty getfileProperty(Project project){ | ||||||
|  | 		try { | ||||||
|  | 			//First try the new method, if that fails fall back. | ||||||
|  | 			return getfilePropertyModern(project); | ||||||
|  | 		} catch (Exception e){ | ||||||
|  | 			//Nope | ||||||
|  | 		} | ||||||
|  | 		return getfilePropertyLegacy(project); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private static RegularFileProperty getfilePropertyModern(Project project) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { | ||||||
|  | 		ObjectFactory objectFactory = project.getObjects(); | ||||||
|  | 		Method method = objectFactory.getClass().getDeclaredMethod("fileProperty"); | ||||||
|  | 		method.setAccessible(true); | ||||||
|  | 		return (RegularFileProperty) method.invoke(objectFactory); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private static RegularFileProperty getfilePropertyLegacy(Project project){ | ||||||
|  | 		return project.getLayout().fileProperty(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | @ -78,7 +78,7 @@ public class ModCompileRemapper { | ||||||
| 			String remappedLog = group + ":" + name + ":" + version + classifierSuffix + " (" + mappingsPrefix + ")"; | 			String remappedLog = group + ":" + name + ":" + version + classifierSuffix + " (" + mappingsPrefix + ")"; | ||||||
| 			String remappedNotation = "net.fabricmc.mapped:" + mappingsPrefix + "." + group + "." + name + ":" + version + classifierSuffix; | 			String remappedNotation = "net.fabricmc.mapped:" + mappingsPrefix + "." + group + "." + name + ":" + version + classifierSuffix; | ||||||
| 			String remappedFilename = mappingsPrefix + "." + group + "." + name + "-" + version + classifierSuffix.replace(':', '-'); | 			String remappedFilename = mappingsPrefix + "." + group + "." + name + "-" + version + classifierSuffix.replace(':', '-'); | ||||||
| 			project.getLogger().lifecycle(":providing " + remappedLog); | 			project.getLogger().info(":providing " + remappedLog); | ||||||
| 
 | 
 | ||||||
| 			File modStore = extension.getRemappedModCache(); | 			File modStore = extension.getRemappedModCache(); | ||||||
| 
 | 
 | ||||||
|  | @ -109,7 +109,7 @@ public class ModCompileRemapper { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) { | 	private static void addToRegularCompile(Project project, Configuration regularCompile, String notation) { | ||||||
| 		project.getLogger().lifecycle(":providing " + notation); | 		project.getLogger().info(":providing " + notation); | ||||||
| 		DependencyHandler dependencies = project.getDependencies(); | 		DependencyHandler dependencies = project.getDependencies(); | ||||||
| 		Dependency dep = dependencies.module(notation); | 		Dependency dep = dependencies.module(notation); | ||||||
| 		if (dep instanceof ModuleDependency) { | 		if (dep instanceof ModuleDependency) { | ||||||
|  | @ -158,7 +158,7 @@ public class ModCompileRemapper { | ||||||
| 
 | 
 | ||||||
| 	private static void scheduleSourcesRemapping(Project project, Consumer<Runnable> postPopulationScheduler, File sources, String remappedLog, String remappedFilename, File modStore) { | 	private static void scheduleSourcesRemapping(Project project, Consumer<Runnable> postPopulationScheduler, File sources, String remappedLog, String remappedFilename, File modStore) { | ||||||
| 		postPopulationScheduler.accept(() -> { | 		postPopulationScheduler.accept(() -> { | ||||||
| 			project.getLogger().lifecycle(":providing " + remappedLog + " sources"); | 			project.getLogger().info(":providing " + remappedLog + " sources"); | ||||||
| 			File remappedSources = new File(modStore, remappedFilename + "-sources.jar"); | 			File remappedSources = new File(modStore, remappedFilename + "-sources.jar"); | ||||||
| 
 | 
 | ||||||
| 			if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified()) { | 			if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified()) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue