Converting ANT build for Java 8 non-modular project to Java 11 modular project with non-modular dependencies - ant

Trying to convert a Java 8 project to use modules in Java 11.
We created the module.info file in Eclipse and everything is compiling fine within Eclipse. But we’re having problems setting up the build which uses ANT (v 1.10.12).
Our code being compiled will be in a module, but it depends on non-modular jar files so it needs to create automatic modules for those jars from my understanding.
But the build keeps failing.
The module.info file looks something like the following where it requires externalclient which should be an automatic module created from non-module jar externalclient.jar
`module project.ourmod {
exports com.projectname.client;
requires externalclient;
}`
Our source code resides in
productpath/src/main/java
And the externalclient.jar resides in
projectpath/lib/main/java
The .classpath that Eclipse creates (and compiles just fine) looks like
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/main/java/externalclient.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
The ANT build target to compile uses javac which we tried to modify to handle building now as a module and looks like the following.
<path id="classpath.junit">
<pathelement location=“projectpath/lib/main/java/externalclient.jar"/>
</path>
<echo>Compiling project client code ...</echo>
<tpcr.javac
ldestdir="projectpath/bin"
srcdir=“projectpath/src/main/java"
modulepath="${classpath.junit}"
listfiles="${compiler.verbose}"
encoding="UTF-8"
optimize="${compiler.optimize}"
debug="${compiler.debug}"
debuglevel="${compiler.debuglevel}">
<include name="com/projectname/client/**”/>
<compilerarg line="--add-modules externalclient"/>
</tpcr.javac>
We tried using but it wasn’t finding the java files to compile. Using srcdir it does see the files however when it tries to compile them we get the following error.
[echo] Compiling project client code ...
[tpcr.javac] Compiling 278 source files to projectpath/bin
[tpcr.javac] projectpath/src/main/java/module-info.java:28: error: module not found: externalclient
[tpcr.javac] requires externalclient;
[tpcr.javac] ^
[tpcr.javac] error: cannot access module-info
[tpcr.javac] cannot resolve modules
[tpcr.javac] 1 errors
We thought that specifying the path holding the externaclient.jar file in would handle making it an automatic module, but doesn’t seem to be working. Seems like we’re still missing something.
NOTE: Renamed the files and directories…so might be some typos…just trying to get the main setup across.

Related

MobileFirst Platform native iOS app building have error while building .wlapp

I am working on MobileFirst Platform version7 using ant script to build the project .war, .wlapp, .adapter.
Everything was working fine while our project was a hybrid one. Now the project is migrated to native-iOS in.
I am using following code to build .wlapp.
<target name="build-wlapp">
<app-builder worklightServerHost="localhost:10080"
applicationFolder="//Users/admin/Documents/workspace/NewProj/apps/Try"
environments="iOSnative"
nativeProjectPrefix="NewProj"
outputFolder="/Users/admin/Documents/workspace/NewProj/bin"/>
it is throwing below error:
build.xml:66: Failed building application: The build could not be
completed due to invalid application-descriptor.xml.(cvc-elt.1: Cannot
find the declaration of element 'nativeIOSApp'.)
I am not getting where the flaw is...
Assuming the application-descriptor.xml you posted in your comment is complete, it looks like you have a stray semicolon after your xmlns declaration. That's not valid XML. Not sure how it got like that (check your source control system?), but you probably need to remove/revert it.
Sorry For the Wrong answer first.
You were using the wrong code to generate the .wlapp file the ant script is below.
<project default="change">
<target name="change">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<native-app-builder
sourceFolder="C:\Workspace\Test\apps\Test" DestinationFolder="bin"
worklightServerHost="http://111.111.111.111:10080">
</native-app-builder>
</target>
</project>

ojdeploy - ant task compile application

I am trying to use ojdeploy to compile and build an ADF application through an AntTask.
The ojdeploy task works fine when I specify not to compile the project by adding the line
The ojdeploy task is unable to find several jars required to build the application which I have specified.
I can't find any documentation which describe the use of the ojdeploy to compile applications which makes me think that it does not work.
The ant task I have is below. My thoughts are that the ojdeploy task does not have the jars required to build the project on its classpath. I can't see a way to add these jars to the classpath however.
ojdeploy task:
<target name="deploy" description="Deploy JDeveloper profiles">
<property name="status" value="${env.WORKSPACE}/deploy/ojdeploy-statuslog.xml"/>
<taskdef name="ojdeploy"
classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask"
uri="oraclelib:OJDeployAntTask"
classpathref="classpath"/>
<ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask"
executable="${env.oracle.middleware}/jdeveloper/jdev/bin/ojdeploy.exe"
failonerror="true"
ora:buildscript="${env.WORKSPACE}/deploy/ojdeploy-build.xml"
ora:statuslog="C:/Oracle/Middleware/ojdeploy-statuslog.xml">
<ora:deploy>
<ora:parameter name="workspace"
value="${env.WORKSPACE}/JWS.jws"/>
<ora:parameter name="profile"
value="*"/>
<!--<ora:parameter name="nocompile" value="true"/>-->
<ora:parameter name="outputfile"
value="${env.WORKSPACE}/deploy/${deployment.profile.name}"/>
</ora:deploy>
</ora:ojdeploy>
</target>
Resolved.
ojdeploy uses the jws and jpr files to find the libraries required. The jpr file was missing several JDeveloper/ADF libraries which JDeveloper is able to resolve.
However for ojdeploy to work ALL the libraries and dependencies are required to be in the jws/jpr file accordingly using the libraries/classpath and dependencies options.

Build and deploy a Zend Framework PHP application in Jenkins

I'm setting up a jenkins job to build and deploy a Zend Framework 2 php application.
In my ant build script I've defined a lint job for validating php files.
The build job failed because lint detected an error in a ZF2 library file.
This is the output generated by lint:
[apply] PHP Fatal error: Constructor Zend\Captcha\Factory::factory() cannot be static in /var/lib/jenkins/workspace/XXX/vendor/zendframework/zendframework/library/Zend/Captcha/Factory.php on line 90
[apply] Errors parsing /var/lib/jenkins/workspace/XXX/vendor/zendframework/zendframework/library/Zend/Captcha/Factory.php
Does anybody know why the validation of Zend/Captcha/Factory.php fails ?
The ANT Task looks like this:
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
Your problem is because Zend Framework requires php 5.3.3 or later. Since your Jenkins box uses 5.3.2, this give a variety of problems. One of them is apparently the error you have now.
I think you haven't noticed the error before because on the development system you have a 5.3.3+ install. Try to update your testing environment to a newer version of php, that will remove this particular problem.
Update
To clarify my answer a bit, there is one backwards compatibility break in php 5.3.3 which comes back in your environment. Check this changelog and particularly this statement:
Backwards incompatible change:
Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn't affect non-namespaced classes.
<?php
namespace Foo;
class Bar {
public function Bar() {
// treated as constructor in PHP 5.3.0-5.3.2
// treated as regular method in PHP 5.3.3
}
}
?>
There is no impact on migration from 5.2.x because namespaces were only introduced in PHP 5.3.
In the case of Zend\Captcha\Factory, there is a method factory() which is static so you can call Zend\Captcha\Factory::factory(). On php 4 and 5 up to 5.3.2, this method is also parsed as the constructor for the factory. And constructors cannot be static.
A linter will give you a fatal error for this case.

how come ANT javac command adds extra directories?

I start studying ANT today in order to make Java compiling easier.
I wrote simple ANT script which only use javac command.
What I am trying is compile from .....\head_first\src\com\masatosan\constant.java (source)
to the destination directory:
.....\head_first\WEB-INF\classes\com\masatosan\conf
So the result would look like:
.....\head_first\WEB-INF\classes\com\masatosan\conf\constant.class
But I can't figure out why the actual result adds "/com/masatosan/conf" directories to the destination folder, so it looks like:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\WEB-INF\classes\com\masatosan\conf\com\masatosan\constant.class
Could anyone tell me how can I fix this?
ANT
<project name="CompileMasatosan"
basedir="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\src\com\masatosan">
<description>
masatosan compiler
</description>
<property name="confSrc"
location="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\src\com\masatosan\conf" />
<property name="confDest"
location="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\WEB-INF\classes\com\masatosan\conf" />
<target name="compileConfSrc">
<javac srcdir="${confSrc}" destdir="${confDest}" />
</target>
</project>
UPDATE
I didn't know complier creates directories based on the package name.
The package name of constant.java was com.masatosan.conf so that complier creates "/com/masatosan/conf/"
You're trying to tell ANT to change the package because you want Constant.class to be under the com.masatosan.conf package rather than the com.masatosan package. The Ant compilation process will create the appropriate package subdirectories, which is why you see com\masatosan created under the dest.
I don't think you can tell ANT to change the package of a source file, which is what you're trying to do by injecting an extra conf dir. You can either create a conf dir and have a conf\com\masatosan\constants.class or put it under classes\com\masatosan\constants.class, but you can't do com\masatosan\conf\constants.class since that changes the package of constants.class to com.masatosan.conf
Or simply change the package of constants.class to com\masatosan\conf and change your ant file to to:
<property name="confDest"
location="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\WEB-INF\classes" />
Its because of the package name. You have a Java file in package com.masatosan. You can fix this two way either move class to default package or set ${confDest} value to \head_first\WEB-INF\classes\ only.
This is because the compiler is creating the package directory stucture under the destination directory you specify. The constant class is in the com.masatosan package, so under classes\com\masatosan\conf, the compiler creates a further two directories for the package, com\masatosan, and places the compiled class (constant.class) in there.
Your destination directory should simply be C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\WEB-INF\classes. The com and masatosan directories will be created for you.

Flex 4 swc size smaller compiled by FlashBuilder than using ANT

I'm trying to figure out why when I compile my Flex 4 Library swc using a simple ANT tasks, it compiles to about three times the size of the swc that's compiled by FlashBuilder.
Here is my ANT script to compile my swc
<target name="compileSWC" description="compiles the Library">
<echo>Compiling Library SWC To Deploy SWC Folder</echo>
<compc debug="false
output="${bin.dir}/${Library.name}-${timeVersion}.swc"
incremental="true"
optimize="true"
headless-server="true"
verbose-stacktraces="true"
default-frame-rate="24">
<source-path path-element="${src.dir}" />
<include-sources dir="${src.dir}" includes="*"/>
<source-path path-element="${src.dir}" />
<compiler.library-path dir="${basedir}/" append="true">
<include name="${library.dir}" />
</compiler.library-path>
</compc>
<echo>Compiled Library SWC To Deploy SWC Folder</echo>
</target>
This yields a swc that is 1,980 KB. This library file has custom components, some skins and images, so I was ok with the file size. But when I use the FlashBuilder to link my Library project to other Flex projects, the compiled swc is only 532 KB.
I am able to move the FlashBuilder compiled swc to any project and it works just fine.
So I'm wondering what is FlashBuilder doing different than my ANT build script to get that file size down? I tried adding 'static-link-runtime-shared-libraries="true"' to my ANT script, but I had the same results.
Thanks.
Have you tried spitting out the config from the FB compile and using that in the ant task? You can use the compiler option
-dump-config fb_config.xml
And then use the load-config tag to pull it into your ant task.
Here's a KB article that runs through it: http://kb2.adobe.com/cps/404/kb404341.html
Hope that helps,
Ruprict
Don't know why but after loading my configuration the compiler is whining about the compiler.extensions, it says is an unknown configuration variable, here's the stack:
Buildfile: C:\Users\cgascons\Documents\workspace\TCGEngine\build.xml
generateAssets:
[echo] Target::generateAssets
compile:
[echo] Target::compile
[mxmlc] Unknown:compiler.extensions
[mxmlc] Loading configuration: C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml:8
[mxmlc] Warning: 'compiler.accessible' is not fully supported.
[mxmlc] <accessible>false</accessible>
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml:49
[mxmlc] Error: unknown configuration variable 'compiler.extensions'.
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml (line: 49)
[mxmlc] <extensions>
BUILD FAILED
C:\Users\cgascons\Documents\workspace\TCGEngine\build.xml:18: mxmlc task failed
Does anybody know what could be happening here?

Resources