Wednesday, November 21, 2012

Learning to Deploy (Maven)

I am in the process of learning how to do public deploys with maven; for instance, to publish java library artifacts. Uploading to AWS S3 would be nice, but one step at a time.

I found no 'deploy' menu item in Eclipse's Maven menus. So I made a nice little script:
cd $(dirname $0)
ls -l

echo -----------------------------------
echo deploying...
echo -----------------------------------

mvn javadoc:jar deploy

echo -----------------------------------
echo deploy script done.
echo -----------------------------------
echo 

echo -----------------------------------
echo damage report...
echo -----------------------------------

find /tmp/maven-tmp-repo

echo -----------------------------------
echo now back to your regular shell, see you later. 
echo -----------------------------------

$SHELL
I have found it to be a nice pedagogical tool. It's of course not much different from doing it manually but it saves work. I've put it in a 'mvn-deploy.command' file next to the 'pom.xml', which also makes for quick deploys -- it's just a double-click to start from inside Eclipse (provided you set the 'executable' property/flag under Properties); no having to navigate to the right directory in the terminal.

(Btw, why doesn't Eclipse have a 'Open Folder In Shell/Terminal'. Or maybe it does, somewhere. Do tell!)

The 'ls -l' at the start is just for context. The 'find' at the end lists all files in the makeshift repository. Yeah, almost forgot: you need something like this in your pom.xml:
<distributionManagement>
    <repository>
            <id>local-tmp-repo</id>
            <name>Temp Folder</name>
            <url>file:///tmp/maven-tmp-repo</url>
        </repository>
</distributionManagement>
Pardon the formatting. (EDIT: Shit, now it looks even worse: '& gt;' and all. Damn you, blogger editor. -- No wait, it looks ok in 'print'.)

So, you can now see in your terminal, or by inspecting the /tmp/ file system tree, how maven adds files like '/1.0-SNAPSHOT/maven-metadata.xml', 'pub-lib-1.0-20121121.203440-1.jar', 'pub-lib-1.0-20121121.205813-2-javadoc.jar', etcetera, without digging in to .m2 (these files are probably simply copies out of the .m2 local repo).

That's it, readers. I just might return with a post about the maven shapshot process, in very concrete terms.

Artifactory Online: Reviewlet

Reviewlet of Artifactory Online.

Home Url: https://secure.artifactoryonline.com/

Sign-Up: easy, but a bit too much filling in of forms. And either there's a glitch, or I mistyped something: the first confirmation mail didn't get back, so I had to add a '2' to the chosen domain, as it was reported as taken. Oh well.

Clicking confirmation link brought me in to the setup process, very simple, a bit slow; but from an implementor viewpoint I can see that it may be hard to keep a pool of fired-up instances ready.

I managed to snap these screenshot during the automatic process:



Done.

Next comes the finding-your-way. I dabbled with Nexus and Artifactory a few years back, so I recognize some of the repo naming schemes. But even thinking a bit, I must confess that I don't remember really fully understanding the scheme.

I am looking to have two 'permissions' of repos, one publicly available, and one for internal libraries. Well, actually, only the public one is really needed. So how do you do such a thing? Not immediately obvious if it is part of the factory set-up or not.

----

Ok, so an unexpected item in the review: finding-your-way-back-to-the-app. Can't seem to find a link from the main page. So I guess browser history, or find the confirmation email in the email history.

----

The repository search browser is pretty nice; I like to have this comprehensive data available like this:


Here, to the left (in this partial screenshot) you can see the list of repos. None of these seem to be the one I am looking for: publicly released artifacts. All these repo names end in '-local'. I suppose the name I am looking for would along the lines of 'libs-releases-public' (and perhaps 'libs-snapshots-public'). Isn't that a common enough usage that the default setup might want to include one?

----

The search I can only presume that it works, since all the shown repos seem to be empty. Maybe the repo1-cache contains something to search for...no. Even such a general pattern as "*X*" finds nothing. I can't get a clue as to why. Possibly they are all empty. One has to click the 'Show...' link as seen in the screenshot to get that number, unfortunately. In each selected one -- not very generous.

----

[TBD-M]

Tuesday, November 20, 2012

Heisenberg Keypress

Breakpoint in JavaScript on keydown. When hit, focus shifts to debugger. The keypress never comes.

I can't observe both the keydown and the keypress event. If I observe the first one, I can't observe the second one.

Good to know. Bad to have to know.

Eclipse Is Back


That's a new one, served fresh in a modal popup close to my face: 
An internal error occurred during: "Launching TestTemplate".
java.lang.NullPointerException
Restart, clean, refresh, nothing helped so far. Is it something in the code itself? Weird. Only other symptoms: 'misplaced' breakpoint (due to quick edit somehow) can't be removed, and no new breakpoints can be added anywhere.

Getting new issues from Eclipse is getting old.

---

(Expletive deleted), this is annoying. Deleted various project files. Open/Closed project, committed all uncommitted, tried the trick "Disable-Enable Dependencies" described in earlier posts, et-f5g-cetera. No go.

---

Found a clue: after deleting the contents of target/, the classes/ and test-classes/ folders are recreated, but they don't get populated. Is it my deletion of the .settings project files, or is it the original problem?

...no, the .settings/ files are actually back (org.eclipse.jdt.core.prefs, org.maven.ide.eclipse.prefs).

---

Two more clues: the process roster has a large number of zombie-like processes in it. When they are terminated, they take a long time, then both die, and a dialog "Termination Failed" is shown.

And shifting to 'Run' instead of 'Debug As..' I get this:


Exception in thread "main" java.lang.NoClassDefFoundError: org/pub/TemplateTest
Caused by: java.lang.ClassNotFoundException: org.pub.TemplateTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Yeah, if the build isn't working, that's not totally weird.

It's interesting that this causes the debugger to not be able to connect to the child process! Is it that it fails so fast, that there's no time? Or does it depend on a working classpath? Would be interesting to know...

---

Solution: rename the project. Don't ask me why it works. My guess is that some cache or setting is associated with the project name.

Repugnant shit...

Thursday, November 15, 2012

Killing Port Owners

This post is about a bunch of ways to do find and kill the process that owns a specific port.

First, some context. [TBD]

Now: the kills! In the below examples, the port number is 8181.

Here's the first way. Find or open a terminal; type:
lsof -i:8181 -t | xargs kill -9

-- TO BE EXTENDED

Wednesday, November 14, 2012

Trying WebStorm

In JavaScript Development Sucks, I detailed some things that make it so. We can consider this a tools issue; at least as far as the language makes tool-making feasible. And it's easy to imagine pretty good tools for JavaScript. Refactoring may be largely out of reach with such a language, at least without assumptions or whole-program analysis. But that's not impossible either.

Am in the process of trying out WebStorm, an IDE in the IntelliJ family. So far:
+ autocompletion seems to be good; looks into at least files in same dir (probably also whole project)
+ it's aware of JS-specific features like 'arguments' -- if 'arguments' is used, an otherwise unused argument is no longer considered to be unused.

Well that's about it. I haven't understood how IntelliJ 'works', so it's pretty slow going. Maybe I'll end up with an expired trial period, as last time when I tried IntelliJ for JEE, forgetting about the period since I have work to do.


Eclipse Drag-And-Drop Idea

Just realized that the serious usability problems with drag-and-drop in Eclipse has a surprisingly obvious solution!

If you have a large number of files and folders in your project source trees, drag-and-drop is a serious pain in the rear, because you may have to wait for scrolling, which is slow and a bit finicky to control. And if you over-scroll, you have to move the drag to the other end of the scrolled pane. Etcetera. And even remembering the target is difficult.

For moves within the same 'classpath entry' (e.g. src/main/java) there is at least the alternative of typing a new package name -- with auto-completion assisting you -- and then using the quick fix 'move', but for moves between projects, for instance, the problem remains.

However, I just got this really simple and in-hindsight-ly obvious idea: why not open a second 'Navigator' view? Turns out I don't know how to do that. But there is a an almost-as-good solution: the possibility to drag-and-drop into panes of other kinds! At least into the 'Project Explorer', just tried it.

Well, one simple trick closer to peaceful cooperation with Eclipse. Many annoyances remain to be worked around.