Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Java 17 #31

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'maven-publish'

import java.nio.file.*

sourceCompatibility = 1.8
sourceCompatibility = 1.17

// Avoid weird configuration-time dependency bugs
// Fun fact: this line of code single-handedly fixed an error I spent two hours debugging.
Expand All @@ -20,8 +20,8 @@ if (!project.hasProperty("maps")) {
}

if (project.hasProperty("release_version")) {
if (!project.property("release_version").startsWith("2021")) {
throw new StopExecutionException("release version must start with 2021!")
if (!project.property("release_version").startsWith("2022")) {
throw new StopExecutionException("release version must start with 2022!")
}
}

Expand All @@ -39,7 +39,7 @@ dependencies {
scala group: 'org.scala-lang', name: 'scala-reflect', version: '2.11.7'
}

def serverJar = new File(project(":engine").libsDir, "engine.jar")
def serverJar = new File(project(":engine").libsDirectory.getAsFile().get(), "engine.jar")

task buildMap(type: JavaExec, dependsOn: [':engine:build']) {
main = 'battlecode.world.maps.' + project.property('buildMap')
Expand Down Expand Up @@ -152,8 +152,6 @@ task runFromClient(type: JavaExec, dependsOn: [':engine:build', ':internal-test-
}




task run(dependsOn: ['headless']) {}

task runClient {
Expand Down Expand Up @@ -271,7 +269,6 @@ task releaseClientLinux32(type: Zip, dependsOn: ['prodClient']) {
}



task updateVersion() {
// new File("frontend/public/version.txt").write(project.findProperty('release_version'))
}
Expand All @@ -296,11 +293,10 @@ publishing {
publications {
server(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21'
artifactId 'battlecode22'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact release_main


artifact release_docs {
classifier 'javadoc'
Expand All @@ -312,39 +308,39 @@ publishing {

clientWin(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21-client-win'
artifactId 'battlecode22-client-win'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact releaseClientWin
}

clientMac(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21-client-mac'
artifactId 'battlecode22-client-mac'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact releaseClientMac
}

clientLinux(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21-client-linux'
artifactId 'battlecode22-client-linux'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact releaseClientLinux
}

clientWin32(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21-client-win-32'
artifactId 'battlecode22-client-win-32'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact releaseClientWin32
}

clientLinux32(MavenPublication) {
groupId 'org.battlecode'
artifactId 'battlecode21-client-linux-32'
artifactId 'battlecode22-client-linux-32'
version project.findProperty('release_version') ?: 'NONSENSE'

artifact releaseClientLinux32
Expand Down
24 changes: 10 additions & 14 deletions engine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@


apply plugin: 'java'

sourceCompatibility = 1.8
sourceCompatibility = 1.17

sourceSets {
main {
Expand Down Expand Up @@ -30,17 +28,17 @@ repositories {
}

dependencies {
compile (
implementation (
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'],
[group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'],

// normal dependencies
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'],
[group: 'commons-cli', name: 'commons-cli', version: '1.3.1'],
[group: 'commons-io', name: 'commons-io', version: '2.4'],
[group: 'org.ow2.asm', name: 'asm', version: '5.0.4'],
[group: 'org.ow2.asm', name: 'asm-tree', version: '5.0.4'],
[group: 'org.ow2.asm', name: 'asm', version: '9.1'],
[group: 'org.ow2.asm', name: 'asm-tree', version: '9.1'],

// Flatbuffers
[group: 'com.google.flatbuffers', name: 'flatbuffers-java', version: '1.11.0'],

Expand All @@ -56,28 +54,26 @@ dependencies {

)

// Javadoc manipulation libraries
compile files(System.getenv('JAVA_HOME') + '/lib/tools.jar')

// Testing dependencies
testCompile (
testImplementation (
[group: 'junit', name: 'junit', version: '4.12'],
[group: 'org.mockito', name: 'mockito-core', version: '1.10.19'],
[group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3']
)
}

jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}

javadoc {
includes = ["**/common/**"]
options.windowTitle = "Battlecode 2017"
options.windowTitle = "Battlecode 2022"
options.classpath = sourceSets.main.compileClasspath as List
options.doclet = "com.sun.tools.doclets.standard.Standard"
options.doclet = "jdk.javadoc.doclet.StandardDoclet"
options.taglets = ["battlecode.doc.CostlyMethodTaglet", "battlecode.doc.RobotTypeTaglet"]
options.tagletPath = ( sourceSets.main.output.classesDirs as List )+ sourceSets.main.compileClasspath
}
2 changes: 1 addition & 1 deletion engine/src/main/battlecode/common/MapLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This class is an immutable representation of two-dimensional coordinates
* in the battlecode world.
*/
public final strictfp class MapLocation implements Serializable, Comparable<MapLocation> {
public final class MapLocation implements Serializable, Comparable<MapLocation> {

private static final long serialVersionUID = -8945913587066072824L;
/**
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/battlecode/common/RobotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* controls the newly created robot.
*/
@SuppressWarnings("unused")
public strictfp interface RobotController {
public interface RobotController {

// *********************************
// ****** GLOBAL QUERY METHODS *****
Expand Down
29 changes: 16 additions & 13 deletions engine/src/main/battlecode/common/RobotType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,49 @@ public enum RobotType {
* Archons are portable buildings that heal and generate robots.
* Losing all archons means losing the game.
*
* @battlecode.doc.robot */
* @battlecode.doc.robottype */
ARCHON ( 0, 250, 10, 24, 1000, -2, 20, 34, 20000),
// BCL BCG AC MC HP DMG AR VR BL

/**
* Alchemist's laboratory
* Converts lead into gold
* Alchemist's laboratory.
* Converts lead into gold.
*
* @battlecode.doc.robot */
* @battlecode.doc.robottype */
LABORATORY (800, 0, 10, 24, 100, 0, 0, 53, 5000),
// BCL BCG AC MC HP DMG AR VR BL

/**
* Guard turret
*/
* Watchtower building.
*
* @battlecode.doc.robottype */
WATCHTOWER (180, 0, 10, 24, 130, 5, 20, 34, 10000),
// BCL BCG AC MC HP DMG AR VR BL

/**
* Can mine gold or lead at their or an adjacent location.
*
* @battlecode.doc.robot */
* @battlecode.doc.robottype */
MINER ( 50, 0, 2, 20, 40, 0, 2, 20, 7500),
// BCL BCG AC MC HP DMG AR VR BL
/**
* Can build and repair buildings.
*
* @battlecode.doc.robot */
* @battlecode.doc.robottype */
BUILDER ( 40, 0, 10, 20, 30, -1, 5, 20, 7500),
// BCL BCG AC MC HP DMG AR VR BL

/**
* Ranged attacking robot.
*/
*
* @battlecode.doc.robottype */
SOLDIER ( 75, 0, 10, 16, 50, 3, 13, 20, 10000),
// BCL BCG AC MC HP DMG AR VR BL

/**
* Gold robot, causes Anomalies.
*/
*
* @battlecode.doc.robottype */
SAGE ( 0, 50, 200, 25, 100, 45, 13, 20, 10000)
// BCL BCG AC MC HP DMG AR VR BL
;
Expand Down Expand Up @@ -303,4 +306,4 @@ public int getGoldDropped(int level) {
this.visionRadiusSquared = visionRadiusSquared;
this.bytecodeLimit = bytecodeLimit;
}
}
}
69 changes: 21 additions & 48 deletions engine/src/main/battlecode/doc/CostlyMethodTaglet.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,47 @@
package battlecode.doc;

import battlecode.instrumenter.TeamClassLoaderFactory;
import battlecode.instrumenter.bytecode.MethodCostUtil;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.Taglet;
import java.util.List;
import java.util.Set;

import com.sun.source.doctree.DocTree;
import javax.lang.model.element.Element;
import jdk.javadoc.doclet.Taglet;

import java.util.Map;
import battlecode.instrumenter.bytecode.MethodCostUtil;

/**
* A taglet for the "battlecode.doc.costlymethod" annotation.
* Only works on methods of classes in the battlecode package.
*/
@SuppressWarnings("unused")
public class CostlyMethodTaglet implements Taglet {

public static final String TAG_NAME = "battlecode.doc.costlymethod";

@SuppressWarnings("unused")
public static void register(Map<String, Taglet> map) {
map.put(TAG_NAME, new CostlyMethodTaglet());
@Override
public Set<Taglet.Location> getAllowedLocations() {
return Set.of(Taglet.Location.METHOD);
}

@Override
public String getName() {
return TAG_NAME;
}

public boolean inConstructor() {
return false;
}

public boolean inField() {
return false;
}

public boolean inMethod() {
return true;
}

public boolean inOverview() {
return false;
}

public boolean inPackage() {
return false;
}

public boolean inType() {
return false;
}

@Override
public boolean isInlineTag() {
return false;
}

public String toString(Tag tag) {
final String methodName = tag.holder().name();
final String fileName = tag.holder().position().file().toString();

// Note: this makes an assumption that this method is in the battlecode/ package.
final String className = fileName.substring(fileName.lastIndexOf("battlecode/"),
fileName.length() - 5); // remove .java
@Override
public String toString(List<? extends DocTree> tags, Element element) {
if (tags.size() != 1) {
throw new IllegalArgumentException("Too many @"+TAG_NAME+" tags: "+tags.size());
}
Element parent = element.getEnclosingElement();
return docFor(element.getSimpleName().toString(), parent.getSimpleName().toString());
}

public String docFor(String methodName, String className) {
final MethodCostUtil.MethodData data =
MethodCostUtil.getMethodData(className, methodName);

Expand All @@ -78,12 +59,4 @@ public String toString(Tag tag) {
+ cost +
"</code></dd>";
}

public String toString(Tag[] tags) {
if (tags.length != 1) {
throw new IllegalArgumentException("Too many @"+TAG_NAME+"tags: "+tags.length);
}

return toString(tags[0]);
}
}
Loading