I currently have a Java project in Netbeans 7.3, which contains a settings.java class. Within that class are 3 booleans that turn on/off various features of the program (eg: trial, full, etc).
Although it is one project in Netbeans, it actually produces 6 different versions of the program, which I currently have to manually create by editing the variables, compiling and copying, editing the variables, compiling and copying.... six times. This is rather time consuming and inefficient.
Is there a way for my to accomplish the 6 builds without manually editing->compiling six times?
Thanks!
----EDIT----
Thanks for the help! In case anybody has a similar question, I ended up writing a java class that modifies the settings file and compiles using ant.
My solution: https://gist.github.com/patopop007/5561428
Two possible solutions come to mind:
Create several NetBeans project. One will be a library which contains all the code common between all the different builds. Then create a new NetBeans project for each of the separate builds.
Create different custom ant targets in your NetBeans file for each build. For example
<target name="trial">
<!-- Stuff specific to the trial build goes here. -->
</target>
<target name="full">
<!-- Stuff specific to the full build goes here. -->
</target>
The specifics depend on the exact differences between the builds.
Related
Here is the situation: I have a large project and I made breaking changes that affect many files but I want to test these changes on these files in small groups. Which means I want in each phase to run the project and compile only say for example 3 files to see how they are affected by these changes, and the rest of the files must not be compiled (the project runs normally with only these 3 files compiled for example). I tried commenting all the code in these unwanted files but this solution is not practical as there are too many of them, I am searching if there is a solution like giving a command line option to exclude these files without touching them or any other similar clean solution.
note: I mentioned flutter just in case it may be relevant and I don't think I should provide any code for this question
I have a code base scattered across tens of repositories.
I want to standardize names of packages and classes, but it's too tedious to do it by hand in IDE, since I need a dictionary based renaming across repositories.
Is there a way programmatically rename classes and packages across many repositories?
A similar thing for a different language: https://metacpan.org/pod/App::EditorTools
Eclipse, and just about every other major IDE, can do this rather trivially. Load the project into the IDE (most can read the project if it is built by maven or gradle, just by saying you want to 'import an existing maven java project' or some such, possibly after installation a maven and/or gradle plugin - if it's not a project built by such tools, then just import an existing java project and tell eclipse about where the source files live).
Then, right click the package, pick refactor/rename, rename it, and eclipse (or intellij, or any other major java IDE) will rename the directory, update the package statement in every source file inside it, and will update all imports or any other reference, and will even search for strings that contain that exact name in case you're doing weird reflective shenanigans and tell you that those probably also need to be updated.
It's not quite programmatic, but this sounds like it'll be much easier and faster than actually using e.g. ecj or writing an eclipse app that will run without a user interface to apply these refactor scripts.
I am creating a system that will compile first and second year java programs, at the moment I have it compiling single Java files.
As I was starting to try and get the system to compile projects with multiple classes, it accord to me that being first and second year students they are not going to hand up the projects all in the same format.
I was trying to research this all yesterday but could not find out much of about things like:
What are to main differences between Netbeans and Eclipse projects when compiling
How to compile projects in jar files
Just the different formats in general
So my question is, is there a compiler out there that compiles all the different formats, or do you have to set up the different formats to a certain way to compile them?
Any examples of this as well?
Make it a requirement to use Maven to build (yes it has it's faults, but at least you'll get consistency).
What I understand is you want something that can compile all types of Java projects (NetBeans, Eclipse, etc.)
Sorry to say this but there isn't one that can compile all the formats out there. But you could write your own, for at least the most common types of formats that you receive from the students.
Check out this page for more information: Building Java Projects.
What I suggest is, start by studying the build architecture used by those tools (NetBeans, Eclipse, etc.) and come up with a build script of your own that can extract the class paths of all the classes in the java project. Let your script do the work for you!
If you don't wish to write your own scripts, then you may consider changing the projects you receive into a standard project format. Check out this and this link to see more about migrating from Ant to Maven or Maven to Ant.
Else, you can always manually port your existing projects into other IDE, provided they follow the same build mechanism. Check out this answer to know more.
I have a web project. I build it using maven(complete all stages in every module, then archiving each module to *.jar and then making war-file).
If I change one line of code in one class I need to run maven build script and it takes ~5 minutes.
How can I see my changes without building the whole application if I changes are within one class and one method?
You should use IntelliJ IDEA for building your project and its Artifacts in the exploded form, so that the classes can be reloaded with hotswap.
With such configuration you can update your application much faster. Also check the tutorials.
For even faster updates consider using JRebel.
You could consider using JRebel. You will need to have a valid license.
You can also can try open source tools just take a look this hotswaping tutorial:
http://www.asjava.com/core-java/how-to-hotswap-java-code-into-jvm-redefinition-example/
I'm new to Android and wanted to use AspectJ with it.
I had searched couple articles online and follow the instruction to have it working:
http://blog.punegtug.org/2010/11/adding-aspect-to-android.html
But I wanted to know whether if it's possible to separate the aspects away from the Android project. In the tutorial link above, it has both the Android App and the aspects inside the same project, but in many cases, we wanted to leave the Android Project untouched in its isolating spaces.
Let said I have AndroidProject in my Eclipse workspace, I would like to create a separate projects for my aspects called something like "AndroidAspectProject" which only contains the aspects for it.
I'm not sure whether this would work because it seems we need to let AspectJ compiler inject point cuts and advices to the .class files before creating the .dex files. In this sense, I may not able to do it in a separate project.
Does anyone try with this?
Another related question would be:
Is it possible to have Ant build the AndroidProject with AND without aspects on it? Can this be done outside of Eclipse?
I'm looking for a way to build different flavours as I'm only injecting pointcuts into the AndroidProject on dev/debug build, but will leave it untouched on release build.
Whether or not to do the compile-time aspects is a matter of whether or not you run the aspectj ant tasks. Have separate targets or properties for the AOP- and non-AOP-builds and either build one based on a target name or property, or build them both and change the artifact name.
IIRC Eclipse allows you to specify an Ant target to run on a build.
Inside of Eclipse, this is simple. Just add AndroidAspectProject to the aspect path of AndroidProject.
Inside of ant, there are several ways of doing this. But, the simplest is to define 2 targets. One that uses iajc and the other that uses javac to compile your sources. You then need to use a little ant magic switch between targets depending on whether you are compiling for dev or for production.