개요 

install4j 는 Multi Platform Java installer 개발 솔루션이다.

Java 로 된 제품을 개발하고 있다면 installer 를 적용하는게 뽀대 측면에서나 고객의 편의성 측면에서나 나은 선택이라고 생각된다.

개인적으로는 상용 자바 인스톨러 제품중에서 제일 괜찮은것 같아서 사용하고 있다.

install4j maven plugin 을 사용하면 command-line install4j compiler 를 호출해서 Release 시 필요한 여러 작업(documentation 만들기, installer 제작)등을 자동화할 수 있다. 

 

Goals

Goals available for this plugin:

GoalDescription
install4j:compileCompile installers (via install4jc). Execution will skip if install4j.home location is invalid.
install4j:helpDisplay help information on install4j-maven-plugin.
Call mvn install4j:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
install4j:install-licenseUpdate the install4j license key (via install4jc --license). Execution will skip if licenseKey parameter is not configured, or theinstall4j.home location is invalid.

 

사용

필요 사항

maven 이 구동되는 PC나 Build Server에 install4j 가 설치되어 있어야 한다.

만약 installj 가 설치되지 않았거나 PATH 에 없다면 compile 이 실패하게 되므로 다음과 같이 install4j.home properties 를 pom.xml 에 설정하는 것을 추천한다.

추가로 maven profiles 기능을 이용하여 개발시에는 install4j 를 제외하고 release profile 일때만 install4j 를 실행하게 설정할 수 있다.

<profiles>
		<profile>
			<id>devel</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<properties>
				<environment>local</environment>
				<!-- If install4j.home is not configured or is configured to an invalid or corrupted location, the plugin execution will skip. -->
				<install4j.home>NOTHING</install4j.home>
			</properties>
		</profile>
		<profile>
			<id>release</id>
			<properties>
				<environment>release</environment>
				<install4j.home>c:\Program Files\install4j5</install4j.home>
			</properties>
		</profile>
	</profiles>
XML

 

Project 설정

dependency 설정
<dependencies>
    <dependency>
		  	<groupId>com.install4j</groupId>
  			<artifactId>i4runtime</artifactId>
  			<version>5.1.6</version>
  			<scope>test</scope>
     </dependency>
</dependencies>
CODE

 

사용

다음과 같이 build의 plguin 설정에 추가하면 된다. profileFile 항목에는 install4j script 의 경로를 적어준다.

<build>
    <plugins>
        <plugin>
            <groupId>org.sonatype.install4j</groupId>
            <artifactId>install4j-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile-installers</id>
                    <phase>package</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                    <configuration>
                        <projectFile>${project.basedir}/src/main/installer/myproject.install4j</projectFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
XML

다음과 같이 package phase 를 실행하면 compile 후 install4j 가 실행된다.

mvn package -Prelease
CODE

 

install4j skip

빌드시 install4j.skip property를 넘겨주면 install4j 실행을 건너뛸수 있다.

mvn -Dinstall4j.skip
CODE

 

Ref