gradle adding -source.jar to war - gradle

I am in the process of converting a number of projects from ant+ivy to Gradle.
One of the projects (address) produces a simple jar for inclusion into a webapp. I have set up the build.gradle to publish the jar and a sources jar to my private ivy repository.
address/build.gradle excerpt:
apply plugin: 'java'
apply plugin: 'publishing'
apply plugin: 'ivy-publish'
[...snip...]
task sourceJar(type: Jar) {
from sourceSets.main.java
classifier "source"
}
publishing {
repositories {
ivy {
url 'http://dev.example.com/ivy/'
layout "pattern", {
artifact "[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"
}
}
}
publications {
ivy(IvyPublication) {
from components.java
artifact(sourceJar) {
type "source"
}
}
}
}
I publish this with gradlew publish. My webapp then has a dependency on the resulting jar:
compile 'com.example:address:1.0.0'
The problem I have is that when I do gradlew build on the webapp, the war's WEB-INF/lib includes address-source-1.0.0.jar along with the expected address-1.0.0.jar.
I cannot figure out why the source jar is being included in the war. It does not show up in gradlew dependencies.
Here is the ivy.xml being generated for the jar:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="com.example" module="address" revision="1.0.0" status="integration" publication="20141027154452"/>
<configurations>
<conf name="default" visibility="public" extends="runtime"/>
<conf name="runtime" visibility="public"/>
</configurations>
<publications>
<artifact name="address" type="jar" ext="jar" conf="runtime"/>
<artifact name="address" type="source" ext="jar" conf="runtime" m:classifier="source"/>
</publications>
<dependencies>
<dependency org="org.springframework" name="spring-asm" rev="3.0.5.RELEASE" conf="runtime->default"/>
<dependency org="org.springframework" name="spring-beans" rev="3.0.5.RELEASE" conf="runtime->default"/>
<dependency org="org.springframework" name="spring-context" rev="3.0.5.RELEASE" conf="runtime->default"/>
<dependency org="org.springframework" name="spring-expression" rev="3.0.5.RELEASE" conf="runtime->default"/>
<dependency org="org.springframework" name="spring-core" rev="3.0.5.RELEASE" conf="runtime->default"/>
<dependency org="log4j" name="log4j" rev="1.2.14" conf="runtime->default"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.5.6" conf="runtime->default"/>
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.6" conf="runtime->default"/>
<dependency org="commons-lang" name="commons-lang" rev="2.4" conf="runtime->default"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.5.6" conf="runtime->default"/>
</dependencies>
</ivy-module>

I think the reason is that the source artifact is published in the runtime configuration as well, if you use a special configuration (e.g. sources) it should work:
publications {
ivyJava(IvyPublication) {
from components.java
configurations.create('sources')
artifact(sourceJar) {
conf "sources"
}
}
}
(configurations.create() is needed because of
GRADLE-3162)

Related

Jacoco coverage in gradle multimodule with arquillian

I have a multimodule project in gradle with the follow structure
root-project:
rest-module
cdi-module
ejb-module
From rest-module I call to the others modules, and tests are working fine, but when I run sonarqube task, I only obtain coverage from rest-module and the others is empty. Also I look for "jacoco.exec" file and only exits in rest module.
My configuration of arquillian is:
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<container qualifier="wildfly-managed" default="true">
<configuration>
<property name="allowConnectingToRunningServer">true</property>
<property name="jbossHome">C:\wildfly-11.0.0.Final</property>
<property name="javaVmArguments">-Xms800m -Xmx800m -XX:MaxPermSize=1024m</property>
<property name="outputToConsole">true</property>
</configuration>
</container>
<extension qualifier="jacoco">
<property name="appendAsmLibrary">true</property>
</extension>
<extension qualifier="reporter">
<property name="report">html</property>
</extension>
and the dependies on my subprojets are:
plugins {
id 'war'
id 'java'
id 'jacoco'
id 'project-report'
}
sourceSets {
test.runtimeClasspath += configurations.jacocoAnt
main {
output.resourcesDir = "build/classes"
}
test {
output.resourcesDir = "build/classes"
}
}
dependencies {
testImplementation ("org.jboss.arquillian.junit:arquillian-junit-container:1.4.0.Final")
testImplementation ("org.jboss.arquillian.protocol:arquillian-protocol-servlet:1.4.0.Final")
testImplementation ("org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain:3.1.3")
testImplementation ("org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-gradle-embedded-archive:3.1.3")
testImplementation ("org.wildfly.arquillian:wildfly-arquillian-container-managed:2.1.0.Final"
testImplementation (group: 'org.ow2.asm', name: 'asm', version: '5.0.1')
//testImplementation "org.jboss.arquillian.extension:arquillian-jacoco-with-asm:1.1.0"
testImplementation ("org.jacoco:org.jacoco.core:0.8.5"){
exclude group: "asm", module: "asm"
}
testImplementation ("org.jboss.arquillian.extension:arquillian-jacoco:1.1.0"){
exclude group: "asm", module: "asm"
}
}

SMS using twilio from mobile app not working

As per the guidelines in this tutorial.
I've completed everything. But it's not working. No errors are occurring. I don't know where to check for the issues. Please can someone help me with a solution or at least where to look for issues?
Please find below manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="uhnm.stroke.strokeapp_secondscreen">
<dist:module dist:instant="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".NIHSSActivityPage4" android:windowSoftInputMode="adjustPan"/>
<activity android:name=".TeamsDisplay" android:windowSoftInputMode="adjustPan" />
<activity android:name=".imageActivity" android:windowSoftInputMode="adjustPan" />
<activity android:name=".timesActivity" />
<activity android:name=".configurationActivity" />
<activity android:name=".addConsultants" />
<activity android:name=".NIHSSActivityFinalPage"android:windowSoftInputMode="adjustPan" />
<activity android:name=".NIHSSActivityPage3" android:windowSoftInputMode="adjustPan" />
<activity android:name=".NIHSSActivityPage2" android:windowSoftInputMode="adjustPan" />
<activity android:name=".MainActivity" android:windowSoftInputMode="adjustPan" />
<activity android:name=".EnterBrainTracker" />
<activity android:name=".NIHSSActivity" android:windowSoftInputMode="adjustPan" />
<activity
android:name=".signIn"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="strokeapp.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
</application>
</manifest>
Here the app gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
//useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "uhnm.stroke.strokeapp_secondscreen"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions
{
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation group: "com.twilio.sdk", name: "twilio", version: "7.44.0"
implementation 'com.squareup.okhttp3:okhttp:4.2.1'
}

getting error after adding elegant button dependency

after adding this
implementation'com.cepheuen.elegant-number-button:lib:1.0.2'
getting the error every time i add this dependency
Manifest merger failed : Attribute application#theme value=(#style/Theme.AppCompat.Light.NoActionBar) from AndroidManifest.xml:13:9-65
is also present at [com.cepheuen.elegant-number-button:lib:1.0.2] AndroidManifest.xml:16:9-40 value=(#style/AppTheme).
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:7:5-27:19 to override.
which other dependency can be used for elegant button
build.gradle module app file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.sharma.digimenu"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
implementation 'com.firebaseui:firebase-ui-storage:4.0.0'
implementation 'com.firebaseui:firebase-ui-database:4.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
Do the following changes in Manifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:theme"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home"
android:label="#string/title_activity_home"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" />
<activity android:name=".FoodList"></activity>
</application>
Follow the instruction, add tools:replace="android:theme" to your <application> element.

org.apache.jasper.JasperException lost in logback, but written to tomcat9 localhost.log

My goal is to have all app-level logging go to my app log file. My problem is that while a lot of my debug/info/error messages make it to STDOUT/File etc... here is one error that only shows in my tomcat9 log:
4-Jun-2018 08:55:29.050 SEVERE [http-nio-82-exec-6] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception
org.apache.jasper.JasperException: /WEB-INF/jsp/di_queue.jsp (line: [110], column: [8]) The function [isCurrentUser] cannot be located with the specified prefix
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115)
at org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1603)
at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:135)
I am using jdk 10, Spring 5.0.5, Hibernate 5.3, Logback 1.2.3
Here is my logback.xml
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.directwebremoting" level="trace"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="org.apache.tiles" level="info"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="org.apache.jasper.compiler" level="info"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="error">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Here is my ivy.xml
<ivy-module version="2.0">
<info organisation="org.apache" module="ews" />
<configurations defaultconfmapping="default">
<conf name="default" />
<conf name="compile" description="compile dependencies" extends="default" />
<conf name="runtime" description="runtime dependencies" extends="default" />
<conf name="test" description="test dependencies" extends="default" />
</configurations>
<dependencies>
<dependency org="org.hibernate" name="hibernate-core" rev="5.3.0.Final">
</dependency>
<dependency org="org.hibernate" name="hibernate-jcache"
rev="5.3.0.Final" />
<!-- just for ehcahce 2? -->
<!-- <dependency org="org.hibernate" name="hibernate-ehcache" rev="5.3.0.Final"
/> -->
<!-- needed or whole hibernate spring config does not start -->
<dependency org="org.springframework.boot" name="spring-boot-starter-cache"
rev="2.0.2.RELEASE" />
<dependency org="javax.cache" name="cache-api" rev="1.1.0" />
<dependency org="org.ehcache" name="ehcache" rev="3.5.2" />
<dependency org="org.springframework" name="spring-orm"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-core"
rev="5.0.6.RELEASE" />
<dependency org="ch.qos.logback" name="logback-access" rev="1.2.3" />
<dependency org="org.springframework" name="spring-webmvc"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-web"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-context"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework.boot" name="spring-boot-starter-logging"
rev="2.0.2.RELEASE" />
<!-- https://mvnrepository.com/artifact/org.directwebremoting/dwr rev="2.0.1"
rev="3.0.2-RELEASE" -->
<dependency org="org.directwebremoting" name="dwr"
rev="3.0.2-RELEASE" />
<dependency org="dom4j" name="dom4j" rev="1.6.1" />
<dependency org="net.sf.jasperreports" name="jasperreports"
rev="3.6.1" /><!-- 6.6.0 -->
<dependency org="jstl" name="jstl" rev="1.2" />
<dependency org="javax.servlet" name="servlet-api" rev="2.5" />
<dependency org="net.sf.supercsv" name="super-csv-dozer"
rev="2.4.0" />
<!-- <dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.7.22" />
<dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="2.7"
/> <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.7"
/> <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.7"
/> -->
<!-- for the ant classes remove after ant jrc working -->
<!-- <dependency org="commons-logging" name="commons-logging" rev="1.2"
/> <dependency org="org.codehaus.groovy" name="groovy-all" rev="1.5.5" />
<dependency org="org.eclipse.jdt.core.compiler" name="ecj" rev="4.6.1" /> -->
<dependency org="org.apache.tiles" name="tiles-jsp" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-core" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-api" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-servlet"
rev="3.0.8" />
<dependency org="commons-fileupload" name="commons-fileupload"
rev="1.3.3" />
<dependency org="javax.mail" name="javax.mail-api" rev="1.6.1" />
<dependency org="com.mchange" name="c3p0" rev="0.9.5.2" />
<dependency org="org.json" name="json" rev="20180130" />
<dependency org="javax.json" name="javax.json-api" rev="1.1.2" />
<dependency org="commons-validator" name="commons-validator"
rev="1.6" />
<dependency org="org.mozilla" name="rhino" rev="1.7R1" />
<!-- <dependency org="org.acegisecurity" name="acegi-security" rev="1.0.4"
/> -->
<dependency org="org.springframework.security" name="spring-security-web"
rev="5.0.5.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-config"
rev="5.0.5.RELEASE" />
<dependency org="com.lowagie" name="itext" rev="2.1.7" />
<dependency org="org.apache.tomcat" name="tomcat-catalina"
rev="9.0.8" />
<dependency org="com.microsoft.sqlserver" name="mssql-jdbc"
rev="6.4.0.jre9" />
<!-- https://www.concretepage.com/forum/thread?qid=531 -->
<dependency org="javax.xml.bind" name="jaxb-api" rev="2.3.0" />
<dependency org="oro" name="oro" rev="2.0.8" />
<dependency org="org.apache.commons" name="commons-lang3"
rev="3.7" />
<dependency org="commons-fileupload" name="commons-fileupload"
rev="1.3.3" />
</dependencies>
</ivy-module>
Seems like JSP/view/tiles/dwr errors are the ones I am missing in STDOUT
This Servlet related exception logs are handled by Tomcat internal logging library which is a customised java.util.logging.
According to this :
The calls to javax.servlet.ServletContext.log(...) to write log
messages are handled by internal Tomcat logging. Such messages are
logged to the category named
org.apache.catalina.core.ContainerBase.[${engine}].[${host}].[${context}]
To overwrite the global Tomcat logging configuration , try to put a java.util.logging 's properties file logging.properties in /WEB-INF/classes/ and configure the above logger log to a file handler , somethings like this:
handlers =java.util.logging.FileHandler
java.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.FileHandler.pattern = /temp/app.log
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.FileHandler

hibernatetools ant task - hbm2java - creates pojo without package statement

I'm exporting my mapping (hbm.xml) to pojo classes using ant task.
It generates the POJO files in the mapped directory. But the Classes miss the Package statement. It simply creates all files in default package
// default package
// Generated Aug 23, 2012 12:34:40 PM by Hibernate Tools 3.2.2.GA
Here is my ant build file for the task.
<project name="Hibernate Tools for Ant - hbm2java" default="gensrc">
<path id="tools">
<path location="lib/hibernate-tools-3.2.3.GA.jar"/>
<path location="lib/hibernate3.6.10.jar"/>
<path location="lib/freemarker-2.3.8.jar"/>
<path location="lib/hsqldb-2.2.4.jar"/>
<path location="lib/commons-logging.jar"/>
<path location="lib/dom4j-1.6.1.jar"/>
<path location="lib/slf4j-api-1.6.1.jar"/>
<path location="lib/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
</path>
<taskdef name="gen-src" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="tools"/>
<target name="gensrc">
<gen-src destdir="src/main/java">
<configuration
configurationfile="src/main/resources/hibernate.cfg.xml">
<fileset dir="src/main/java/com/kee/example/domain/maps">
<include name="Event.hbm.xml"/>
</fileset>
</configuration>
<hbm2java destdir="src/main/java/com/kee/example/domain"/>
</gen-src>
</target>
</project>
the default Pojo.ftl (inside hibernate-tools.jar) has the declaration as below
${pojo.getPackageDeclaration()}
// Generated ${date} by Hibernate Tools ${version}
what should i be changing in order to have correct package declaration in the generated POJO.
Update:
Here is my Mapping file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.kee.example.domain">
<meta attribute="generated-class">EventBase</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="scope-field">protected</meta>
<class name="com.kee.example.domain.Event" table="event">
<id name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="eventDate" type="timestamp"/>
<property name="eventString" type="java.lang.String"/>
</class>
</hibernate-mapping>
I was getting the same problem in maven and not sure about the reason but it was resolved once I started using annotationconfiguration instead of jdbcconfiguration.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>${db.src.dir}</outputDirectory>
</component>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<create>true</create>
<export>false</export>
<format>true</format>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<outputfilename>${ddl.file}</outputfilename>
<templatepath>src/main/resources/hibernate-template</templatepath>
<delimiter>;</delimiter>
<configurationfile>src/main/resources/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
I did not want the annotated pojo classes so I had commented codes in *.ftl files.

Resources