During development, our Android app is built using Eclipse (ADT). We use an eclipse feature called Linked Resources, which allows eclipse to compile files outside of the source tree.
It works well on eclipse, but when trying to compile from the command line (using android update project and ant), ant/javac won't find the linked resources (as they are defined in the eclipse project).
How can I make it work? Do I need to manually add the additional source dir to build.xml (which was auto-generated by android)? Is there an android setting I should use?
You could put the paths of the extra source code in the source.dir line of ant.properties in your project directory. Something like this:
source.dir=src;../ExtraSource;../MoreSource/java
See http://code.google.com/p/android/issues/detail?id=21205 for more discussion. Apparently they took this feature out at some point but it looks like they have put it back in since then.
Are you using referencing library? If so, you need to tell ant where it can find the referencing library (typically in project.properties)
android.library.reference.1=/pathToReferenceLibrary
A referencing library is where you want to keep all classes and resouces that you want to reuse between different android projects.
Related
I'm trying to setup the Scichart libraries using this guide.
The library I downloaded has a structure that looks like this:
I copied the 5 .aar files and the 4 documentation .jar files into the libs folder of the app in Android Studio, like so:
Following a guide I read online (I've never added an external library before) I found that for the documentation to work I'd need to add it as an attachment here:
However, when I right clicked and went to library properties it looked like it already had it - I assume that since the files are in the lib folder in the app they're seen and used.
So, everything should work. The problem is that Android Studio is offering to import one of two classes with the exact same package name but different Gradle packages (? don't know if that's the right term) on the right. Picture:
Why is it doing this? What did I do wrong when adding the library?
Per tutorial (Tutorial 01), the sections
Using Maven (well it's more Gradle)
Using bare SciChart libs
Are mutually exclusive.
If you already referenced their libraries via build.gradle (as described in the tutorial, Using Maven part), you don't need (and don't have) to put JAR(s) inside any folder and then add them to the Module settings, or whatever. Even sources will be pulled down automatically.
What you're doing is creating a local repository, in addition to using the remote one. That's why the duplicated libraries.
I have recently started using Sightly in AEM 6.1, which allows the Java files to be located in the same folder as the component and use the WCMUse class. However, I am noticing that whenever I do a Maven build that involves a change to one of those Java files that the page functionality operates as if the Java class had not been changed, though the Java file in the crx does include the changes. As a workaround I have been been able to modify the Java file in the crx, save it, then modify it back and save again in order to update the functionality, but I do not have that capability on all of my instances.
Anybody have an idea how to force the recompile of the Sightly Java within the components either during or following the build?
A few things to validate:
1- Do you change the version of the software when doing a maven build/deploy? Sometime if your zip or jar does not have -SNAPSHOT in it AEM won't update the code when maven deploys.
2- there a /var/classes/sightly in CRX/DE that you can delete compiled classes, I think even in the system console there is an entry
Hope this help.
Bambara actually helped me get to the answer that I needed. It turns out the /var/classes folder holds the compiled sightly files, but it doesn't naturally recompile on build. Deleting that folder on build, then running a page that uses the sightly code forces a recompile and shows the new functionality.
Hopefully others can answer why this happens and how to avoid it. Having faced this a number of times, I'm beginning to think placing Java code into the component folders is not a very good idea. Using a maven multi-module project with a Services/Core bundle, then all Java code could go there. Calling it from the view just requires using the fully qualified classname (including the package). Placing the Java into the services bundle has the following benefits
Allows the classes to be extended. For some reason compilation was unpredictable when extending classes from component folders.
Easier IDE setup. Java classes in component folders in the view module have a Sling specific folder structure, so getting IDE's to provide code assist requires extra effort.
Sling folder conventions follow URI practices and might have dashes, Java packages cannot have dashes... import apps.my-cool-project.components.pages.base.Header; // won't compile
I downloaded an API from Uniprot, which is a protein database, to play around with their code. This is my first time working with an API. The API contains a folder of source files (which includes example code for developers), a folder for classes, a library of JAR files, and an executable command file to run the example code (in cmd, I must execute: runExample.cmd InsertExampleCodeHere )
How do you edit this API? I tried making my own Java project, linked it to the JARS I downloaded, and also transferred over the executable cmd program to my Java project folder. At first, I copied over some of the example code, and added some print statements. When I saved my changes and executed the cmd file, my main class cannot be found. If I tried compiling my java project, I get a bunch of errors - and these errors apply to the example codes Uniprot provides (and while linked to the library of JARs). Is there a particular call (or special command) I must make when compiling my projects?
Thanks in advance!
Hmm, not sure myself as the only real API I was using was a JSON one so I could easily parse it. But, assuming you have a folder that contains of all that, I would imagine you could try to just copy it over to your project's folder and then just add it to build path in a similar vein to how you would add jars. At least that's what I can think of.
Also, you could try this which is a solution I found from the Stackoverflow question titled "How do I important the javax.servlet AOI in my Eclipse project?"
Quick Fix- This worked in Eclipse - Right Click on project -> Properties -> Java Build Path (Tab) -> Add External JARs -> locate the servlet api jar implementation (if Tomcat - its named servlet-api.jar) -> click OK. That's it !!
I'm programming in Java, and I usually prefer git when programming in Python. So I want to use it for Java too. I'm using Eclipse, but other people may use Netbeans or IntelliJ IDEA or whatever. How is this usually managed when putting Java code into version control?
I'm making a game which uses the library LWJGL, and that library needs to be added to the project file to be used. Therefore, I still need to check the project file into my project.
Short answer, it doesn't matter at all. Create a file called .gitignore in the root of your project file to ignore your IDE's project files or anything like that, then add your code into the git repository. For example, a good Eclipse .gitignore can be found here.
That way the other collaborators won't see your project files, and if they do the same with their .gitignore for their IDE, you won't see theirs.
I'm currently working in a big java project with quite a few submodules that are worked on by different teams. Some of these teams are building the "framework", others are building the "application" based on the framework.
When the framework guys move or rename a class, the applications guys get compile errors wherever they are using a refactored framework class. Is there a way in Eclipse (Galileo Release) to record the change and update the references in another workspace?
What I've tried so far is creating a refactoring script during the rename refactoring, but when I try to apply that script to another workspace, it fails with The refactoring 'Rename Type' (org.eclipse.jdt.ui.rename.type) cannot be performed, since its input 'xxx.TestClass" does not exists. Well, it does not exist (anymore) alright, but what I want is for all references for xxx.TestClass in my project to be changed to xxx.MyRenamedTestClass. Is there a way in Eclipse to do this with built-in functionality or an existing plugin or do I have to write one myself?
Thanks for your help!
EDIT: By now I found out that the "Migrate JAR"-Plugin provides the functionality I am looking for, although we build our JARs with Maven, not Eclipse. I'm going through the source code now to find out what parts I can reuse.
Answering my own question to get some closure here.
The easiest way to do it is to use the Migrate JAR File... refactoring which uses a refactoring script in META-INF called REFACTORINGS.XML. You can get a JAR with this included automatically by using Export JAR in Eclipse. We build with Maven and thus just do Refactoring->Create Script... and put it into the appropriate position in the JAR.
The JDT-internal code that Migrate JAR executes creates Stubs for the source classes in a temporary source folder, so it actually executes the refactoring first and then updates the references. The user never gets to see these temporary files.