Errors in Eclipse (Spring Tool Suite) in Spring Security - spring-security

I'm attempting to become a contributor for Spring Security, it's not going so well. I am getting validation errors in Spring Tool Suite although the build/compilation of the .gradle project is succeeding. The errors show up in the "Markers" view in Eclipse. Here is what I've done so far.
Forked the Spring Security master branch on Github
Copied the https URL for my forked branch
In Spring Tool Suite, Import->Git->Projects from Git->Clone URI
After #3 Spring Tool Suite downloaded the project from Git
Spring Tool Suite prompted asking me what type of project to create
I selected "Import as a general project"
I deleted the project from my workspace (but did not delete it on disk)
I imported the project using Import->Gradle->Gradle project and the recommended settings
After everything finishes building, I get the following error in Spring Tool Suite:
The error is accompanied by several messages including the following:
Pointcut cannot be resolved to a type
The method aspectOf() is undefined for the type ...
The method proceed() is undefined for the type ...
This error can be fixed (with an ugly hack) if I open the Eclipse .project file and add the following:
<buildSpec>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
</natures>
Question
How can I properly set up my development environment? What should I look into for figuring out why I'm getting these errors? I'm currently researching how the gradle/maven configurations relate to the Eclipse .project file, but I have not gotten very far yet.

Here is what works for me (and what I discussed with Rob Winch):
download STS 3.7.2 (not the latest 3.7.3, it has a few issues when importing spring-security projects) from https://spring.io/tools/sts/all. There is a link to previous versions of STS. There you find STS 3.7.2.
install Groovy-Eclipse into that from here: http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/
install the Gradle STS tooling from here:
http://download.springsource.com/release/TOOLS/update/3.7.2.RELEASE/e4.5
after installing all the components mentioned above, import the spring-security projects using the STS Gradle support ("Import -> Gradle -> ...")
it might take a while, but after downloading the necessary artifacts, all those projects should appear in your workspace. The "aspects" one has an error marker on it. Right-click on the project, go to the Groovy context menu entry, and do the "remove Groovy nature" (or something like that). That removes the groovy tooling for that project and it compiles fine.
After all those steps, I get a workspace with all those projects compiling fine. But it looks like we could/should simplify this procedure in the future using an Eclipse Oomph setup file maybe. But that is a story for the future.
Hope this helps!!!

I found this walkthrough on how to bring spring projects into eclipse via gradle. It actually looks like it was based on Spring Security which might create a nice process flow for you.
My guess is, eclipse is not defaulting to use the gradle configuration for its dependency management.

Related

Adding in-place plugin to grails 3 project

In grails 2.x, we were allowed to add an in place plugin by adding following in BuildConfig.groovy
grails.plugin.location."my-plugin" = "../my-plugin"
My question is, can we add our local plugins similarly in-place in grails3.0 as well or there is some other way to do this in grails.
Actual purpose is to test the plugin whether it's working properly or not before pushing it to bintray.
Yes, there is. Grails 3 is based on Gradle so multi-project gradle builds solve your issue.
Basically you add dependency as:
compile project(':../my-custom-plugin')
and has to modify settings.gradle to include plugin:
include '../my-custom-plugin'
Check Grails documentation on Plugins and Multi-Project Builds in http://grails.github.io/grails-doc/latest/guide/plugins.html
Other way is to install plugin in local maven repository using gradle publishToMavenLocal command and resolve if from there, before publishing to Bintray or other dependency repository.
Additionally since Grails 3.1.1, reloading is now supported for 'inline' plugins. Check https://github.com/grails/grails-core/releases/tag/v3.1.1 and http://grails.io/post/138665751278/grails-3-gradle-multi-project-builds
It is done using grails { plugins { syntax. Copied from docs:
grails {
plugins {
compile ":hibernate"
compile project(':myplugin')
}
}
This multi-project thing is a bit too big to answer in a short post. I just recently started with it, but, thankfully, I now have the hang of it. There's a tutorial on my site with a plugin handling the domain classes and services and all other sub-projects (just one, a web application in this example) using the plugin. The code is also downloadable. Here's the link: http://www.databaseapplications.com.au/grails-multi-app.jsp Make no mistake, there are a few things to watch out for.

How to generate zip file for a grails plugin

I wrote a Grails plugin, lets say PluginA which has dependency on another plugin, lets say PluginB, which I wrote myself too, these both plugins are being used by a main project. I am trying to build a continious integration system for this project using jenkins, so far I managed to setup everything in Jenkins. But while building the project, I get this error
Zip C:\Users\me\project\PluginA\grails-PluginA-0.1.zip is not a valid plugin
So, how do I generate that zip file, I noticed that all my other plugins have that zip file but I don't remember building them. I also tried to do a grails compile-plugin but I got an error saying that few classes were not found as they were in PluginB. So, how can I specify that PluginA has dependency on PluginB while running a grails command?
It's not entirely clear, but I believe the problem you are having occurs when trying to build the main project and not the plugins, so I will address that situation.
Since the error message mentions a zip file, I will also assume you are using Grails 2.x. If you are using Grails 3.x, then stop reading now and add info on how you are specifying your dependencies.
Key info: In my experience plugins don't come with their dependencies; I've had to re-declare them in my top-level projects. I have no idea if that is the intent of the grails plugin design, but I have found it works to do so.
Step 1: Build PluginB and install it to your local maven repo using
grails maven-install
Step 2: Specify PluginB as a dependency for PluginA in its app/conf/BuildConfig.groovy
Step 3: Build PluginA and install it to your local maven repo using the same command as for PluginB.
Step 4: In your main project, specify dependencies on BOTH PluginA and PluginB in app/conf/BuildConfig.groovy
Step 4 is the key.
If I've misinterpreted your problem, sorry about that! Please provide some more detail on exactly which part is failing and I'll let you know if I have any info on it.

Grails - Maven - STS

I am relatively new to this and still bit puzzled how the Maven dependencies (in pom.xml) and the Grails dependencies (in BuildConfig.groovy) hang together.
When I choose Convert to Grails Project... in STS (Springsource Tool Suite) it seems to list the different (i.e. the Grails) dependencies.
Do I have to keep them in synch if I wanna receive a WAR file with mvn package/install? Sometimes I get weird build error and I am always unsure where to look for a fix.
Can anyone shed some light on this please?
Regards
Jonas
It sounds like you are using a mavenized grails project. See this bug report:
https://issuetracker.springsource.com/browse/STS-596
When working with a mavenized grails dependency you can work with a grails project, but make sure to turn off dependency management from right-click -> Grails Tools -> Disable Dependency Management.
There is not much tooling support for these projects since the STS grails tooling relies on calling grails to determine project structure and dependencies. But, when using maven, grails is not called directly and the Grails tooling is not initialized.

What is the .link_to_grails_plugins folder used for?

Background: I'm just learning Groovy and Grails. I inherited a project from someone who has disavowed themselves of it completely, so I'm basically just thumbing around blindly. I am using the Springsource IDE.
My source had a number of plugin dependencies. I attempted to install these via the plugin manager but one plugin (image-tools) was not available through that medium and needed to be installed separately. I've been unable to install it or the others, as I always end up with build errors which apparently reverts the partial plugin install. While search for references to the image-tools plugin which I could comment out in an attempt to get SOMETHING compiling correctly, I found the .link_to_grails_plugins directory, which seemed to contain the source of all the necessary grails plugins.
Adding this to my classpath and rebuilding seemed to let me make some progress, but I'm not sure if that's what I should actually be doing. Can someone explain to me what this folder is used for? Google hasn't been particularly helpful.
.link_to_grails_plugins is not a standard Grails directory - it has been created by the STS IDE.
The Grails plugins are cached in the grails.project.plugins.dir and grails.global.plugins.dir as described in the documentation for Customizing the Build:
The image-tools plugin documentation indicates that it must be built from the source and provides the instructions for doing so.

Grails and hudson plugin issue

I'm developing my first project in Grails framework. I'm using Spring Security Core plugin. On my machine, on newest IntelliJ Idea everything works fine. I can run, test and so on with no problems.
I have a remote machine with subversion where I upload my code and Hudson with Grails Plugin. Target which I call on my hudson builds is:
"test-app --non-interactive"
When I run build, everything goes fine - plugins are downloaded and then, bam!
Resolving plugin JAR dependencies ...
:: UNRESOLVED DEPENDENCIES :: ::::::::::::::::::::::::::::::
:: org.springframework#org.springframework.test;3.0.5.RELEASE: configuration not found in org.springframework#org.springframework.test;3.0.5.RELEASE: 'master'. It was required from org.grails.internal#League;0.1 test
Here I put whole output from Hudson Console of this project build.
That looks like a dependency issue with the Mail plugin, try going back to a non-snaphot version. I think 1.0 will be out shortly but see if 0.9 works.
Grails will automatically install the plugins it needs, you don't need to do anything manual on the build server.
You have to install the plugin of the remote machine. Because the plugins are not included in the code. The plugin will be installed under your_home/.grails/grails_version/plugins (or project/your_project).

Resources