Dagger2 Set up in Java with Ant in Eclipse - java

I am having trouble in setting up Dagger 2 sample cofee app in Eclipse using Ant. We have huge source code built using Ant so we cannot switch to maven. And I can find no sources anywhere which explains how to do that.
I have created a sample project, included all the dependencies and compiled. But, how do I generate the auto generated code of Dagger and reference it.
For example when I do
CoffeeShop coffeeShop = DaggerCoffeeApp_CoffeeShop.builder().build();
Compiler in eclipse complains that DaggerCoffeeApp_CoffeeShop cannot be found.
Can somebody please help with providing me a way to set up Dagger2 with Ant?
Thanks.

Related

Compilation error in Eclipse in Kotlin + Java project, but project builds with Maven

This happens in a Java and maven project in Eclipse with a kotlin nature.
In this part of the code:
val faces = figure.getFaces()
for (polygon in faces) {
//...
I get the error below in eclipse, where faces, in the second line above, is underlined in red:
Cannot access class 'Polygon'. Check your module classpath for missing or conflicting dependencies
The project is a mix of Java and Kotlin. The figure object is an instance of a Java class, while the faces are a set of type Polygon which is in a different project that is pure Kotlin (ie Polygon is a Kotlin type, in a separate Kotlin project).
This Kotlin project where Polygon is, is indeed in the classpath as a Maven dependency, and in fact used by the Java class of which figure is an instance.
I think the problem is in Eclipse, because I can build the project with maven successfully. It looks like either a bug in eclipse or a configuration issue.
I know it's strange to have a mix of Java and Kotlin. I simply started this project in Java and then decided to convert it to Kotlin gradually. So far I haven't had many issues but I'm aware that Kotlin tools and support in eclipse are not mature yet.
Not much of a proper solution: I converted my Figure class to Kotlin and the problem went away, but I can do that because I have full control on my project.
Possibly newer versions of the eclipse plugin won't generate this error or, as suggested in the comments, switching to IntelliJ IDEA is another option.

Eclipse & Xtext - DSL Editor not working on deployment

I've implemented a DSL using the Xtext framework on the Eclipse IDE. Additionally, I've created several UI features (Import/Export handlers, for example) that are available when I run my Eclipse Application.
Now I'm trying to deploy my application as a standalone product. I created a ".product" file in the ".ide" package of my project and everything works when I run my application from that ".product" file.
However, when I DO deploy it, I run the generated ".exe" file and the editor fails when I create a ".mydsl" file (I don't even get the prompt to convert the project to an Xtext project). The error is:
Failed to create injector for org.xtext.myDsl.Mydsl ExtensionFactory: org.xtext.myDsl.Mydsl.MydslExecutableExtensionFactory
I'm totally clueless with this, as I don't believe I'm missing any plugin imports... what could I be missing?
Any help is greatly appreciated! Thanks!
These kind of issues is ususally caused by some inconsistencies in your eclipse metadata in build.properties. Make sure all source folders and resources like the manifest and the plugin.xml are listed there. You should get a warning in eclipse like
There is a quickfix for the issue as well.

Problems compiling AutoValue library example project

I just discovered google's AutoValue library, which seems great.
I'm trying to compile the example project which I downloaded from here
But the project doesn't compile.
The compiler complains about the AutoValue_ constructor symbol not being recognized.
Can someone explain what I am doing wrong?
I am using auto-value-1.3.jar
Thanks
IntelliJ does not enable annotation processors by default.
You can follow the official guide. You need to go to the Annotation Processors page and click + to create a new profile. Then you have to associate your module with this profile. In the end you only need to enable annotation processing for this profile and everything should work.
The IntelliJ editor might not find the generated class files though and still display the name red. But it should not affect the build.

How do you create a custom project type (from my plugin) without opening Eclipse?

I have created a plugin for Eclipse. With the help of this plugin, I am creating a new type of project, let's say XTypeProject. The creation of this XTypeProject is similar to any other type of project you create in Eclipse.
File -> New -> YourProjectType
I just want to know whether there is any way I can create a simple XTypeProject in Eclipse through some external mechanism, anything, and this project created through an external mechanism has to be similar to the project I create using Eclipse. Can Maven help me in this? Or is there any other way to do that?
Here are my findings :-
I went through the advice of Amos M. Carpenter and searched for the source code of the plugin that I have written.
After that, I did a debug (Plugin Debug) and searched for the methods that are called when we create a project from the Eclipse menu.
I took a note of all those class files and their methods that are called and the information/parameters they need for further processing.
I initiated the same call through ANT and was able to do what I wanted.
Thank you for the support.
P.S - I can't share my Plugin details as it is written for an organisation.

Tool for creating Dynamically Generated Code in Java (In Eclipse)

In Visual Studio land, I used to be able to define a structure in an XSD file and add a special attribute to it which would cause it to be dynamically compiled and available to use with intellisense in the other C# files in the application. I am not sure exactly what the term for this is, perhaps "dynamic code generation."
I am trying to accomplish the same in Java using Eclipse IDE. Basically what I am looking for is a tool that will allow me to specify some template and generate Java code from it in a "hot folder" that will allow me code complete in the other static Java files.
Does anyone know of a solution for this? I know it is possible in Visual Studio, but I can't seem to find anything for Eclipse.
Ok, here is exactly what I want to do.
Step 1. I create a folder called templates
Step 2. I create a file called HelloWord.ibes
Step 3. Code it automatically generated in my src folder HelloWorld.java
I want to be able to do this in eclipse easily.
You may create an ant build file that does the source generation for you. Then you are free to use any code generator you like. Ant support is part of the eclipse IDE. If you prefer maven, there's a nice eclipse pluging available (that's what I actually use for source code generation based on jaxb, javacc and xdoclet...).
Technically spoken, you just add another eclipse builder which is invoked anytime eclipse detects a change in your code base.
If you already have a code generator in mind, just 'ask' the internet if there's a plugin available.
Edit
On how to install a builder: This is done automatically. For maven, you just install the maven plugin (m2eclipse) and enable maven dependencies for a project. Then if you look at the projects properties pages (Builder section), you find a second entry in the list of builders.
It's similiar with ant, even easier, because ant is already integrated. "enable" ant for a project and the builder is added to the list of builders for the project. You can deselect it at any time if it kills performance or switch of automatic building (I don't know by heart how to enable ant builds for a project, but I remember that the eclipse help had sufficiant informations).
All about ant can be found here: Apache Ant
Creating a new builder is difficult, as it has to be coded in java and added to eclipse as a plugin. I bet you don't want to follow that track ;)
I'm not sure whether you have seen the code template option?
Preferences.Java, Code Style then Code Templates
How
to add code templates
Useful
code templates

Categories

Resources