Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (5)
Moved the email cleaning code of GenerateDebianFilesMojo into a separate method
· 1035ce62
Emmanuel Bourg
authored
Jun 27, 2018
1035ce62
Ask the questions first in the execute() method of GenerateDebianFilesMojo
· 78e44799
Emmanuel Bourg
authored
Jun 27, 2018
78e44799
Removed the projectVersion variable in GenerateDebianFilesMojo
· bab5974b
Emmanuel Bourg
authored
Jun 27, 2018
bab5974b
Simplified GenerateDebianFilesMojo by using a Set to hold the dependencies
· 54d9590d
Emmanuel Bourg
authored
Jun 27, 2018
54d9590d
Minor simplification when checking the developers in GenerateDebianFilesMojo
· d42c6a35
Emmanuel Bourg
authored
Jun 27, 2018
d42c6a35
Show whitespace changes
Inline
Side-by-side
maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
View file @
d42c6a35
...
...
@@ -164,9 +164,14 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
private
LicensesScanner
licensesScanner
=
new
LicensesScanner
();
public
void
execute
()
throws
MojoExecutionException
{
// #638788: clean up email
if
(
email
!=
null
&&
email
.
indexOf
(
'<'
)
>=
0
&&
email
.
indexOf
(
'>'
)
>=
0
)
{
email
=
email
.
substring
(
email
.
indexOf
(
'<'
)
+
1
,
email
.
indexOf
(
'>'
)
-
1
);
if
(
project
.
getName
()
==
null
||
project
.
getName
().
isEmpty
())
{
project
.
setName
(
new
SimpleQuestion
(
"POM does not contain the project name. Please enter the name of the project:"
).
ask
());
}
if
(
project
.
getUrl
()
==
null
||
project
.
getUrl
().
isEmpty
())
{
project
.
setUrl
(
new
SimpleQuestion
(
"POM does not contain the project URL. Please enter the URL of the project:"
).
ask
());
}
if
(
project
.
getDescription
()
==
null
||
project
.
getDescription
().
trim
().
isEmpty
())
{
project
.
setDescription
(
new
MultilineQuestion
(
"Please enter a short description of the project (press Enter twice to stop):"
).
ask
());
}
try
{
...
...
@@ -179,19 +184,12 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
context
.
put
(
"packageType"
,
packageType
);
context
.
put
(
"binPackage"
,
binPackageName
);
context
.
put
(
"packager"
,
packager
);
context
.
put
(
"packagerEmail"
,
e
mail
);
context
.
put
(
"packagerEmail"
,
e
xtractEmail
(
email
)
);
context
.
put
(
"project"
,
project
);
context
.
put
(
"collectedProjects"
,
wrapMavenProjects
(
collectedProjects
));
context
.
put
(
"runTests"
,
Boolean
.
valueOf
(
runTests
));
context
.
put
(
"generateJavadoc"
,
Boolean
.
valueOf
(
generateJavadoc
));
if
(
project
.
getName
()
==
null
||
project
.
getName
().
isEmpty
())
{
project
.
setName
(
new
SimpleQuestion
(
"POM does not contain the project name. Please enter the name of the project:"
).
ask
());
}
if
(
project
.
getUrl
()
==
null
||
project
.
getUrl
().
isEmpty
())
{
project
.
setUrl
(
new
SimpleQuestion
(
"POM does not contain the project URL. Please enter the URL of the project:"
).
ask
());
}
Set
<
String
>
licenses
=
licensesScanner
.
discoverLicenses
(
project
.
getLicenses
());
context
.
put
(
"licenses"
,
licenses
);
...
...
@@ -216,12 +214,11 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
projectTeam
=
project
.
getOrganization
().
getName
()
+
" developers"
;
}
if
(
copyrightOwner
==
null
||
copyrightOwner
.
isEmpty
())
{
Iterator
<
Developer
>
devs
=
project
.
getDevelopers
().
iterator
();
if
(
devs
.
hasNext
())
{
Developer
dev
=
devs
.
next
();
copyrightOwner
=
dev
.
getName
();
if
(
dev
.
getEmail
()
!=
null
&&
!
dev
.
getEmail
().
isEmpty
())
{
copyrightOwner
+=
" <"
+
dev
.
getEmail
()
+
">"
;
if
(!
project
.
getDevelopers
().
isEmpty
())
{
Developer
developer
=
project
.
getDevelopers
().
get
(
0
);
copyrightOwner
=
developer
.
getName
();
if
(
developer
.
getEmail
()
!=
null
&&
!
developer
.
getEmail
().
isEmpty
())
{
copyrightOwner
+=
" <"
+
developer
.
getEmail
()
+
">"
;
}
}
}
...
...
@@ -247,21 +244,17 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
context
.
put
(
"copyrightYear"
,
copyrightYear
);
context
.
put
(
"currentYear"
,
currentYear
);
if
(
project
.
getDescription
()
==
null
||
project
.
getDescription
().
trim
().
isEmpty
())
{
project
.
setDescription
(
new
MultilineQuestion
(
"Please enter a short description of the project, press Enter twice to stop."
).
ask
());
}
context
.
put
(
"description"
,
formatDescription
(
project
.
getDescription
()));
File
substvarsFile
=
new
File
(
outputDirectory
,
binPackageName
+
".substvars"
);
if
(
substvarsFile
.
exists
())
{
Properties
substvars
=
new
Properties
();
substvars
.
load
(
new
FileReader
(
substvarsFile
));
Lis
t
<
String
>
compileDepends
=
new
ArrayLis
t
<
String
>();
Se
t
<
String
>
compileDepends
=
new
TreeSe
t
<
String
>();
compileDepends
.
addAll
(
split
(
substvars
.
getProperty
(
"maven.CompileDepends"
)));
compileDepends
.
addAll
(
split
(
substvars
.
getProperty
(
"maven.Depends"
)));
Lis
t
<
String
>
buildDepends
=
new
ArrayLis
t
<
String
>(
compileDepends
);
Lis
t
<
String
>
testDepends
=
new
ArrayLis
t
<
String
>(
split
(
substvars
.
getProperty
(
"maven.TestDepends"
)));
Se
t
<
String
>
buildDepends
=
new
TreeSe
t
<
String
>(
compileDepends
);
Se
t
<
String
>
testDepends
=
new
TreeSe
t
<
String
>(
split
(
substvars
.
getProperty
(
"maven.TestDepends"
)));
if
(
runTests
)
{
buildDepends
.
addAll
(
testDepends
);
}
...
...
@@ -270,7 +263,6 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
buildDepends
.
addAll
(
split
(
substvars
.
getProperty
(
"maven.DocOptionalDepends"
)));
}
if
(
"maven"
.
equals
(
packageType
))
{
boolean
seenJavadocPlugin
=
false
;
// Remove dependencies that are implied by maven-debian-helper
for
(
Iterator
<
String
>
i
=
buildDepends
.
iterator
();
i
.
hasNext
();)
{
String
dependency
=
i
.
next
();
...
...
@@ -283,11 +275,9 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
dependency
.
startsWith
(
"velocity"
)
||
dependency
.
startsWith
(
"libplexus-velocity-java"
))
{
i
.
remove
();
}
else
if
(
dependency
.
startsWith
(
"libmaven-javadoc-plugin-java"
))
{
seenJavadocPlugin
=
true
;
}
}
if
(
generateJavadoc
&&
!
seenJavadocPlugin
)
{
if
(
generateJavadoc
)
{
buildDepends
.
add
(
"libmaven-javadoc-plugin-java"
);
}
}
else
if
(
"ant"
.
equals
(
packageType
))
{
...
...
@@ -342,7 +332,6 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
}
String
projectVersion
=
project
.
getVersion
();
int
downloadType
=
DownloadType
.
UNKNOWN
;
if
(
downloadUrl
==
null
)
{
...
...
@@ -353,7 +342,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
if
(
downloadUrl
!=
null
&&
downloadUrl
.
startsWith
(
"scm:svn:"
))
{
downloadType
=
DownloadType
.
SVN
;
downloadUrl
=
downloadUrl
.
substring
(
"scm:svn:"
.
length
());
String
tag
=
projectVersion
;
String
tag
=
project
.
get
Version
()
;
int
tagPos
=
downloadUrl
.
indexOf
(
tag
);
String
baseUrl
=
null
;
String
suffixUrl
=
null
;
...
...
@@ -418,7 +407,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
generateFile
(
context
,
"compat.vm"
,
outputDirectory
,
"compat"
);
generateFile
(
context
,
rulesTemplate
,
outputDirectory
,
"rules"
,
true
);
context
.
put
(
"version.vm"
,
mangleVersion
(
projectVersion
)
+
"-1"
);
context
.
put
(
"version.vm"
,
mangleVersion
(
project
.
get
Version
()
)
+
"-1"
);
generateFile
(
context
,
rulesTemplate
,
new
File
(
"."
),
".debianVersion"
);
...
...
@@ -470,6 +459,18 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
}
/**
* Returns the email enclosed in < ... >.
*
* @see <a href="https://bugs.debian.org/638788">Bug #638788</a>
*/
private
String
extractEmail
(
String
email
)
{
if
(
email
!=
null
&&
email
.
indexOf
(
'<'
)
>=
0
&&
email
.
indexOf
(
'>'
)
>=
0
)
{
email
=
email
.
substring
(
email
.
indexOf
(
'<'
)
+
1
,
email
.
indexOf
(
'>'
)
-
1
);
}
return
email
;
}
/**
* Normalizes the project version for use as a Debian package version.
*/
...
...