How to add project dependency (classes from another module/folder) in Grails? - grails

Is there a way for me to add dependencies from other folders/projects(non-grails, but definitely java projects) into my grails project? I've tried searching but didn't really get much of an answer. :(

You can use every possible library which is in a maven repository. So transform your java project to a maven or gradle project. Install your builded jar to maven repo and then you can add dependency in grails-app/conf/BuildConfig.groovy.
dependencies {
compile "your.group:your.artifact:1.0"
}

You have to get the code into your project somehow.
These are the options:
JAR
Package your module as a jar file and copy this to your project's lib/ directory.
source code
Copy the source code for your module into src/java/
Maven Artifact
Package your module as a maven artifact, and specify it in the dependencies closure of grails-app/conf/BuildConfig.groovy.
Read more in the grails documentation at http://grails.org/doc/latest/guide/conf.html#configurationsAndDependencies

Related

Importing classes from jar file in grails

I have downloaded and copied the http-builder-0.5.0-RC2.jar to the lib folder of my grails project. I am using GGTS and see the jar in my lib folder when I open the project.
BuildConfig.groovy has the following line in the dependency section:
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2'
When I try to reference a class from the jar the I am getting a reference error indicating the class name cannot be resolved.
Is there something I am missing in regards to importing classes from a jar file? I am new to java / groovy and would appreciate some help. Thanks.
import groovyx.net.http.HTTPBuilder
This results in:
Groovy:unable to resolve class groovyx.net.http.HTTPBuilder
I have downloaded and copied the http-builder-0.5.0-RC2.jar to the lib folder of my grails project.
This should not be necessary, since HttpBuilder is in Maven Central. Just declare the dependency and let Grails download the JAR itself along with its transitive dependencies. You may also want to consider using a more recent version of HttpBuilder (0.5.0-RC2 is from 2009, at the time of writing the current release is 0.7.1).
Delete the JAR from your lib directory and try refreshing your Grails dependencies again.

Missing maven dependencies in project converted from java to maven

I converted a Java project to maven project. But there are still maven dependencies not in the build path. There maven dependencies do not show up in the lib path.
Once you have converted your project to maven (i.e) you have to do the following in eclipse:
Right Click on your and select Maven --> Update Project
This will rebuild your eclipse and all dependencies that is defined in that project pom.xml will be added to your build path under Maven Dependencies.
In general all your dependencies will be downloaded to .m2 folder in your system. This will generally be inside your home directory unless you change it in the settings.xml.

How can I remove a classpath entry from Grails dependencies in GGTS

I mistakenly added some jars to Grails dependencies using Java build path dialogue of GGTS.
Now I want to remove them.
But the build path dialogue offers no chance to do so.
Just remove the project from eclipse, delete .project and .classpath files. regenerate eclipse files using command grails integrate-with --eclipse and import the project again and you classpath should be good.

How can I compile a primefaces source?

In the download section of primefaces there are 3 links:
binary
bundle
sources
I use primefaces 3.4.2 and would like to recompile one java class to fulfill my needs.
I downloaded the sources. Now I would like to recompile this class, but I don't know how to achieve that. How can I compile a primefaces source?
From primefaces site:
http://code.google.com/p/primefaces/wiki/BuildingFromSource
PrimeFaces uses maven as the build tool. There's a custom maven plugin to generate jsf artifacts. To begin you might need to check out and build PrimeFaces maven-jsf-plugin in case the version used is not available in Prime Repository.
svn checkout http://primefaces.googlecode.com/svn/maven/trunk/maven-jsf-plugin/ build
cd to the build and do a maven install
cd build
mvn install
Next thing to do is to build PrimeFaces itself, checkout the code with;
svn checkout http://primefaces.googlecode.com/svn/primefaces/trunk
cd to the primefaces folder and run maven build.
cd primefaces
mvn install
Component Development
PrimeFaces JSF plugin generates the necessary artifacts including component sources, faces-config.xml, and facelets taglib. Component developers only need to implement the Renderer classes of the components. Component metadata files are defined under src/main/resources-maven-jsf folder.
Checkout sources from repo. It is maven project, so build it with maven.

How to build project dependencies from source jar-s with maven

I have a project, which is building with maven 3. While building project maven downloads a lot of dependencies (jars). I want to build all this dependencies from source-jars, which I get from maven repository with maven dependency plugin.
But this source jars doesn't contain any pom or other things for building. How I can build them with maven??
You can't. You need to get the source from the project's source repository. The source-jars are just for helping developers debug dependencies.

Resources