Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend control #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class PackageParameters

public final Option<String> contact;

public final Option<String> size;

public final Option<String> contactEmail;

public final Option<String> license;
Expand All @@ -71,10 +73,11 @@ public class PackageParameters
public PackageParameters( String groupId, String artifactId, PackageVersion version, String id, String name,
FileAttributes defaultFileAttributes, FileAttributes defaultDirectoryAttributes,
Option<String> classifier, Option<String> description, Option<String> contact,
Option<String> size,
Option<String> contactEmail, Option<String> license, Option<String> architecture )
{
validateNotNull( groupId, artifactId, version, id, name, defaultFileAttributes, defaultDirectoryAttributes,
classifier, description, contact, contactEmail, license, architecture );
classifier, description, contact,size, contactEmail, license, architecture );

this.groupId = groupId;
this.artifactId = artifactId;
Expand All @@ -84,6 +87,7 @@ public PackageParameters( String groupId, String artifactId, PackageVersion vers
this.classifier = classifier;
this.description = description;
this.contact = contact;
this.size= size;
this.contactEmail = contactEmail;
this.license = license;
this.architecture = architecture;
Expand All @@ -102,13 +106,14 @@ public static PackageParameters packageParameters( String groupId, String artifa
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, Option.<String>none(), Option.<String>none(),
Option.<String>none(),
Option.<String>none(), Option.<String>none(), Option.<String>none() );
}

public PackageParameters name( String name )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

Expand All @@ -120,7 +125,7 @@ public PackageParameters description( String description )
public PackageParameters description( Option<String> description )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

Expand All @@ -132,7 +137,19 @@ public PackageParameters contact( String contact )
public PackageParameters contact( Option<String> contact )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

public PackageParameters size( String size )
{
return size( fromNull( size ) );
}

public PackageParameters size( Option<String> size )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

Expand All @@ -144,7 +161,7 @@ public PackageParameters contactEmail( String contactEmail )
public PackageParameters contactEmail( Option<String> contactEmail )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

Expand All @@ -156,7 +173,7 @@ public PackageParameters license( String license )
public PackageParameters license( Option<String> license )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}

Expand All @@ -168,7 +185,7 @@ public PackageParameters architecture( String architecture )
public PackageParameters architecture( Option<String> architecture )
{
return new PackageParameters( groupId, artifactId, version, id, name, defaultFileAttributes,
defaultDirectoryAttributes, classifier, description, contact, contactEmail,
defaultDirectoryAttributes, classifier, description, contact,size, contactEmail,
license, architecture );
}
}
67 changes: 47 additions & 20 deletions unix-deb/src/main/java/org/codehaus/mojo/unix/deb/ControlFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class ControlFile

public final Option<String> maintainer;

public final Option<String> installedSize;

public final Option<String> architecture;

public final Option<String> priority;
Expand All @@ -74,14 +76,17 @@ public class ControlFile

public ControlFile( String packageName )
{
this( packageName, Option.<String>none(), Option.<String>none(), Option.<String>none(), Option.<String>none(),
this( packageName, Option.<String>none(), Option.<String>none(), Option.<String>none(),
Option.<String>none(), Option.<String>none(),
Option.<String>none(), Option.<String>none(), List.<String>nil(), List.<String>nil(), List.<String>nil(),
List.<String>nil(), List.<String>nil(), List.<String>nil(), List.<String>nil(),
TreeMap.<String, String>empty( stringOrd ) );
}

public ControlFile( String packageName, Option<String> version, Option<String> description,
Option<String> maintainer, Option<String> architecture, Option<String> priority,
Option<String> maintainer,
Option<String> installedSize,
Option<String> architecture, Option<String> priority,
Option<String> section, List<String> depends, List<String> recommends, List<String> suggests,
List<String> preDepends, List<String> provides, List<String> replaces, List<String> conflicts,
TreeMap<String, String> extraFields )
Expand All @@ -90,6 +95,7 @@ public ControlFile( String packageName, Option<String> version, Option<String> d
this.version = version;
this.description = description;
this.maintainer = maintainer;
this.installedSize= installedSize;
this.architecture = architecture;
this.priority = priority;
this.section = section;
Expand All @@ -105,97 +111,114 @@ public ControlFile( String packageName, Option<String> version, Option<String> d

public ControlFile version( Option<String> version )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize,architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile description( Option<String> description )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile maintainer( Option<String> maintainer )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority,
section, depends, recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile installedSize(Option<String> size) {
return new ControlFile( packageName, version, description, maintainer, size, architecture, priority,
section, depends, recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile architecture( Option<String> architecture )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile priority( Option<String> priority )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize,architecture, priority,
section,
depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile section( Option<String> section )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile depends( List<String> depends )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile recommends( List<String> recommends )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority,
section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile suggests( List<String> suggests )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority, section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile preDepends( List<String> preDepends )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority, section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile provides( List<String> provides )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer,installedSize, architecture, priority, section, depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile replaces( List<String> replaces )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority, section,
depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile conflicts( List<String> conflicts )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority, section,
depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public ControlFile extraFields( TreeMap<String, String> extraFields )
{
return new ControlFile( packageName, version, description, maintainer, architecture, priority, section, depends,
return new ControlFile( packageName, version, description, maintainer, installedSize, architecture, priority, section,
depends,
recommends, suggests, preDepends, provides, replaces, conflicts, extraFields );
}

public List<String> toList()
{
List<Option<String>> optionList = single( some( "Package: " + packageName ) ).
cons( section.map( curry( concat, "Section: " ) ) ).
cons( priority.map( curry( concat, "Priority: " ) ) ).
cons( maintainer.map( curry( concat, "Maintainer: " ) ) ).
cons(priority.map(curry(concat, "Priority: "))).
cons(maintainer.map(curry(concat, "Maintainer: "))).
cons(installedSize.map(curry(concat, "Installed-Size: "))).
cons( version.map( curry( concat, "Version: " ) ) ).
cons( architecture.map( curry( concat, "Architecture: " ) ) ).
cons( description.map( curry( concat, "Description: " ) ) );
cons(description.map(curry(concat, "Description: ")));

F<String, F<List<String>, List<String>>> f = listToHeader.f( 80 );

Expand Down Expand Up @@ -289,6 +312,9 @@ public TreeMap<String, String> f( TreeMap<String, String> map, P2<String, String
controlFile = controlFile.maintainer( map.get( "Maintainer" ) );
map = map.delete( "Maintainer" );

controlFile = controlFile.installedSize( map.get( "Installed-Size" ) );
map = map.delete( "Installed-Size" );

controlFile = controlFile.architecture( map.get( "Architecture" ) );
map = map.delete( "Architecture" );

Expand Down Expand Up @@ -324,4 +350,5 @@ public TreeMap<String, String> f( TreeMap<String, String> map, P2<String, String

return controlFile;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static ControlFile getControlFile( File deb )
addArgument( "section" ).
addArgument( "priority" ).
addArgument( "maintainer" ).
addArgument( "installedSize" ).
addArgument( "package" ).
addArgument( "version" ).
addArgument( "architecture" ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void testParseAnt()
ControlFile expectedControlFile = new ControlFile( "ant" ).
version( some( "1.7.0-3" ) ).
maintainer( some( "Ubuntu Core Developers <[email protected]>" ) ).
installedSize( some( "1025" ) ).
architecture( some( "all" ) ).
priority( some( "optional" ) ).
section( some( "devel" ) ).
Expand All @@ -126,6 +127,7 @@ public void testParseBash()
ControlFile expectedControlFile = new ControlFile( "bash" ).
version( some( "3.2-0ubuntu16" ) ).
maintainer( some( "Ubuntu Core developers <[email protected]>" ) ).
installedSize( some( "1316" ) ).
architecture( some( "amd64" ) ).
priority( some( "required" ) ).
section( some( "base" ) ).
Expand Down Expand Up @@ -153,6 +155,7 @@ public void testParseLibc6()
ControlFile expectedControlFile = new ControlFile( "libc6" ).
version( some( "2.7-10ubuntu3" ) ).
maintainer( some( "Ubuntu Core developers <[email protected]>" ) ).
installedSize( some( "11348" ) ).
architecture( some( "amd64" ) ).
priority( some( "required" ) ).
section( some( "base" ) ).
Expand Down Expand Up @@ -204,6 +207,7 @@ private void assertControlFile( String path, ControlFile expectedControlFile )
assertEquals( "version", expectedControlFile.version, actualControlFile.version ).
assertEquals( "description", expectedControlFile.description, actualControlFile.description ).
assertEquals( "maintainer", expectedControlFile.maintainer, actualControlFile.maintainer ).
assertEquals( "installedSize", expectedControlFile.installedSize, actualControlFile.installedSize).
assertEquals( "package", expectedControlFile.packageName, actualControlFile.packageName ).
assertEquals( "architecture", expectedControlFile.architecture, actualControlFile.architecture ).
assertEquals( "priority", expectedControlFile.priority, actualControlFile.priority ).
Expand Down
2 changes: 1 addition & 1 deletion unix-deb/src/test/resources/control/ant.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ant
Priority: optional
Section: devel
Installed-Size: 1460
Installed-Size: 1025
Maintainer: Ubuntu Core Developers <[email protected]>
Original-Maintainer: Debian Java Maintainers <[email protected]>
Architecture: all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Package: basic
Section: devel
Priority: standard
Maintainer: Acme
Installed-Size: 1024
Version: 1.0-20110708.151032
Architecture: all
Description: Hudson Solaris Package
1 change: 1 addition & 0 deletions unix-handbook/src/main/docbook/examples/basic/pom-deb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<extensions>true</extensions>
<configuration>
<contact>Acme</contact>
<size>1024</size>
<contactEmail>[email protected]</contactEmail>
<deb>
<section>devel</section>
Expand Down
1 change: 1 addition & 0 deletions unix-handbook/src/main/docbook/examples/basic/pom-pkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<extensions>true</extensions>
<configuration>
<contact>Acme</contact>
<size>1024</size>
<contactEmail>[email protected]</contactEmail>
<assembly>
<copyArtifact>
Expand Down
1 change: 1 addition & 0 deletions unix-handbook/src/main/docbook/examples/basic/pom-rpm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<extensions>true</extensions>
<configuration>
<contact>Acme</contact>
<size>1024</size>
<contactEmail>[email protected]</contactEmail>
<rpm>
<group>Application/Collectors</group>
Expand Down
1 change: 1 addition & 0 deletions unix-handbook/src/main/docbook/examples/basic/pom-zip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<extensions>true</extensions>
<configuration>
<contact>Acme</contact>
<size>1024</size>
<contactEmail>[email protected]</contactEmail>
<assembly>
<copyArtifact>
Expand Down
Loading