Pregunta

I have Maven project, but on one of servers I must build it without Maven.
It's possible using standard JDK commands. Where can I see what commands Maven sent to JDK while building project?

¿Fue útil?

Solución 3

This is my solution. Of course it's hardcode, and project is very small, but for me it is helpful

project structure:
main folder
- dependency (dir)
- module1 - src ...
- module2 - src ...
- manufest.template (file)
module2 have dependency of module1, module1 is compilied with JDK1.5, module2 with JDK1.6.

@echo off

set JODA=dependency\joda-time-1.6.2.jar
set EJB=dependency\ejb-api-3.0.jar
set PERSISTANCE_API=dependency\persistence-api-1.0.jar
set DEPENDENCIES=%EJB%;%JODA%;%PERSISTANCE_API%
set TEMP_FILE=temp
set PUBLIC_INTERFACE_CLASSES=target\target-module1
set CODEGEN_CLASSES=target\target-module2
mkdir target
mkdir %MODULE1_CLASSES%
mkdir %MODULE2_CLASSES%

dir module1\*.java /s /B > %TEMP_FILE%
%JAVA_HOME_1_5%\bin\javac -classpath %DEPENDENCIES%;%MODULE1_CLASSES% -d %MODULE1_CLASSES% @%TEMP_FILE%

dir module2\*.java /s /B > %TEMP_FILE%
%JAVA_HOME_1_6%\bin\javac -classpath %DEPENDENCIES%;%JAVA_HOME_1_6%\lib\tools.jar;%MODULE1_CLASSES%;%MODULE2_CLASSES% -d %MODULE2_CLASSES% @%TEMP_FILE%

jar cf module1.jar -C %MODULE1_CLASSES% .
jar cfm module2.jar manifest.template -C %MODULE2_CLASSES% .

rm %TEMP_FILE%
rm -r target

Otros consejos

Maven does a lot. There's no easy way to simulate what Maven does without Maven.

If you absolutely can't install maven on the server, build your artifacts on another server (or locally) and move them onto the server via scp.

That said: I have once had a similar scenario where I generated an RPM from Maven for a server that absolutely needed to run a local build but could not run Maven (network access prohibited). What I did was to put all dependencies in the RPM, plus an Ant distribution and an Ant build file. In the RPM install script, the dependencies were unpacked and the Ant script called. It worked, but it meant double work.

You can download the dependencies from here: http://jar-download.com/online-maven-download-tool.php. Therefore you need no Maven installtion.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top