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

2

8

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.

Triplane answered 28/4, 2016 at 12:30 Comment(2)
I am using JBOSS AS 7 server.Triplane
No. There isn't any specific need for JBOSS. But as a developer, I would prefer my development and testing environment to be same.Triplane
D
3

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)

Ductile answered 2/5, 2016 at 16:14 Comment(0)
F
3

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>
Fardel answered 5/5, 2016 at 9:36 Comment(1)
Accepted answer just 2 hours after the bounty end... >.>Fardel

© 2022 - 2024 — McMap. All rights reserved.