Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static html web page in maven

Tags:

html

static

maven

I want to have static html web page as an maven project. I have done project like advised on this tutorial http://www.doclo.be/lieven/articles/personalsitewithmaven.html.

I have copyied my static html web page with complete structure into src/site/resources directory and I have deleted all files/directories in src/site directory (instead of resources dir).

I have added into pom.xml file in reporting section plugin called maven-linkcheck-plugin (its usage is described on http://maven.apache.org/plugins/maven-linkcheck-plugin/usage.html).

I want to have something like surefire plugin in project which will fail build if there will be any error in links on generated web page. linkcheck plugin seems to check just validity of links and tryies to retrieve head of all links. It does not generate any error when referencing nonexisting pdf file for example.

To have my project, just do this:

mvn archetype:create -DgroupId=com.mypage -DartifactId=mypage -DarchetypeArtifactId=maven-archetype-site-simple
cd mypage
rm -r src/site/*
mkdir src/site/resources
echo "<h1>my last web page, I promisse</h1> <a href="relativeUrlToNonexistentPage.html">Link text</a>" > src/site/resources/index.html

Than edit pom.xml and add there:

  <reporting>
   <excludeDefaults>true</excludeDefaults>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-project-info-reports-plugin</artifactId>
     <version>2.7</version>
     <reportSets>
          <reportSet>
           <reports />
          </reportSet>
     </reportSets>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-linkcheck-plugin</artifactId>
        <version>1.1</version>
        <configuration>
          <excludedLinks>
            <excludedLink>https://trackit.sk/app</excludedLink>
          </excludedLinks>
        </configuration>
      </plugin>
   </plugins>
  </reporting>

Than just run: mvn clean site:run and than open http:// localhost:8080 web page. There you will see link which is nor working.

When I run: mvn clean linkcheck:linkcheck there is in target directory generated report, but no error. According the report it seems that invalid url link was not scanned.

I want to check all ulrs (all relative will be enough) by some maven plugin. Is there any possibility to do that by linkcheck plugin, or I should use for this thing some other plugin?

like image 250
user3698328 Avatar asked Nov 22 '22 20:11

user3698328


1 Answers

Of course you can for example create a warfile (web app) with Maven that contains just plain HTML files.

Just set packaging to war and drop plain HTML files in src/main/webapp

When you copy yourprojectname.war into a tomcat webapps folder on your computer and one of those files is for example called example.html, the URL to that file could for example be http://localhost:8080/yourprojectname/example.html.

Please refer to Maven and Tomcat documenations for details.

like image 66
Gunnar Avatar answered Jun 28 '23 22:06

Gunnar