Showing posts with label build. Show all posts
Showing posts with label build. Show all posts

Friday, December 14, 2012

Maven Idea

Here's a radical idea to simplify the usage of Maven, especially when considering Eclipse cooperation.

How about not using test scope, but instead create a 'project-test' for every 'project'? Some advantages:

The pom.xml files will be cleaner.

The single-classpath Eclipse will not be a problem any more.

One will not have to think about the interaction between the declared dependency scope and the importing dependency scope. (Unfortunately, the 'provided' scope is still needed, but that is pretty simple.)

If one would want to import test code into another project, no need to fiddle with '-tests' attachment.

One can build with-out tests, which is quicker, and could likely allow tests to be run quicker, ironically, because of parallel execution. Or you could collect all tests before running them.

The odd thing is that maven wasn't designed this way from the start. It would have dispensed with a lot of extra complexity. Etcetera.

Tuesday, November 6, 2012

Basic Maven Project Build Fix Tip

Sometimes, in Eclipse, a maven project will not be properly set up. For instance, when you create a maven project by creating a pom.xml file inside a folder. This can be seen by inspecting the '.classpath' file -- it will contain only these three items (or similar):


<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> 

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> 

<classpathentry kind="output" path="target/classes"/>


Then, what you do is this: simply "Disable Dependency Management" and then "Enable Dependency Management" from the "Maven" menu in the contextual menu from the project. If you keep the ".classpath" file open, you'll be able to see the what happens.

In the 'Disable' step, the Maven entry disappears:
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
Then, in the 'Enable' step, the entries which enable the build appears:
kind="src" output="target/classes" path="src/main/java"> 
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
 along with the 'MAVEN2_CLASSPATH_CONTAINER' thing mentioned above. Done!

--

Today I discovered that the above maneuver is in fact useful to handle another problem involving mis-synchronization between ".classpath" and the "pom.xml" file. Article forthcoming.