Reputation: 7563
I've used gradle plugin to generate pom.xml.
following correspond documentation I've added to may project into build.gradle
file next changes:
task writePom {
doLast {
pom {
project {
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
}
after that I used gradle writePom
and as result I've got generated pom.xml
in my project root directory.
The issue is I can not build project using the pom.xml
because of:
> maven clean install
[ERROR] /Users/XXX/Documents/projects/workspace/THE_PROJECT/src/main/java/CLASS_PACKAGE/THE_CLASS.java:[45,38] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
The issue reason is completely clear. My pom.xml
should use valid java version but the java version isn't generated in it.
How should I configure the plugin (for gradle
) to generate pom.xml
with specified java version?
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'pl.allegro.tech.build', name: 'axion-release-plugin', version: '1.7.1'
classpath 'org.hidetake:gradle-ssh-plugin:1.1.3'
}
}
plugins {
id "nebula.provided-base" version "3.0.3"
}
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'groovy'
apply plugin: 'osgi'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'signing'
apply plugin: 'pl.allegro.tech.build.axion-release'
apply plugin: 'nebula.optional-base'
apply from: 'gradle/dist.gradle'
group = 'org.mnode.ical4j'
description = '''
A Java library for reading and writing iCalendar (*.ics) files
'''
sourceCompatibility = 1.7
targetCompatibility = 1.7
ext {
slf4jVersion = '1.7.10'
}
repositories {
mavenCentral()
}
dependencies {
api "org.slf4j:slf4j-api:$slf4jVersion",
'commons-codec:commons-codec:1.9',
'org.apache.commons:commons-lang3:3.3.2',
'org.apache.commons:commons-collections4:4.0',
'org.threeten:threetenbp:1.3.3'
compile 'org.codehaus.groovy:groovy-all:2.3.2', optional
compileOnly 'biz.aQute.bnd:bndlib:2.3.0'
testImplementation 'org.codehaus.groovy:groovy-all:2.3.2',
'org.spockframework:spock-core:0.7-groovy-2.0',
'commons-io:commons-io:2.4',
'org.ccil.cowan.tagsoup:tagsoup:1.2.1',
"org.slf4j:slf4j-log4j12:$slf4jVersion"
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
javadoc {
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
jar {
manifest {
instruction 'Import-Package', 'groovy.*;resolution:=optional, org.codehaus.groovy*;resolution:=optional, *'
}
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
scmVersion {
tag {
prefix = 'ical4j'
}
versionCreator 'versionWithBranch'
branchVersionCreator = [
'master': 'simple'
]
}
version = scmVersion.version
ext {
isReleaseVersion = !version.endsWith("SNAPSHOT")
}
task writePom {
doLast {
pom {
project {
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
}
Upvotes: 1
Views: 2034
Reputation: 8267
You can specify the Java version with the target command:
targetCompatibility = '1.7'
Try with this code:
apply plugin: 'java'
compileJava {
sourceCompatibility = '1.7'
}
For more info visit this post:
how specify the required java version in a gradle build?
Upvotes: 1