I am working on a project which has its backend written in spring boot and UI written in react, the react UI code is clubbed into the maven project carrying spring code like
JavaMavenProject (Project Structure)
->src
->main
->java (Spring boot code)
->reactcode (UI react code)
->resources
->webapp
-> test
I use plugins(snippet below) in pom.xml to build react code as well when i build my java code
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<executions>
<execution>
<id>Install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v14.15.0</nodeVersion>
<npmVersion>6.14.8</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v14.15.0</nodeVersion>
<workingDirectory>src/main/reactcode</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>Copy my react app into my Spring Boot target static folder</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/classes/static</outputDirectory>
<resources>
<resource>
<directory>src/main/reactcode/build</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Now when I test my entire application through Intellij things run fine, but when i create a war file to run it on "Apache Tomcat",even "index.html" is not loaded, I tried to debug this so I got below(image) mentioned problem
enter image description here
for which I when I removed the starting backslashes for these from the exploded war file in the webapp folder of Apache Tomcat(just to debug the problem)
<script src="/static/js/2.f62791a5.chunk.js"></script>
<script src="/static/js/main.839bea33.chunk.js"></script>
so after changing above code to
<script src="static/js/2.f62791a5.chunk.js"></script>
<script src="static/js/main.839bea33.chunk.js"></script>
index.html along with chunk.js and chunk.css starting to show up like see below image
enter image description here
Now, aaahh.. when o tried to click on the links they are not working , I tried to check the network logs and also the server but no luck there as well.
Code of "package.json"
{
"name": "mapping-tool",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.32",
"#fortawesome/free-brands-svg-icons": "^5.15.1",
"#fortawesome/free-solid-svg-icons": "^5.15.1",
"#fortawesome/react-fontawesome": "^0.1.12",
"#testing-library/jest-dom": "^5.11.6",
"#testing-library/react": "^11.1.2",
"#testing-library/user-event": "^12.2.2",
"axios": "^0.21.0",
"bootstrap": "^4.5.3",
"react": "^17.0.1",
"react-autocomplete-input": "^1.0.15",
"react-bootstrap": "^1.4.0",
"react-bootstrap-table-next": "^4.0.3",
"react-bootstrap-table2-editor": "^1.4.0",
"react-bootstrap-table2-filter": "^1.3.3",
"react-bootstrap-table2-paginator": "^2.1.2",
"react-dom": "^17.0.1",
"react-flexy-table": "^1.3.6",
"react-gif-loader": "^0.6.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.0",
"react-select": "^3.1.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
code for "App.js"
import React from 'react';
import './App.css';
import Mappings from './Mappings';
import Mapping from './Mapping';
import Test from './Test';
import Property from './Property';
import { Route, BrowserRouter as Router, Switch } from 'react-router-dom';
import NavigationBar from './Components/NavigationBar';
import {Row, Col, Container } from 'react-bootstrap';
function App() {
return (
<Router>
<NavigationBar />
<Container>
<Row>
<Col lg={12} className={"margin-top"}>
<Switch>
<Route path="/add" exact component={Mapping} />
<Route path="/edit/:id" exact component={Mapping} />
<Route path="/list" exact component={Mappings} />
<Route path="/tester" exact component={Test} />
<Route path="/property" exact component={Property} />
</Switch>
</Col>
</Row>
</Container>
</Router>
);
}
export default App;
code for "NavigationBar.js"
<Navbar bg="dark" variant="dark">
<Link to={""} className="navbar-brand">
</Link>
<Nav className="mr-auto">
<Link to={"add"} className="nav-link">Add System</Link>
<Link to={"list"} className="nav-link">Mapping List</Link>
<Link to={"tester"} className="nav-link">Add Mapping</Link>
<Link to={"property"} className="nav-link">Property</Link>
</Nav>
</Navbar>
Problem statement in conclusion : I have spring boot and react app in one Maven Java project which i make a production build which I deploy on Apache Tomcat, Things run fine on Intellij but on Tomcat they are not running.
"sigh........"
I would appreciate any help
Thanks
Fixed by doing following steps :
using HashRouter instead of BrowserRouter
setting "homepage": "." in package.json
for point1 do this :
<HashRouter>
<Container>
<Row>
<Col lg={12} className={"margin-top"}>
<Switch>
<Route path="/add" exact render={(props) => (
<Component1 {...props} restUrls={this.state.urls} />
)} />
<Route path="/edit/:id" exact render={(props) => (
<Component2 {...props} restUrls={this.state.urls} />
)} />
</Switch>
</Col>
</Row>
</Container>
</HashRouter>
Related
I'm using eclipse to compile/run my projects. I tried to use maven on c++ projects with nar-maven-plugin to build them. It works well as i launch maven goals in command line.
But when i import my maven project in eclipse, i have the following errors :
Execution default-nar-compile of goal
com.github.maven-nar:nar-maven-plugin:3.2.3:nar-compile failed: An API
incompatibility was encountered while executing
com.github.maven-nar:nar-maven-plugin:3.2.3:nar-compile:
java.lang.NoSuchMethodError:
org.codehaus.plexus.util.DirectoryScanner.setupMatchPatterns()V
----------------------------------------------------- realm = plugin>com.github.maven-nar:nar-maven-plugin:3.2.3 strategy =
org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
...
Moreover, eclipse seems to manage my project as a Java project instead of a C project.
Note : i'm using
Eclipse 4.3.1
M2E 1.4.0
CDT 8.3.0
My pom.xml
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>helloworld-cplusplus-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>nar</packaging>
<name>Helloworld</name>
<properties>
<rootdir>${project.basedir}</rootdir>
<nar.linker>gpp</nar.linker>
<nar.arch>x86</nar.arch>
<nar.os>Windows</nar.os>
</properties>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<versionRange>[3.2.3,)</versionRange>
<goals>
<goal>nar-test-unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<fork>true</fork>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<linker>
<name>g++</name>
</linker>
<libraries>
<library>
<type>executable</type>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sample</groupId>
<artifactId>helloworld-shared-library-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>nar</type>
</dependency>
</dependencies>
</project>
If someone is using nar-maven-plugin with eclipse can help me :). I would really like to use it on eclipse.
Thanks!
I have a folder structure as shown below under src/main/webapp/
I have a maven property ${sencha.env} that can be either of development | testing or production. I want to exclude the others from the build directory while making WAR. I am trying the below but its not working. Please guide -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/webapp/build/${sencha.env}/BACK</directory>
</resource>
</webResources>
<packagingExcludes>.sencha/**,app/**,ext/**,sass/**,%regex[build/(?!${sencha.env})]</packagingExcludes>
</configuration>
</plugin>
Please notice :
%regex[build/(?!${sencha.env})] in packagingExcludes
thanks!
You are very close; you need to have %regex[build/(?!${sencha.env}/).*]. Notice the .* which means that you are excluding every path below build/(?!${sencha.env}/.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/webapp/build/${sencha.env}/BACK</directory>
</resource>
</webResources>
<packagingExcludes>.sencha/**,app/**,ext/**,sass/**,%regex[build/(?!${sencha.env}/).*]</packagingExcludes>
</configuration>
</plugin>
I am having a problem trying to configure Maven to excluded some categories of unit tests based on multiple profiles.
I have two categories defined for unit testing: SlowTest for those unit tests that take a very long time to run, and WindowsTest for those unit tests that can only be executed within a Windows environment.
I have two profiles defined in my project's pom.xml file as follows:
<profiles>
<!-- Exclude any tests in `SlowTest` category when profile 'skipSlowTests' is specified. -->
<profile>
<id>skipSlowTests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>SlowTest.class</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Skip any tests in 'WindowsTest' category when not running on Windows. -->
<profile>
<id>skipWindowsTests</id>
<activation>
<os><family>!windows</family></os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>WindowsTest.class</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
So for example when I want to run the tests and exclude any slow tests, I can execute mvn -PskipSlowTests test. And If I want to skip any Windows tests I can execute mvn test on a non-Windows OS (or explicitly specify -PskipWindowsTests on the command line).
The problem here is that when both the skipSlowTests and skipWindowsTests profiles are activated then only the Windows tests are skipped. The slow tests still run. When maven constructs the effective pom.xml file, it applies the skipSlowTests profile and configures maven-surefire-plugin to exclude the groups SlowTest.class. Then the skipWindowsTests profile is applied and this overwrites the excluded groups to be WindowsTest.class.
What I really want is the excluded groups to be SlowTest.class,WindowsTest.class when both profiles are activated, but I cannot figure out a way to do this.
There's no way that I can see in maven of appending a value to a property, e.g.
<properties>
<excludedGroups>IgnoreTest.class</excludedGroups>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>${excludedGroups}</excludedGroups>
</configuration>
</plugin>
<profile>
<id>skipSlowTests</id>
<property>
<excludedGroups>${excludedGroups},SlowTest.class</excludedGroups>
</property>
...
</profile>
<profile>
<i>skipWindowsTests</id>
<property>
<excludedGroups>${excludedGroups},WindowsTest.class</excludedGroups>
</property>
...
</profile>
This pom.xml is broken, because there's recursion in assigning a value to the excludedGroups property.
And there's no way to set up a third profile (e.g. skipSlowTestsAndWindowsTests) that activates whenever both the skipSlowTests and skipWindowsTests are activated.
Any suggestions here? Maybe adding separate phases to maven-surefire-plugin (one for slow tests, one for windows tests, one for all others) and using profiles to determine which phases run?
Edit #1
I tried creating separate execution phases for the maven-surefire-plugin as follows:
<!-- By default, do not skip slow tests or windows tests -->
<properties>
<skipSlowTests>false</skipSlowTests>
<skipWindowsTests>false</skipWindowsTests>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<!-- Default execution will skip SlowTest and WindowsTest categories -->
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludedGroups>SlowTest,WindowsTest</excludedGroups>
</configuration>
</execution>
<!-- Slow Test execution will run the slow tests only (if not skipped) -->
<execution>
<id>slow-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipSlowTests}</skip>
<groups>SlowTest</groups>
</configuration>
</execution>
<!-- Windows Test execution will run the windows tests only (if not skipped) -->
<execution>
<id>windows-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipWindowsTests}</skip>
<groups>WindowsTest</groups>
</configuration>
</execution>
</executions>
</plugin>
<profiles>
<!-- Skip slow tests when skipSlowTests profile enabled -->
<profile>
<id>skipSlowTests</id>
<properties>
<skipSlowTests>true</skipSlowTests>
</properties>
</profile>
<!-- Skip windows tests when skipWindowsTests profile enabled -->
<profile>
<id>skipWindowsTests</id>
<properties>
<skipWindowsTests>true</skipWindowsTests>
</properties>
...
</profile>
</profiles>
This configuration will run tests in three separate executions: the default-test execution will run every test except for slow tests and windows tests; the slow-test execution will run the slow tests only; and the windows-test execution will run the windows tests only. And if both the skipSlowTests and skipWindowsTests profiles are enabled, then both slow tests and windows tests will be skipped.
The problem here is when there is a test marked with both SlowTest and WindowsTest categories:
#Test #Category({SlowTest.class,WindowsTest.class})
public void slowWindowsTestCase() { ... }
When the skipSlowTests profile only is enabled, then the windows-test execution is still run, and since the slowWindowsTestCase method is marked as a windows test, it will be executed, even though we want to skip slow tests. Similarly, this test case will also be executed when the skipWindowsTests profile only is enabled. The only way to skip this test case is to specify both the skipSlowTests and skipWindowsTests profiles.
I tried modifying the executions as follows:
<execution>
<id>slow-test</id>
...
<groups>SlowTest</groups>
<excludedGroups>WindowsTest</excludedGroups>
...
</execution>
<execution>
<id>windows-test</id>
...
<groups>WindowsTest</groups>
<excludedGroups>SlowTest</excludedGroups>
...
</execution>
But now the slowWindowsTestCase method is never executed.
Edit #2
And even if I could get the test executions working correctly, I would need to add a dependency on maven-surefire-plugin so that the SlowTest and WindowsTest interfaces can be loaded during testing. I have put maven-surefire-plugin in the pluginManagement section of my parent POM, but any dependency defined for this plugin cannot have test scope. As a result, running a test outside of the module that defines the SlowTest and WindowsTest interfaces will not work. I can add a test scope dependency for the plugin in the profiles, but that will not cover the case when no profiles are active.
You can make the default profile exclude all groups, and for each profile, you add one execution of the failsafe/surefire plugin including only one group.
What about having each profile define a property excludedGroups and concatenate those into one property at the very start of POM execution?
<build>
...
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.9</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<executions>
<execution>
<id>excludedGroups</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>
<![CDATA[
def groups = ""
(project.activeProfiles).each{ profile -> groups += profile.properties.excludedGroups + "," }
project.properties.excludedGroups = groups.substring(0, groups.length() - 1)
]]>
</script>
</scripts>
</configuration>
</execution>
</executions>
</plugin>
</build>
<profiles>
<!-- Exclude any tests in `SlowTest` category when profile 'skipSlowTests' is specified. -->
<profile>
<id>skipSlowTests</id>
<properties>
<excludedGroups>SlowTest.class</activeByDefault>
</properties>
</profile>
<!-- Skip any tests in 'WindowsTest' category when not running on Windows. -->
<profile>
<id>skipWindowsTests</id>
<activation>
<os><family>!windows</family></os>
</activation>
<properties>
<excludedGroups>WindowsTest.class</excludedGroups>
</properties>
</profile>
</profiles>
Now you can use ${excludedGroups} as value for the surefire plugin configuration.
We are in the process of upgrading from Weblogic 10g to 12c. A portion of our code base is webservices so we were using weblogic-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.5</version>
<configuration>
<contextPath>ws</contextPath>
<keepGenerated>true</keepGenerated>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jwsc</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>${weblogic.version}</version>
<scope>system</scope>
<systemPath>${bea.lib}/weblogic.jar</systemPath>
</dependency>
</dependencies>
</plugin>
The build error I see is
[ERROR] Failed to execute goal org.codehaus.mojo:weblogic-maven-plugin:2.9.5:jwsc (default) on project webService: Execution default of goal org.codehaus.mojo:weblogic-maven-plugin:2.9.5:jwsc failed: Plugin org.codehaus.mojo:weblogic-maven-plugin:2.9.5 or one of its dependencies could not be resolved: Failure to find weblogic:webservices:jar:10.3.6 in http://ccicusbuild1/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Deeper inspection shows that the plugin has a dependency on weblogic:weblogic:10.3.6 and weblogic:webservices:10.3.6. As shown in the previous code, I can override weblogic:weblogic:10.3.6 with weblogic:weblogic:12.1.1. The problem is webservices.jar is no longer apart of weblogic 12c, so I have nothing to override the dependency with, nor can I exclude it.
The page for weblogic-maven-plugin (http://mojo.codehaus.org/weblogic-maven-plugin/) mentions support for 12c, but doesn't give any details.
The goal is to be able to run JWSC through maven. Is there a tweak to the plugin configuration that I can do to make it work, or is there another plugin, or do I need to bite the bullet and run the code with the ant plugin?
This was the eventual solution we used. If some one else has something better, please post it.
plugins portion of pom.xml
<plugins>
<!--
Below contains a work around to build web services for Weblogic 12c.
weblogic-maven-plugin was how things were done (and was much cleaner)
but at the time of this work around, it doesn't appear to support Weblogic 12c.
If in the future, weblogic-maven-plugin or some other plugin become known,
it should replace both parts of the work around.
-->
<!-- START OF WORK AROUND part 1-->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>set-main-artifact</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.artifact.setFile(new File(project.build.directory+'/'+project.artifactId+'-'+project.version+'.war'))
</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<target>
<property name="maven.compile.classpath" refid="maven.compile.classpath" />
<property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
<property name="maven.test.classpath" refid="maven.test.classpath" />
<property name="maven.plugin.classpath" refid="maven.plugin.classpath" />
<ant antfile="src/main/ant/build.xml" target="all" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>${weblogic.version}</version>
<scope>system</scope>
<systemPath>${bea.lib}/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
<!-- END OF WORK AROUND part 1 -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<!-- START OF WORK AROUND part 2 -->
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
</executions>
<!-- END OF WORK AROUND part 2 -->
</plugin>
</plugins>
build.xml
<project name="build-webservice" default="all">
<target name="all" depends="build.webService" />
<path id="maven_plugin_classpath">
<pathelement path="${maven.plugin.classpath}" />
</path>
<path id="maven_runtime_classpath">
<pathelement path="${maven.compile.classpath}" />
<pathelement path="${maven.runtime.classpath}" />
<pathelement path="${maven.plugin.classpath}" />
<pathelement path="${weblogic.jar}" />
</path>
<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask"
classpath="${weblogic.jar}"
classpathref="maven_plugin_classpath"
/>
<target name="build.webService" description="Compile the web services if not up2date">
<!--
Eclipse compiles and places classes into target/classes when the workspace is building.
If this folder exists when jwsc runs, then any classes that are already compiled will NOT
be included in the final WAR file. Thus, this directory is removed prior to created the
webServices WAR fie.
-->
<delete dir="target/classes" />
<jwsc srcdir="${project.build.sourceDirectory}"
destDir="target"
classpathref="maven_runtime_classpath"
keepGenerated="yes"
applicationxml="${project.build.directory}/application.xml"
fork="true"
memorymaximumsize="256m"
verbose="true"
debug="on"
>
<module contextPath="ws" name="${project.artifactId}-${project.version}">
<jwsfileset srcdir=".">
<include name="**/*.java" />
<exclude name="**/*Test.java" />
</jwsfileset>
</module>
</jwsc>
</target>
</project>
Overall description:
War plugin execution is overwritten so that it isn't run
The compiling and packaging is handled in ant by JwscTask
gmaven plugin is used inform maven that it should use the ant generated war as the artifact
Notes:
Alternatives for gmaven were attachartifact ant task and build-helper-maven-plugin as specified in How to register a custom built jar file as maven main artifact?, but neither worked. Both resulted in An attached artifact must have a different ID than its corresponding main artifact.
I have a maven application configured to start Jetty and also load statics from ../client . Configuration is below:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.4.v20120524</version>
<configuration>
<scanIntervalSeconds>25</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>9095</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webAppSourceDirectory>../client/</webAppSourceDirectory>
<webAppConfig>
<resourceBases>
<resourceBase>src/main/webapp</resourceBase>
<resourceBase>../client/</resourceBase>
</resourceBases>
</webAppConfig>
</configuration>
</plugin>
What I am trying to do is to move only webapp under /API resource base. To be more explicit I want to have the mappings:
src/main/webapp ---> /API
../client/ ---> /
Finally found the right config:
<webAppConfig>
<contextPath>/API</contextPath>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<contextPath>/</contextPath>
<resourceBase>../client/</resourceBase>
</contextHandler>
</contextHandlers>