{"action":"created","issue":{"url":"https://api.github.com/repos/itdelatrisu/opsu/issues/126","labels_url":"https://api.github.com/repos/itdelatrisu/opsu/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/itdelatrisu/opsu/issues/126/comments","events_url":"https://api.github.com/repos/itdelatrisu/opsu/issues/126/events","html_url":"https://github.com/itdelatrisu/opsu/pull/126","id":103301285,"number":126,"title":"Migrated to the Gradle build system","user":{"login":"LemonLake","id":858456,"avatar_url":"https://avatars.githubusercontent.com/u/858456?v=3","gravatar_id":"","url":"https://api.github.com/users/LemonLake","html_url":"https://github.com/LemonLake","followers_url":"https://api.github.com/users/LemonLake/followers","following_url":"https://api.github.com/users/LemonLake/following{/other_user}","gists_url":"https://api.github.com/users/LemonLake/gists{/gist_id}","starred_url":"https://api.github.com/users/LemonLake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LemonLake/subscriptions","organizations_url":"https://api.github.com/users/LemonLake/orgs","repos_url":"https://api.github.com/users/LemonLake/repos","events_url":"https://api.github.com/users/LemonLake/events{/privacy}","received_events_url":"https://api.github.com/users/LemonLake/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":55,"created_at":"2015-08-26T15:42:35Z","updated_at":"2015-08-27T15:21:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/itdelatrisu/opsu/pulls/126","html_url":"https://github.com/itdelatrisu/opsu/pull/126","diff_url":"https://github.com/itdelatrisu/opsu/pull/126.diff","patch_url":"https://github.com/itdelatrisu/opsu/pull/126.patch"},"body":"It took a while, but I've migrated the project to Gradle. IntelliJ has built in support for gradle, I'm not sure about Eclipse but it probably does. \r\n\r\n## IntelliJ Usage\r\nTo use this in IntelliJ, you first need to reopen the project. `File -> Open`, then navigate to the `build.gradle` file and simply open that. Next, make sure that you have selected a valid `JAVA_HOME` location and you can optionally enable `Auto import` if you don't want to have to run `gradle build` every time the build file changes. Click Next or Finish or whatever.\r\n\r\nThe project will sync for a few minutes, and the structure will change a few times during this process. Don't panic, it should work when the import is over. Next, go into `Run -> Edit Configurations` and click the green +, choose `Gradle`. Name the configuration `run`, set the Gradle Project to the `build.gradle` file, and set the task to `run`. \r\n\r\nNext, you need to unpack the LWJGL natives. You will only ever have to do this once, unless you clean  the project or delete the target folder. In the gradle panel on the right of the screen, double click `opsu -> Tasks -> other -> unpackNatives`. It should take a few seconds to unpack the natives, and that is all. You can now run the project.\r\n\r\nFinally, to compile a fat jar, you can run the `build -> build` task. It will build to `target/libs/opsu-(version).jar`.\r\n\r\n## Eclipse usage\r\nI'm not too sure about Eclipse usage, but it should be as simple as importing the `build.gradle` similar to above, and running the tasks.\r\n\r\n## Gradle tasks\r\n`unpackNatives`\r\n  Unpacks the LWJGL natives from the jar and places them in `target/natives`\r\n\r\n`run`\r\n  Builds and runs the project\r\n\r\n`build`\r\n  Builds the project and produces a fat jar containing the libraries and natives. `NativeLoader` is a class that works similar to the JarSplice launcher - it looks for top level `dll`, `so`, `jnilib` and `dylib` files inside the jar and extracts them to a temporary directory, which is finally set as the classpath.\r\n\r\n\r\nYou can run a gradle task in the CLI by running `gradle <task>`.\r\n\r\n## build.gradle explanation\r\nThe gradle file is initially a bit complicated, but it's actually pretty simple.\r\n\r\n```gradle\r\n// Loads the Java plugin\r\napply plugin: 'java'\r\n// Loads the Maven plugin, used to import Maven dependencies\r\napply plugin: 'maven'\r\n// Loads the Eclipse plugin, if you run the task 'gradle eclipse' it will create Eclipse project files for you.\r\napply plugin: 'eclipse'\r\n// Loads the IntelliJ Idea plugin. If you run the task 'gradle idea' it will create IntelliJ project files for you.\r\napply plugin: 'idea'\r\n// Loads the application plugin. This is used for creating runnable jars and fat jars.\r\napply plugin: 'application'\r\n\r\n// The Group ID\r\ngroup = 'itdelatrisu'\r\n// The project version\r\nversion = '0.10.1'\r\n\r\n// The main class\r\nmainClassName = 'itdelatrisu.opsu.Opsu'\r\n// By default, gradle builds to (root)/build. I just made this (root)/target for compatibility\r\nbuildDir = new File(rootProject.projectDir, \"target/\")\r\n\r\n// Java version to use when compiling the java source\r\nsourceCompatibility = 1.7\r\n// Java version to use for the classes\r\ntargetCompatibility = 1.7\r\n\r\n// The source directories\r\nsourceSets {\r\n    main {\r\n        java {\r\n            // The main module's java source is in (root)/src\r\n            srcDir 'src'\r\n        }\r\n        // Files to be copied to the root of the jar\r\n        resources {\r\n            // The resources are in (root)/res\r\n            srcDir 'res'\r\n             // Also copies the natives to the jar for NativeLoader to load them.\r\n            include 'target/natives'\r\n        }\r\n    }\r\n}\r\n\r\n// Load repositories from Maven\r\nrepositories {\r\n    mavenCentral()\r\n}\r\n\r\n// The dependencies, of course\r\ndependencies {\r\n    compile 'org.lwjgl.lwjgl:lwjgl:2.9.3'\r\n    compile 'org.slick2d:slick2d-core:1.0.1'\r\n    compile 'org.jcraft:jorbis:0.0.17'\r\n    compile 'net.lingala.zip4j:zip4j:1.3.2'\r\n    compile 'com.googlecode.soundlibs:jlayer:1.0.1-1'\r\n    compile 'com.googlecode.soundlibs:mp3spi:1.9.5-1'\r\n    compile 'com.googlecode.soundlibs:tritonus-share:0.3.7-2'\r\n    compile 'org.xerial:sqlite-jdbc:3.8.6'\r\n    compile 'org.json:json:20140107'\r\n    compile 'net.java.dev.jna:jna:4.1.0'\r\n    compile 'net.java.dev.jna:jna-platform:4.1.0'\r\n    compile 'org.apache.maven:maven-artifact:3.3.3'\r\n    compile 'org.apache.commons:commons-compress:1.9'\r\n    compile 'org.tukaani:xz:1.5'\r\n    compile 'com.github.jponge:lzma-java:1.3'\r\n}\r\n\r\n// A list of folders that lwjgl hides the natives in\r\ndef nativePlatforms = ['windows', 'linux', 'osx']\r\n// For each platform, and disable some weird false warning in IntelliJ\r\nnativePlatforms.each { platform -> //noinspection GroovyAssignabilityCheck\r\n    // Adds additional tasks for single-platform native unpacking\r\n    task \"${platform}Natives\" {\r\n        // Outputs to target/natives\r\n        def outputDir = \"${buildDir}/natives/\"\r\n        inputs.files(configurations.compile)\r\n        outputs.dir(outputDir)\r\n        doLast {\r\n            copy {\r\n                def artifacts = configurations.compile.resolvedConfiguration.resolvedArtifacts\r\n                        .findAll { it.classifier == \"natives-$platform\" }\r\n                artifacts.each {\r\n                    from zipTree(it.file)\r\n                }\r\n                into outputDir\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n// Adds the unpackNatives task, which looks for other xNatives tasks and 'depends on' them, essentially executing them before this one\r\ntask unpackNatives {\r\n    description \"Copies native libraries to the build directory.\"\r\n    dependsOn nativePlatforms.collect { \"${it}Natives\" }.findAll { tasks[it] } }\r\n}\r\n\r\n// Defines the format for the jar when running the 'jar' task, this is a function added by the application plugin\r\njar {\r\n    manifest {\r\n        attributes 'Implementation-Title': 'opsu!',\r\n                'Implementation-Version': version,\r\n                'Main-Class': mainClassName\r\n    }\r\n  \r\n    // This allows us to override the slick classes\r\n    duplicatesStrategy = DuplicatesStrategy.EXCLUDE\r\n    // Base filename\r\n    baseName = \"opsu\"\r\n    // Marks everything in the source directories to be added to the jar\r\n    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/itdelatrisu/opsu/issues/comments/135467223","html_url":"https://github.com/itdelatrisu/opsu/pull/126#issuecomment-135467223","issue_url":"https://api.github.com/repos/itdelatrisu/opsu/issues/126","id":135467223,"user":{"login":"itdelatrisu","id":7078123,"avatar_url":"https://avatars.githubusercontent.com/u/7078123?v=3","gravatar_id":"","url":"https://api.github.com/users/itdelatrisu","html_url":"https://github.com/itdelatrisu","followers_url":"https://api.github.com/users/itdelatrisu/followers","following_url":"https://api.github.com/users/itdelatrisu/following{/other_user}","gists_url":"https://api.github.com/users/itdelatrisu/gists{/gist_id}","starred_url":"https://api.github.com/users/itdelatrisu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itdelatrisu/subscriptions","organizations_url":"https://api.github.com/users/itdelatrisu/orgs","repos_url":"https://api.github.com/users/itdelatrisu/repos","events_url":"https://api.github.com/users/itdelatrisu/events{/privacy}","received_events_url":"https://api.github.com/users/itdelatrisu/received_events","type":"User","site_admin":false},"created_at":"2015-08-27T15:21:57Z","updated_at":"2015-08-27T15:21:57Z","body":"Great, thanks!\r\n\r\nOne last thing from that commit, the `jar` task shouldn't depend on `unpackNatives` since it isn't copying the natives from that directory, but from the dependencies (I think I mentioned this a while ago)."}}