yeeter 490 Share Posted March 3, 2020 Saw some people having issues with Dreambot and libs. Thought I would yeet this in the snippets real quick to save someone else the trouble of writing their own. This is a premade pom file for Maven. If you are unfamiliar with Maven it is a build automation tool created by Apache. It is great for managing dependencies for building self contained private scripts so no more lib/dependency fuckery. For starters in the properties change the dreambot.path to wherever your DreamBot folder is located. On Windows this is C:/Users/yeeter01/Dreambot <properties> <dreambot.path>C:/Users/yeeter01/DreamBot</dreambot.path> </properties> To add dependencies its as simple as going out to a maven repository like https://mvnrepository.com/ and finding the dependencies you want to use. I will use google protobuf and simple json for this example <dependencies> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.11.0</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java-util</artifactId> <version>3.11.0</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>dreambot</groupId> <artifactId>client</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${dreambot.path}/BotData/client.jar</systemPath> </dependency> </dependencies> Now for the part that was a pain in my ass initially.. the build. We will use the maven-shade plugin in order to create a shaded jar. This is just a fancy uber jar. Jar packaging information -> https://dzone.com/articles/the-skinny-on-fat-thin-hollow-and-uber Apache Shade plugin information -> https://maven.apache.org/plugins/maven-shade-plugin/ <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <shadedClassifierName>dep-included</shadedClassifierName> <outputDirectory>${dreambot.path}/Scripts</outputDirectory> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> Smash that maven build button and BOOM! Out comes 2 jar files. 'original-yeetware-0.0.1-SNAPSHOT' and 'yeetware-0.0.1-SNAPSHOT'. The file with the original prefix is the normal jar generated by maven. The other will be your shaded jar which can be thrown into the scripts folder ready to rock. You can get really fancy with this and auto output the script into there, delete the original, upload to a fileserver etc but this was just a barebones example. FULL FILE <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.db.yeet</groupId> <artifactId>yeetBarrowsPort</artifactId> <version>0.1</version> <name>plz work</name> <properties> <dreambot.folder.path>C:/Users/yeeter01/DreamBot</dreambot.folder.path> </properties> <dependencies> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.11.0</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java-util</artifactId> <version>3.11.0</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>dreambot</groupId> <artifactId>client</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${dreambot.path}/BotData/client.jar</systemPath> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <shadedClassifierName>dep-included</shadedClassifierName> <outputDirectory>${dreambot.path}/Scripts</outputDirectory> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> *Disclaimer* I am no maven expert so probably better ways to do it. depwession, yetanotherbot, relleum and 8 others 4 7 Link to comment Share on other sites More sharing options...
Bot Tom Frag 2 Share Posted March 3, 2020 Thanks for sharing. Pretty sweet, and I like that you can rename dependencies internally. yeeter 1 Link to comment Share on other sites More sharing options...
Defiled 415 Share Posted March 3, 2020 Quality snippet. Gj yeeter yeeter 1 Link to comment Share on other sites More sharing options...
kamilo 7 Share Posted September 14, 2020 this man is a genius, tysm bro repped ! Link to comment Share on other sites More sharing options...
Hmm 31 Share Posted October 4, 2020 TYVM. Very, very helpful. Link to comment Share on other sites More sharing options...
botmaker_01 0 Share Posted September 30, 2021 Thanks Yeeter! btw, is it possible to do this but implementing scripts in Kotlin? I don't personally like writing in Java 😕 Link to comment Share on other sites More sharing options...
Pandemic 2445 Share Posted September 30, 2021 3 hours ago, botmaker_01 said: Thanks Yeeter! btw, is it possible to do this but implementing scripts in Kotlin? I don't personally like writing in Java 😕 It's the same setup, and you can make scripts with Kotlin, although I don't think we have any guides specific to that (?). Please note that while local scripts are fine with Kotlin, they can't be added to our public SDN (if that was your plan at all). Link to comment Share on other sites More sharing options...
botmaker_01 0 Share Posted October 9, 2021 On 10/1/2021 at 2:59 AM, Pandemic said: It's the same setup, and you can make scripts with Kotlin, although I don't think we have any guides specific to that (?). Please note that while local scripts are fine with Kotlin, they can't be added to our public SDN (if that was your plan at all). If I show the code and the pom.xml file for the dependencies n stuff it still can't be added? (not sure if I'm planning to add anything it anyways). For me it just seems that Kotlin is the way to go as it's basically more functionalities for less code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now