Clojure pedestal.io code is not resolved in IntelliJ - clojure

I have a small application of Clojure and Pedestal that I grabbed from pedestal.io tutorial. It works fine in the terminal. When I open it in IntelliJ some "cannot be resolved" tips are appearing. And some code parts are getting a beige background.
I have Cursive plugin installed. The code is executed by boot repl. Is any way to resolve full code by IntelliJ? If so, which settings?
Update
"Indexed Maven Repositories" field

Check your settings to make sure both Clojars and Maven repos are indexed:
Navigate to:
File
-> Settings
-> Build, Execution, Deployment
-> Build Tools
-> Maven
-> Repositories
And make sure it looks like the above picture. If necessary, highlight both the Maven & Clojars repos and click "Update", then "OK" (you don't need to wait for it to finish as it is a background process).
Also, it is frequently helpful to do
File
-> Invalidate Caches / Restart
Then it will resolve correctly:
Update #2
OK, I see you have a boot project. I have a lein project, and Cursive populated my list automatically (from project.clj I assume). Two ways forward:
Search the docs, SO, & Cursive mailing list for boot info. The Cursive author is very responsive to items on the mailing list:
If the above doesn't work, maybe convert it to a lein project just to make Cursive/IntelliJ happy. You can still run it as a boot project from the command line (or however you normally use boot).
For more info, see also this question: IntelliJ IDEA: "Indexed Maven Repositories" list - how to add remote maven repository in this list?
and the reference: http://maven.apache.org/settings.html#Repositories
Update #3:
OK, just found this boot Cursive info, which looks good: https://github.com/boot-clj/boot/wiki/For-Cursive-Users

Related

Leiningen raises "Tried to use insecure HTTP repository without TLS." but for which dependency?

I'm using Leiningen to run a Clojure project on my Raspberry Pi 3 (running stretch), previously I used version 2.7.1 with no problems, but upgrading to the latest version on lein (2.8.1) I now get this error for some of the dependencies (but not others):
Tried to use insecure HTTP repository without TLS
However, lein doesn't tell me which dependencies are causing problems, so how do I discover which ones cause this error?
Also is it possible to disable this security feature for certain dependencies? I'm only running on a home network so consider this acceptable.
Answer edited after a comment correctly pointed out that the first method was showing only the immediate dependencies.
Generate the Maven POM:
lein pom
Wrote .../pom.xml
Following this answer for Java https://stackoverflow.com/a/3270067/561422, use the Maven dependency plugin:
mvn dependency:purge-local-repository > raw.txt
Open raw.txt in an editor and search for the string http:, that should point you on the right track.
For example with Unix command-line tools:
Unsafe repos (searching for http:):
grep http: raw.txt
Downloading from example: http://unsafe.example.org
[Note: this is not my preferred solution, but it got my project working again].
Use Leiningen 2.7.1, which doesn't have such strict security checks. Download from:
https://raw.githubusercontent.com/technomancy/leiningen/2.7.1/bin/lein
It's a bit difficult to see which extension causes the problem as they can include other deps as well.
You can still download the extension though.
From the lein FAQ;
This is very insecure and exposes you to trivially-executed man-in-the-middle attacks. In the rare event that you don't care about the security of the machines running your project, you can re-enable support for unprotected repositories by putting this at the top of your project.clj file:
;; allow insecure downloads
(require 'cemerick.pomegranate.aether)
(cemerick.pomegranate.aether/register-wagon-factory!
"http" #(org.apache.maven.wagon.providers.http.HttpWagon.))
For me this worked on several older project that were not updated. In the logs you can easily track which package was downloaded via http.
So this answers the : "Is it possible to disable the security" feature question from the OP.
The other question seems to have an answer on StackOverflow already. Display complete dependency tree with Leiningen

IONIC2 transformClassesWithDexForDebug

I got this error
`FAILURE: Build failed with an exception.
What went wrong?
Execution failed for task ':transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;
`
I have enabled Multidex (multiDexEnabled = true) in build.gradle and also added following
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "2g"
}
but still getting that error.
Even I was facing the similar issue, I tried updating Cordova, Ionic and setting ANDROID_HOME and JAVA_HOME and almost all the solution over the web, but nothing worked for me. Finally, it was the issue with PhoneGap-push plugin. The 2.0 version of PhoneGap-push plugin has some collision with some plugins like
Google Analytics
To be more specific the plugins that use google play services.
So Below is my solution.
First, remove the PhoneGap-push plugin 2.0 from your application.
Now try to build the app by commenting all the lines that use push plugin.
If the build is successful then it will be the issue with push plugin. Then follow below instructions to fix the issue. If the build is not successful then you might be having some other issue.
First, uninstall the PhoneGap-push plugin 2.0
Then go to project -> package.json and search for push and replace the line with “”: “4.0.1” earlier it will be 4.3.0 or 4.3.1
Now add push plugin again to the project with below command ionic plugin add phonegap-plugin-push#1.10.5 --variable SENDER_ID=XXXXXXX
Now build your app works like a charm....
This issue is already opened in phonegap-pushplugin repo . They have a next milestone of releasing version 2.1.0 which will be fixing this issue.

How can I use a Leiningen plugin before I deploy it to Clojars?

I'm developing a Leiningen plugin. Actually, I'm working on a patch to an existing Leiningen plugin. I've made some changes, and now I want to see if they work.
What do I do?
I made these changes to support another project I'm working on. I'd like to point that project at my local working copy of the plugin to test my changes, but I don't see a way to do that.
Leiningen offers checkout dependencies, which solve this problem for dependencies, but not for plugins. Is there an equivalent for plugins?
Publish your forked version with a different group-id, either to clojars or to your local repo (with lein install). Then, in the project that uses the plugin, depend on your new artifact-id instead of the public one.

Unable to execute unit tests in a maven project from within intellij

I have inherited a legacy project with 100s of tests, and dependencies defined within the pom.
All of the tests run when I execute a mvn clean install from the command line, but when I try to execute one of these tests in debug mode from within Intellij i get the following error.
java.lang.NoClassDefFoundError: Could not initialize class
How can I get intellij to recognise these dependencies when trying to run a test in debug mode from the ide?
I managed to solve this by simply changing the working directory location in the Run configuration to point to the correct classpath location. The default location had been taken from a parent project.
It would be very convenient if one was able to debug tests from within IntelliJ. I have run into similar issues with my massive project and have found a workaround for it.
When wishing to debug a test, I have often found it useful to use a remote debugging session like so:
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dtest=com.autofunk.TheFunkImplTest test -DfailIfNoTests=false
You can then attach to the above using a remote debug session from within IntelliJ on port 8000.
Therefore, when debugging tests I first check to see whether a simple debug from within Intellij works. If not, I run the above and then attach to it using a debug configuration like so:
IntelliJ execute unit tests without mvn command.
a IntelliJ plugin: MvnRunner
You can run tests using the maven project window in IntelliJ
View - Tool Windows - Maven Projects
Then under the project or module you wish to test open the lifecycle goals and click test.
This will run the currently configured test goal. Now the report is logged into the target directory
I use
https://github.com/destin/maven-test-support-plugin
to view the test results.
You can access this screen once the plugin is installed from the Project window again right click on the projects root and select "Show Test Results" (should be below the maven icon)
Good luck

Jetty won't work: Is there a way to purge it?

I'm a Jetty newb, but it's making life hell. First there was an Eclipse problem I described in another question. Rather than waste time on it, I decided to just run Jetty from the console. I started off importing a sample Tapestry project and was able to run it fine... the project is on the Tapestry page and is called tutorial1
I began work on my own project then and began introducing new functionality to it. At some point it stopped working. I tried backtracking my project to get it to a working state but every time I requested the home page it would just hang. At this point I still thought it was my fault, though I did think a more graceful error message would have been nice than the it attempting to load for a minute followed by a server timeout error.
I then shutdown jetty and attempted to load up the imported sample project using mvn jetty:run in my tutorial1 project directory. it doesn't work either! When I try going to localhost:8080/tutorial1 or the URL of my project the jetty console does show any output, almost as if it's not receiving the request.
I rebooted my entire machine but that doesn't help. I am not familiar with jetty architecture and am unsure if there is a way I can purge all my files from the jetty web application directory.
Any ideas?
Cliffs Notes:
Downloaded Tapestry Archetype project with maven.
Executed jetty from the command line using mvn jetty:run
Started new project
Executed jetty from the command line using mvn jetty:run
Modified new project
Error occurred, attempted fix and restarted Jetty (Ctrl + C, followed by mvn jetty:run)
Jetty restarted, but did not seem to handle requests for any pages
Tried starting jetty from Archetype project, experienced the same problem
If your project didn't deploy correctly, jetty won't serve any pages (they will either return 404 or some error in the 500s).
Look at the log folder and check if it is getting correctly deployed.