Include java project into android build - java

I've got such a problem
I have to include external java project into my android build.
The project structure is:
Alpha - project with shared classes and libs.
Beta - android project that uses files from alpha
Gamma - desktop java project that uses files from alpha.
Everything works fine on Eclipse, but I need it to work on Jenkins.
I'm using Google Android SDK (android update project command) to create a build.xml, and then I'm using google targets to do what I need (build, emma, clean and so on)
The problem is that this build.xml does not include files and libs from alpha project, so it basically failes at first line of beta build task.
My question is:
How to properly add alpha project as a dependency for a googles generated build.xml file?
Should I compress alpha to .jar and then add it somehow to beta (how?)
Should I just link it somehow?
Thanks for all help.
[I'm new to ant scripting so please write in plain engish:P]

Yep, this sucks! When using Jenkins and sharing one lib-project on different projects, you'll have to compile your lib-project (alpha), as you already mentioned, copy the jar to the respective directory of both projects, and link them in the Build Path Settings.
This is quite a lot of ANT-Stuff, you'll have to look into, but don't get discouraged, it ain't rocket science :)
Basically you have to do this:
Create an Ant-script that compiles your shared project, and copies it to some lib-directory in both projects
Link the Jar in the Build Path of your desktop and android project
For Jenkins: Customize android's build.xml (e. g. add a new target), so that it executes the lib project's build.xml (compile the project and copy the jar).
Run it on Jenkins
If you don't want to compile the shared project (manually) each time before you run your android or desktop project in eclipse, you should add the shared lib's build.xml with the respective targets to the projects' builder settings (in Eclipse -> right click on Project -> Properties -> Builders -> add the new builder between the Java and the Android package builder).
Sorry dude, I don't know any other way. Maybe there is another solution out there, I haven't used Jenkins for a year.

Related

Gradle script for custom web project

I have a web project with 2 src folders. First is in businessServices >> commonServices and Second is in iSo >> src .
Now i have to write gradle script to build this project. i want a war and jar to deploy on tomcat.. Since this is not the standard gradle project, I am unable to generate the same. Please help.
I have added the screenshots to get the idea of project structure.
I think multi-src project is not a feasible solution, U can go with multi-project build.
Multi-project builds helps with modularization. It allows a person to
concentrate on one area of work in a larger project, while Gradle
takes care of dependencies from other parts of the project.
https://guides.gradle.org/creating-multi-project-builds/

How can I add Normal Java project capabilities to EJB project in Eclipse (.ear)?

Just started working with EJB (already developed project).
Imported the project from git and converted it to Maven project. However the project looks like a normal folder structure unlike regular java project. I cannot have any eclipse Java capabilities in side those files. Though they are Java files they look like class files to me with different symbol (can see that in image).
It won't compile unless I do maven build. Eclipse not showing any errors for those files even there are compile errors.
Running each time maven kills time and its irritating too.
Any help will be greatly appreciated. How to make that a normal Java project with eclipse compiler capabilities.
What configuration I have to do achieve this ?
Try running the command mvn eclipse:eclipse from the root folder of the project. It will create eclipse configuration files after which the project can be imported in Eclipse.

Intellij Idea compiler recompiles already compiled project

I use maven command which cleans,builds whole project, creates war and deploys to server. I cannot use Intellij to do that since I have only Community edition. It builds the project in same directory as intellij.
To speed things up I wrote a script which finds compiled files in local "target" directory which are newer than the ones in server and copy them. It all works okay but the problem is Intellij does not see classes compiled with maven as the ones it should skip and rebuilds whole project all over.
Currently it works like this:
Manually in terminal build whole project with maven
Go back to intellij -> make project
Rebuilds all
Run script -> it swaps all files
What I am trying to achieve:
Manually in termin build whole project with maven
Go back to intellij. Change one file -> make project
Compiles only one java file
Run script -> it swaps only one .class file
So the problem is how do I make intellij treat files already compiled with external tool as compiled?
You don't. IntelliJ IDEA has its own incremental compilation system which tracks the dependencies between files being compiled and recompiles the minimum set of classes for every set of changes. External compilation with tools like Maven or Gradle does not update IntelliJ IDEA's incremental compilation database. Because of that, IntelliJ IDEA cannot recognize the fact that classes have been already compiled with an external tool, and will recompile.
That troubled me for long time. Finally, i found this .
IDEA build settings
You can choose whether use InteliJ or gradle to compile when runnning program. Under gradle project, it uses gradle to build by default.

How to combine one android studio project into another android studio project

I have two separate android app projects that were made in android studio I am trying to combine project 1 into project 2 to make it all one app how would I go about doing this? I know how to do it in eclipse but not in android studio.
Please note they are both of these projects are android applications none of them are android libraries.
Any help would be amazing!
When I import project 1 into project module I get this error on grade build:
Warning:Dependency School Tools Calc lib.gz:SchoolTools:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: /Users/chrisdebrodie/Documents/School Tools Calc lib.gz/SchoolTools/build/outputs/apk/SchoolTools-release-unsigned.apk
You cannot have two "projects" as a single project in Android Studio.
Convert one (or both) project into libraries. Then create a "shell" project to build each app. The shell project is basically empty, or it may have build specific value overrides. The advantage here is that you can modify the library and changes will be immediately reflected in both/all versions. The drawback is that you will have to fix any issues in all projects that result from any change to any library. But you can then create the "combined" project in a similar manner.
After you convert one or both to a library you can create an aar file. This gives you the option to then include that aar as a gradle dependency. Be careful to remember that you will need to re-build the aar every time you modify that project - so if you have an indication as to which is the more stable codebase, go with that for the aar. This gives you the ability to "version control" the main project dependency so that you can make changes to one project without impacting the stability of the other.
Additionally, you can write scripts and use tools like Bamboo or Jenkins to do real-time updates to the aar - but that is like using a "snapshot" dependency. When you change the aar it may compile, but it may break the build of the second project without you knowing it until you do a build on that project. (And yes, you can include a build on that project as a part of the Bamboo or Jenkins script, but it isn't easy.)
There may be other alternatives, but these seem to offer enough options to produce a wide variety of build options.
I write a repo to handle this staff safely and easily: Jacksgong/android-project-combine.
Characteristics:
Just a developing env wrapper, it can't modify projects, safe to use.
Different Android projects develop together at the one Android Studio window.
Find References and Jump into source code rather than .class file on jar package.
Jump out of the each projects compile system and using the official compile system.
Very light, very fast for each time you want to refresh combine project.
Add one project as a module of the another's. This answer explains how to do it. Note that this answer is in response to adding a library dependency, but it will work for your situation as well.

Add scala capabilities into an existing EJB eclipse project

I have an existing EJB project set up in Eclipse Helios, and would like to slowly introduce Scala into the project. The Scala IDE has been installed successfully, and I'm able to create standalone scala project. The issue however comes when trying to use my existing project with scala additions. I've went as far as manually editing the .project, .classpath, and related files under .settings of the project's home directory for eclipse.
However I still have the issue where the Java compiler tries to compiles .scala classes, which results in errors and ultimately not being able to build the project.
Has anyone faced a similar scenario or are there any workarounds?
Thanks in advance.
You should be able to right-click the project, go to "Scala" and click on "add scala nature". Then .scala files should be recognized as such. You might also have to add the scala library to your dependencies. Depending on whether this is a "simple" Eclipse project or you're using Maven there might be other steps required.
Right click on project, and choose Configure/Add Scala Nature.

Categories

Resources