Red Hat Bugzilla – Bug 717526
Revert filtering in server/jar
Last modified: 2012-02-07 14:24:50 EST
Currently in server/jar we filter on *each* build the sources into filtered-sources just to replace one property ( org.rhq.enterprise.server.system.ServerVersion#namespace ) with the pom version, so that webservices know the correct namespace.
This has several negative effects:
- IntelliJ sees target/filtered-sources as a source directory and complains about duplicated classes
- running 'mvn test' twice in a row to debug things, each time compiles all the sources in filtered-sources again, considerably slowing down debugging.
We should put the pom.version into a .properties file, that will just be included in server.jar and where the namespace code then gets its data.
Actually it turns out, that ServerVersion.namespace is used in a lot of places as a constant , so using a method to obtain the namespace may be no option.
A static class initializer may help here e.g.
namespace = System.getProperty("pom.version");
public static final String namespace;
The CoreServer class in server-jar has an example of loading build properties from the classpath. There is also the MavenArtifactProperties class that I wrote, which provides the ability to load the standard maven build properties file for the specified Maven artifact, e.g.:
MavenArtifactProperties richFacesMavenProps = MavenArtifactProperties.getInstance("org.richfaces.framework", "richfaces-api");
The static initializer approach from comment#1 is failing:
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/jaxb/WebServiceTypeAdapter.java:[25,46] attribute value must be constant
The compiler sees that the "public static final String namespace" is only initialized in that initializer and not a real constant.
Can we perhaps use some sed mechanics on release builds to replace the version and otherwise keep the String constant with some "dummy" value -- much like we do with the pom versions?
Commit 6a75748bbe847d611f8ecdcf64b09134fde63340 makes this a bit less of an issue. Basically instead of doing resource filtering on the whole src/main/java, I split the code into "normal" and "filtered". The normal code lives under src/main/java and is your ordinary java sources with no special maven attention. The filtered sources live under src/filtered-sources/java and are subject to maven resource filtering. The filtered java files are put into target/filtererd-sources/java which is then set as an additional source directory. Effectively, the sources from src/main/java and target/filtered-sources/java then make up the full source tree and are compiled normally into target/classes.
The advantage of this approach is three-fold:
1) There is a clear separation of source files that need special treatment.
2) The build only recompiles the filtered sources each time it is invoked (even if there were no changes to the source files). This is a big improvement over the former implementation that had to recompile all the sources in server jar each time a build was invoked.
3) Increased compatibility with the Eclipse maven plugin (m2e) that wouldn't handle well the change of the source directory and would force the user to actually edit files in the source directory (that was redefined to be in target) and thus the user would loose changes everytime a maven build would commence. The only special case left are the filtered source files but because it is made explicitly an exceptional kind of a source file, the developer is more easily aware of special treatment needed for it.
To test this, we need to make sure the Web services still define the correct namespace. Simeon, could you please provide more feedback on how to actually do that? I know nothing about our web services infrastructure.
confirmed web services by following these steps:
and then visiting this URL:
this page defines an endpoint as follows:
Endpoint Name jboss.ws:context=rhq-rhq-enterprise-server-ejb3,endpoint=WebservicesManagerBean
Endpoint Address http://foleymonsterbox1.foleyhomenetwork:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl
there is no WSDL at this location
(and I expect there would some WSDL)
Simeon ... could you confirm that this is the correct behavior for web services?
added BZ 726502 https://bugzilla.redhat.com/show_bug.cgi?id=726502 while trying to verify. discussed with spinder. verification of this BZ is blocked by BZ 726502.
Created attachment 515903 [details]
screen shot of ws version still being correctly set after filter changes
Fixed BZ 726502 and verified that Webservice version is still being correctly set. See attached screenshot. Nice work Lukas.
Moving to ON_QA.
Verified on build#231 (Version: 4.1.0-SNAPSHOT Build Number: c4a82bc)
1. Followed the steps in:
2. Visited this URL: https://localhost:7443/jbossws/services
3. Clicked on:
4. Verified that the namespace in the WSDL is displayed as:
Please refer the attached screenshot.
Marking as verified.
Created attachment 516123 [details]
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE