I am learning Akka and am trying out Akka remoting. I am using the intellij IDE and the language being used is Java. I tried running the AKKA remote example (Calculator). I am not using the sbt tool. How do I build the application and run it. I tried running the example, but I dont think it is reading the configuration files correctly and is not creating a remote actor. I have included the akka jar files in the project. I have created a simple java project in intellij to run the program.
Am I doing it the right way?. What are the alternate ways to build and run the same. How to use sbt with Java.
You can create Dependencies.scala and Versions.scala under project folder; which again you can use with build.sbt.
build.sbt is very similar to build.xml with maven. You can define libraryDependencies and assembly file name, etc.
For example you can refer https://github.com/asethia/akka-streaming-graph/tree/master/project in detail.
Related
I am quite new to gradle, currently working on a java project where I have to migrate from ANT to Gradle. The ANT scripts compile and create .class files at the java code location itself. While In Gradle it stores all output class files in build/classes directory. Is it possible to create class files at the code location in Gradle? I was thinking that would make the migration a bit easy for me to follow. If it is not possible, is there a reason why Gradle uses separate output folder? Thanks.
You can certainly configure Gradle to however you like. For example, to change the output of the compileJava task, you would change destinationDirectory property.
Gradle has a dedicated guide on migrating from ANT to Gradle: Migrating Builds From Apache Ant
is there a reason why Gradle uses separate output folder?
Well, it is a different build tool, but mainly because it is by convention. Both Maven and Gradle follow this convention and it is well established.
let's assume I have an android project in IntelliJ.
Now, I am changing some details on the strings.xml resource file, and after every change I build a new apk.
I want to create a second program that will automatically build an apk file. I could change the parameters for the strings.xml file, and then build automatically without accessing IntelliJ, is it possible? will it only be related to Java language? or could I build it in C# or any other language as well?
I did read about Maven and Ant, but I have no idea how to use them correctly, I would like an answer that will lead me to some examples or tutorials as well, thanks!
The common approach is to use three things:
Build system (Ant, Maven or Gradle) - for Android apps Gradle is
becoming standard
Version Control System (e.g. Git)
Continuous Integration Server (Jenkins, Travis or
other)
Gradle Build System
When you create default project in Android Studio, you already have it created with Gradle. Android Studio also allows you to convert project from Ant to Gradle. I cannot explain you, how to use Gradle in a single post, as it can be subject for whole article or even book. Basically, you have build.gradle file in which you can define dependencies in your project and build configuration. You can have installed Gradle in your system, but good practice is to use Gradle Wrapper, which is a single *.jar file and it can be used to build your application. Once you have your project configured with Gradle, you can build it from command line as follows:
./gradlew build
On MS Windows:
gradlew.bat build
Continuous Integration Server
When you have your project configured with Gradle, you can push its source code to your Git repository and create a job on your Continuous Integration server, which will be responsible for building your project. Within the build, you can create an artifact with compiled *.apk file, execute tests and run static code analysis. You can trigger your job via Git commit hooks or via polling on Continuous Integration server. It depends on chosen technology stack, but it can be automated.
If you want a lot of customization and free solution, Jenkins CI would be a good choice, but you'll have to configure a lot of stuff by yourself and host server by yourself. In my opinion, such choice can make sense in a team projects, when you have appropriate infrastructure and time to set it up. If you want an easy configuration and you're willing to spend some money or create an open-source project, I recommend using GitHub and Travis CI. It's also a good choice for individual developers. I'm not sure how to generate artifact with *.apk file on Travis CI, but I suppose it can be done and you can always ask support to help you. For sure, artifact be archived in Jenkins CI job.
I have the following situation:
I am trying to write a little project in Java which should produce a single EAR file which contains a single WAR. There might be some JARs in the future, but it is not important now.
I need to use gradle for build automation and Intellij for developing. I have some problems with synchronization between those tools.
I have prepared a gradle project ‘ear-app’ with the ‘ear’ plugin applied. It depends on a second project ‘web’ which is war. It works well with gradle wrapper. ‘build’ task builds ‘ear’ file.
Unfortunately Intellij has not recognized the
‘ear’ artifact. In “Project Structure”, there is only web application artifact which comes from ‘web’ project.
Is it possible to make Intellij be able to recreate ‘ear’ artifact?
I do not keep intellij files in my repo, so I need a solution which bases on gradle configuration.
Seems like this was asked over here in the meantime, and got this response from ɐuıɥɔɐɯ:
Seems automatic artifact configuration is not implemented yet in IDEA
it might be a stupid question but how do I set up an environment to develop a test application using libvirt?
do I have to set up ant or maven project or can I just copy java files to my src folder in eclipse ?
Thanks
If you use Eclipse, you can build your classes and run your program in Eclipse without using Ant or Maven. In fact, Eclipse is usually completely ignorant of your Ant build.xml or your Maven pom.xml file. Eclipse uses its own build technology (although you can ask it to run your pom.xml or build.xml). However, a pure Eclipse way of building a project means there is no way to build and run your project except with Eclipse. If you have a continuous integration system, or someone downloads your project and simply wants to build your jar or war file, there's no way they can do it.
Actually, not entirely true. You could write a shell script to compile your code via the javac commands and jar it up via the jar command. What Maven and Ant do is give you a framework to help build your application and remove system dependencies.
Ant has an advantage of flexibility. You can do things easily in Ant that are harder to do in Maven. The disadvantage is that Ant has the flexibility to do things in a really, really bad way. I almost always recommend for developers to use Maven for new projects. It forces them to write their project in a standard way, and eliminates the need to write Ant build scripts which most developers really can't do.
What if you don't know Maven, but know Ant? I still recommend that you use Maven and take this as an opportunity to learn Maven.
What is the most proper way to accomplish all of the following:
Create a project in Eclipse
With an Apache Ant buildfile
That Hudson (or another more recommended CI system?) uses
And support for JUnit tests that are run by both Ant/Hudson and Eclipse
And check the proper folder structure into SVN so that future developers can replicate the build, and Hudson can automatically grab from SVN and run the Ant file to build/test/deploy the project
And the project has native libraries, if that makes any difference (I've already written an Ant task that can download and unzip the proper library files depending on the OS)
I already have my project with some source files and an Ant file, but I've been having trouble integrating it with Eclipse in an organized manner, so I would really love to start from a fresh Eclipse project, set it up correctly, and then copy my Ant file and my source files piece-by-piece into the project in the most Eclipse-compatible way.
I will be continuing to play around with everything in an attempt to get it working as I like it. But if you have experience with this sort of thing, perhaps at your workplace, please give as much information as you can.
My main goal here is to learn this once and use it in my future projects. For now, I am developing a client-server application consisting of a JOGL applet frontend (using JNLP files) and an unattended server app. Up until now I've been doing it all by hand: writing and building in Eclipse, dragging the applet jar into my FTP client, SSHing the server jar and restarting it by hand, and all with no testing process. I'm hoping that by the end, the build process will be something like this: test locally on my machine with a copy of the native libraries; commit code changes to SVN; Hudson svn updates, uses the Ant buildfile to compile and run all JUnit tests; if all the tests pass, it proceeds to copy the server jar to my dedicated server and restart the running server instance, and then copy the client jar to my web server.
When I start a new project, I generally take the following steps:
Create a new Java project in Eclipse, using the Java project wizard and opting to keep source and class files in separate directories ('src' and 'class')
Set up the project in Eclipse with the package structure you want
Create a new repository (or folder in your repository) for the project, with the normal /trunk/ /branches/ /tags/ set up
Using your SVN client, import the contents of the project folder Eclipse made for the project (at the level where the 'src' and 'class' directories are) into the trunk of the repository
Confirm everything is in Subversion correctly (check the trunk out to a new location)
Using Eclipse, delete the project (and the files on disk)
Create a new project using the 'Checkout projects from SVN' wizard, using the trunk of the repository
Create your Ant script, ensure the project builds correctly, and add the Ant script to the repository
Now, from Hudson:
Create a new job and set the Subversion URL to the root of the repository
Add a build set that will use Ant (I've always had to install my own version of Ant and ensure it's configured correctly to have this work) and will call the Ant script you
Use 'Build Now' to see if the job will build correctly
You can invoke your JUnit tests from Ant in the build script (first compile them with the javac task, then run them with the junit task). Hudson will track the test results if you ask it to.
You can use a shell script build step to copy your server jar to where it's needed, and restart the server instance. Like Mnementh said, it sounds like you've got the native libraries sorted...
If you are not tied to using ant, and are prepared to use Maven, then it is simply a matter of setting up Maven with the Eclipse plugin which generates the Eclipse projects for you.
Hudson already knows how to build Maven projects, so that is taken care of.
So long as you can pull your projects into eclipse, then it will be able to run the unit tests, and hudson can use the previously mentioned maven support to run the unit tests as well.
If you use Maven, then you will want to follow it's guidelines on how to create a project, here is a good starting point.
Hope this helps.
At our company we actually use Eclipse, Java, Ant, SVN, Junit and Hudson. That is all you mentioned except the native libraries. If you said your ant-buildscript already works with the native libraries that problem seems solved too. To integrate it well into eclipse you could do it in two ways: Use Ant also from Eclipse (has downsides) or the developer has to install the native library for his machine properly, so that Eclipse can compile without a problem and for continuous integration it will be downloaded by Ant.