mirror of
https://hub.spigotmc.org/stash/scm/spigot/buildtools.git
synced 2025-09-18 21:45:56 +00:00
Improve maven execution code and add infrastructure for passing jenkins info to build
This commit is contained in:
parent
7fe93755c5
commit
7ca290a0c8
1 changed files with 36 additions and 29 deletions
|
@ -43,6 +43,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
@ -85,7 +86,10 @@ public class Builder
|
||||||
private static String applyPatchesShell = "sh";
|
private static String applyPatchesShell = "sh";
|
||||||
private static boolean didClone = false;
|
private static boolean didClone = false;
|
||||||
//
|
//
|
||||||
|
private static BuildInfo buildInfo = new BuildInfo( "dev", "Development", 0, null, new BuildInfo.Refs( "master", "master", "master", "master" ) );
|
||||||
|
//
|
||||||
private static File msysDir;
|
private static File msysDir;
|
||||||
|
private static File maven;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -275,7 +279,6 @@ public class Builder
|
||||||
clone( "https://hub.spigotmc.org/stash/scm/spigot/builddata.git", buildData );
|
clone( "https://hub.spigotmc.org/stash/scm/spigot/builddata.git", buildData );
|
||||||
}
|
}
|
||||||
|
|
||||||
File maven;
|
|
||||||
String m2Home = System.getenv( "M2_HOME" );
|
String m2Home = System.getenv( "M2_HOME" );
|
||||||
if ( m2Home == null || !( maven = new File( m2Home ) ).exists() )
|
if ( m2Home == null || !( maven = new File( m2Home ) ).exists() )
|
||||||
{
|
{
|
||||||
|
@ -296,15 +299,11 @@ public class Builder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String mvn = maven.getAbsolutePath() + "/bin/mvn";
|
|
||||||
|
|
||||||
Git bukkitGit = Git.open( bukkit );
|
Git bukkitGit = Git.open( bukkit );
|
||||||
Git craftBukkitGit = Git.open( craftBukkit );
|
Git craftBukkitGit = Git.open( craftBukkit );
|
||||||
Git spigotGit = Git.open( spigot );
|
Git spigotGit = Git.open( spigot );
|
||||||
Git buildGit = Git.open( buildData );
|
Git buildGit = Git.open( buildData );
|
||||||
|
|
||||||
BuildInfo buildInfo = new BuildInfo( "Dev Build", "Development", 0, null, new BuildInfo.Refs( "master", "master", "master", "master" ) );
|
|
||||||
|
|
||||||
if ( !dontUpdate )
|
if ( !dontUpdate )
|
||||||
{
|
{
|
||||||
if ( !dev )
|
if ( !dev )
|
||||||
|
@ -453,7 +452,7 @@ public class Builder
|
||||||
"BuildData/mappings/" + versionInfo.getPackageMappings(), finalMappedJar.getPath() ).split( " " ) );
|
"BuildData/mappings/" + versionInfo.getPackageMappings(), finalMappedJar.getPath() ).split( " " ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
runProcess( CWD, "sh", mvn, "install:install-file", "-Dfile=" + finalMappedJar, "-Dpackaging=jar", "-DgroupId=org.spigotmc",
|
runMaven( CWD, "install:install-file", "-Dfile=" + finalMappedJar, "-Dpackaging=jar", "-DgroupId=org.spigotmc",
|
||||||
"-DartifactId=minecraft-server", "-Dversion=" + versionInfo.getMinecraftVersion() + "-SNAPSHOT" );
|
"-DartifactId=minecraft-server", "-Dversion=" + versionInfo.getMinecraftVersion() + "-SNAPSHOT" );
|
||||||
|
|
||||||
File decompileDir = new File( workDir, "decompile-" + mappingsVersion );
|
File decompileDir = new File( workDir, "decompile-" + mappingsVersion );
|
||||||
|
@ -587,30 +586,18 @@ public class Builder
|
||||||
if ( compile.contains( Compile.CRAFTBUKKIT ) )
|
if ( compile.contains( Compile.CRAFTBUKKIT ) )
|
||||||
{
|
{
|
||||||
System.out.println( "Compiling Bukkit" );
|
System.out.println( "Compiling Bukkit" );
|
||||||
if ( dev )
|
runMaven( bukkit, "clean", "install" );
|
||||||
{
|
|
||||||
runProcess( bukkit, "sh", mvn, "-P", "development", "clean", "install" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
runProcess( bukkit, "sh", mvn, "clean", "install" );
|
|
||||||
}
|
|
||||||
if ( generateDocs )
|
if ( generateDocs )
|
||||||
{
|
{
|
||||||
runProcess( bukkit, "sh", mvn, "javadoc:jar" );
|
runMaven( bukkit, "javadoc:jar" );
|
||||||
}
|
}
|
||||||
if ( generateSource )
|
if ( generateSource )
|
||||||
{
|
{
|
||||||
runProcess( bukkit, "sh", mvn, "source:jar" );
|
runMaven( bukkit, "source:jar" );
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "Compiling CraftBukkit" );
|
System.out.println( "Compiling CraftBukkit" );
|
||||||
if ( dev )
|
runMaven( craftBukkit, "clean", "install" );
|
||||||
{
|
|
||||||
runProcess( craftBukkit, "sh", mvn, "-P", "development", "clean", "install" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
runProcess( craftBukkit, "sh", mvn, "clean", "install" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -621,13 +608,7 @@ public class Builder
|
||||||
if ( compile.contains( Compile.SPIGOT ) )
|
if ( compile.contains( Compile.SPIGOT ) )
|
||||||
{
|
{
|
||||||
System.out.println( "Compiling Spigot & Spigot-API" );
|
System.out.println( "Compiling Spigot & Spigot-API" );
|
||||||
if ( dev )
|
runMaven( spigot, "clean", "install" );
|
||||||
{
|
|
||||||
runProcess( spigot, "sh", mvn, "-P", "development", "clean", "install" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
runProcess( spigot, "sh", mvn, "clean", "install" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch ( Exception ex )
|
} catch ( Exception ex )
|
||||||
{
|
{
|
||||||
|
@ -739,6 +720,32 @@ public class Builder
|
||||||
return !result.getTrackingRefUpdates().isEmpty();
|
return !result.getTrackingRefUpdates().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int runMaven(File workDir, String... command) throws Exception
|
||||||
|
{
|
||||||
|
List<String> args = new LinkedList<String>();
|
||||||
|
|
||||||
|
if ( IS_WINDOWS && false )
|
||||||
|
{
|
||||||
|
// TODO: BUILDTOOLS-561
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
args.add( "sh" );
|
||||||
|
args.add( maven.getAbsolutePath() + "/bin/mvn" );
|
||||||
|
}
|
||||||
|
|
||||||
|
args.add( "-Dbt.name=" + buildInfo.getName() );
|
||||||
|
|
||||||
|
if ( dev )
|
||||||
|
{
|
||||||
|
args.add( "-P" );
|
||||||
|
args.add( "development" );
|
||||||
|
}
|
||||||
|
|
||||||
|
args.addAll( Arrays.asList( command ) );
|
||||||
|
|
||||||
|
return runProcess( workDir, args.toArray( new String[ args.size() ] ) );
|
||||||
|
}
|
||||||
|
|
||||||
public static int runProcess(File workDir, String... command) throws Exception
|
public static int runProcess(File workDir, String... command) throws Exception
|
||||||
{
|
{
|
||||||
if ( msysDir != null )
|
if ( msysDir != null )
|
||||||
|
|
Loading…
Add table
Reference in a new issue