3131public final class RenameTask implements Task {
3232 private final String name ;
3333 private final MCPSide side ;
34+ private final boolean javadocs ;
3435 private final Task task ;
3536
3637 /**
@@ -39,21 +40,12 @@ public final class RenameTask implements Task {
3940 * @param build The directory where the output will be stored
4041 * @param name The development artifact, only used for the task name
4142 * @param sources The task that creates the unnamed sources
43+ * @param javadocs Wither to inject javadocs and rename lambda parameters, false is used for ForgeDev as we remap to SRG patches when making userdev
4244 */
43- public RenameTask (File build , Artifact name , MCPSide side , Task sources , Mappings mappings ) {
44- this (build , name .getName (), side , sources , mappings );
45- }
46-
47- /**
48- * Creates a new renamer for the given patcher.
49- *
50- * @param build The directory where the output will be stored
51- * @param name The development artifact, only used for the task name
52- * @param sources The task that creates the unnamed sources
53- */
54- public RenameTask (File build , String name , MCPSide side , Task sources , Mappings mappings ) {
45+ public RenameTask (File build , String name , MCPSide side , Task sources , Mappings mappings , boolean javadocs ) {
5546 this .name = name ;
5647 this .side = side ;
48+ this .javadocs = javadocs ;
5749 this .task = this .remapSources (sources , mappings .getFolder (build ), mappings );
5850 }
5951
@@ -73,21 +65,22 @@ public String name() {
7365 }
7466
7567 private Task remapSources (Task input , File outputDir , Mappings provider ) {
76- var output = new File (outputDir , "remapped.jar" );
68+ var output = new File (outputDir , ! this . javadocs ? "remapped.jar" : "remapped-javadoc .jar" );
7769 var mappings = provider .getCsvZip (side );
78- return Task .named ("remap[" + this .name + "][" + provider + ']' ,
70+ return Task .named ("remap[" + this .name + "][" + provider + ']' + (! this . javadocs ? "" : "[javadoc]" ) ,
7971 Task .deps (input , mappings ),
80- () -> remapSourcesImpl (input , mappings , output )
72+ () -> remapSourcesImpl (input , mappings , output , javadocs )
8173 );
8274 }
8375
84- private static File remapSourcesImpl (Task inputTask , Task mappingsTask , File output ) {
76+ private static File remapSourcesImpl (Task inputTask , Task mappingsTask , File output , boolean javadocs ) {
8577 var input = inputTask .execute ();
8678 var mappings = mappingsTask .execute ();
8779
8880 var cache = HashStore .fromFile (output );
8981 cache .add ("input" , input );
9082 cache .add ("mappings" , mappings );
83+ cache .add ("javadocs" , javadocs ? "true" : "false" );
9184
9285 if (output .exists () && cache .isSame ())
9386 return output ;
@@ -96,7 +89,6 @@ private static File remapSourcesImpl(Task inputTask, Task mappingsTask, File out
9689
9790 try {
9891 var names = MCPNames .load (mappings );
99- names .rename (new FileInputStream (input ), true );
10092
10193 // TODO: [MCMavenizer][Renamer] This garbage was copy-pasted from FG.
10294 // I changed the while loop to a for loop, though. I guess it is fine?
@@ -107,7 +99,7 @@ private static File remapSourcesImpl(Task inputTask, Task mappingsTask, File out
10799 zout .putNextEntry (FileUtils .getStableEntry (entry .getName ()));
108100
109101 if (entry .getName ().endsWith (".java" )) {
110- var mapped = names .rename (zin , false );
102+ var mapped = names .rename (zin , javadocs , javadocs );
111103 IOUtils .write (mapped , zout , StandardCharsets .UTF_8 );
112104 } else {
113105 IOUtils .copy (zin , zout );
0 commit comments