Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to build maven webapp project everytime i make changes into static files?

I am using JBOSS AS7.1, Eclipse Luna for development. My eclipse installation does have a plugin installed for maven.

I have created my webapp project using maven command-line.

In my current set up, I have to build my maven project using mvn clean install every time for all changes, even for the static files like HTML, CSS.

Then, I have to deploy the generated WAR file using JBOSS console running at http://localhost:9990/console.

I am quite sure that there must be another way to do this. Surely, it does take a hell lot of time.

Please guide me to the approaches I can adopt for faster development.

like image 882
Paras Avatar asked Apr 28 '16 12:04

Paras


People also ask

What is the difference between Maven build and Maven install?

First of all, build is not a phase in the standard Maven lifecycles, whereas install is one. mvn install will invoke all the phases up to the phase install , which generally consists of compiling the source code, packaging the project and installing it in the local repository.

When should you run Maven clean?

On Maven, each time you want to compile, the best practice is to run mvn clean . It clears out the existing classes that you compiled from last compile. If you don't want to run 3 lines, just do "mvn test" after mvn clean .

What is the difference between Maven clean and install?

5 Answers. Show activity on this post. clean is its own build lifecycle phase (which can be thought of as an action or task) in Maven. mvn clean install tells Maven to do the clean phase in each module before running the install phase for each module.


2 Answers

You can replace the static file in your target folder and launch a build skipping the compile phase.

It will save you a lot of time, when only updating static files.

It is not a good practice, but should let you achieve your goal.

How to:

  • Use the maven-clean-plugin to remove the files to replace from the target folder (or they will not be overwritten);
  • Use the resources tag if your static files are not the only content of the resources folder you want to copy (or your static files are not in resources folder at all);
  • Use the maven-compiler-plugin to skip the compile phase.

Customize this profile (and use it with mvn clean install -P skip-compile):

<profile>
    <id>skip-compile</id>
    <build>
        <resources> <!-- optional -->
            <resource>
                <directory>src/main/resources/META-INF</directory>
                <targetPath>META-INF</targetPath>
                <excludes>
                    <exclude>**/*.xml</exclude>
                </excludes>
                <includes>
                    <include>**/*.html</include>
                    <include>**/*.css</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                <excludeDefaultDirectories>true</excludeDefaultDirectories>
                    <filesets>
                        <fileset>
                            <directory>${project.build.outputDirectory}/META-INF</directory>
                            <excludes>
                                <exclude>**/not_to_delete.xml</exclude>
                            </excludes>
                            <includes>
                                <include>**/*.html</include>
                                <include>**/*.css</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <skipMain>true</skipMain>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
like image 95
Linuslabo Avatar answered Nov 03 '22 01:11

Linuslabo


One option is jrebel. It's not free though.

If you are not bound to JBOSS, you could use spring boot. It also supports automatic restart (spring boot devtools)

like image 35
niekname Avatar answered Nov 03 '22 00:11

niekname